目录
前文已经安装好了一套kubernetes 1.10,下面我们来进行日常使用测试
1. 创建部署及服务
编辑一个yaml文件:
vim nginx.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-router
namespace: test
spec:
replicas: 2
template:
metadata:
labels:
app: nginx-router
spec:
containers:
- name: nginx-router
image: 172.21.248.242/base/nginx
ports:
- containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: nginx-router
namespace: test
spec:
selector:
app: nginx-router
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-router-ingress
namespace: test
annotations:
kubernetes.io/ingress.class: traefik
spec:
rules:
- host: "nginx.k8s.dev.huilog.com"
http:
paths:
- backend:
serviceName: nginx-router
servicePort: 80
# 创建部署及服务:
[root@bs-ops-test-docker-dev-01 dev]# kubectl create -f nginx.yaml
deployment.extensions "nginx-router" created
service "nginx-router" created
ingress.extensions "nginx-router-ingress" created
[root@bs-ops-test-docker-dev-01 dev]#