- apiVersion: extensions/v1beta1
- kind: Deployment
- metadata:
- name: my-nginx
- spec:
- replicas: 2
- template:
- metadata:
- labels:
- run: my-nginx
- spec:
- containers:
- - name: my-nginx
- imagePullPolicy: IfNotPresent #默认拉取方式,先查本地是否存在
- image: nginx:v1.1.1
- ports:
- - containerPort: 80
1)创建
- # kubectl create -f run-my-nginx.yaml
返回信息:
2)查看 pods
- # kubectl get pods --all-namespaces
返回信息:
- # kubectl delete -f run-my-nginx.yaml
返回信息:
1)由两个 nginx pod 扩到五个 pod
- # kubectl scale --replicas=5 -f run-my-nginx.yaml
返回信息:
2)查看 pods
- # kubectl get pods --all-namespaces
返回信息:
1)由五个 nginx pod 缩到两个 pod
- # kubectl scale --replicas=2 -f run-my-nginx.yaml
返回信息:
2)查看 pods
- # kubectl get pods --all-namespaces
返回信息:
- # kubectl expose deployment my-nginx --target-port=80 --port=8081 --protocol=TCP --type=NodePort
返回信息:
1)查看容器的 IP
- # kubectl get ep my-nginx
返回信息:
2)查看容器详细信息
- # kubectl describe svc my-nginx
返回信息:
得知暴露在外面的端口为 31838。
访问地址:http://192.168.6.132:31838/
返回页面:
来源: http://www.cnblogs.com/RUReady/p/6519972.html