k8s操作常见命令-我是一个粉刷匠

创建测试kubectl run net-test --image=alpine --replicas=2 sleep 3600

查看pod的情况kubectl get pod -o wide

查看某个pod的详情kubectl describe pod pod-name

先生成一个nginx-deployment.yaml文件kubectl create -f nginx-deployment.yaml 查看deploymentkubectl get deployment

查看某个deployment的详情kubectl describe deployment nginx-deployment

更新depolyment--record 参数用于记录日志,方便后期的回滚操作kubectl set image deployment/nginx-deployment nginx=nginx.1.12.1 --record

查看更新历史记录kubectl rollout history deployment/nginx-deployment

查看某个版本的操作历史详情kubectl rollout history deployment/nginx-deployment --revision=1

快速回滚操作kubectl rollout undo deployment/nginx-deployment

pod的ip会随机变化,但是访问的不是pod id ,而是 service ip ,这个才是vip

查看service

[root@linux-node1 scripts]# kubectl get service
NAME                       TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
garish-butterfly-mychart   ClusterIP   10.1.40.122    <none>        80/TCP    10d
kubernetes                 ClusterIP   10.1.0.1       <none>        443/TCP   16d
nginx-service              ClusterIP   10.1.178.121   <none>        80/TCP    16d
点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注