晓夏

YoungCheung

Zhang Sir's technical way

Kubernetes 实际案例

浏览量:629

1、创建版本为v1.10 副本集为3的nginx

kubectl run nginx --replicas=3 --labels="app=nginx-example" --image=nginx:1.10 --port=80

2、查看

kubectl get deploy
kubectl get pods --show-labels
kubectl get pods -l app=nginx-example 
kubectl get pods -o wide

3、发布

[root@linux-node1 ~]# kubectl expose deployment nginx --port=88 --type=NodePort --target-port=80 --name=nginx-service
kubectl describe service nginx-serviceservice "nginx-service" exposed
[root@linux-node1 ~]# kubectl describe service nginx-service
Name:                     nginx-service
Namespace:                default
Labels:                   app=nginx-example
Annotations:              <none>
Selector:                 app=nginx-example
Type:                     NodePort
IP:                       10.1.216.70
Port:                     <unset>  88/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  35769/TCP
Endpoints:                10.2.41.10:80,10.2.41.9:80,10.2.99.7:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

4、更新

kubectl set image deployment/nginx  nginx=nginx:1.11
or
kubectl edit deployment/nginx

5、资源发布管理

kubectl rollout status deployment/nginx  
kubectl rollout history deployment/nginx
kubectl rollout history deployment/nginx --revision=3

6、扩容

kubectl scale deployment nginx --replicas=5

7、回滚

kubectl rollout undo deployment.apps/nginx
kubectl rollout undo deployment/nginx-deployment --to-revision=3

8、删除

kubectl delete deploy/nginx 
kubectl delete svc/nginx-service



神回复

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。