[关闭]
@zhangyy 2020-01-16T13:35:26.000000Z 字数 1381 阅读 115

Kubernetes 的命令管理

kubernetes系列


  • 一: kubernetes 的命令介绍
  • 二: kubernetes 的 生命周期管理
  • 三: kubernetes 的远程连接处理

一: kubernetes的命令的介绍

image_1dbriuljtjvneo1s6fmf1pnd19.png-1011.5kB

  1. kubectl get all

image_1dbrjis441cu61kb71714rs2186h9.png-263.2kB

  1. kubectl get all -o wide

image_1dbrjlh6tj2fqfqg6o2foaj71m.png-315kB

  1. kubectl get all -o wide -n kube-system

image_1dbrjn0281kr11o4u1sgag45mds23.png-326.1kB

  1. kubectl get pods,svc,nodes -o wide -n kube-system --all-namespaces

image_1dksecpqj13s31tmvutq14241vdf9.png-565.8kB


二: kubernetes 部署项目的 生命周期

  1. kubectl 部署一个nginx
  2. 1、创建
  3. kubectl run nginx --replicas=3 --image=nginx:1.14 --port=80
  4. kubectl get deploy,pods
  5. 2、发布
  6. kubectl expose deployment nginx --port=80 --type=NodePort --target-port=80 --name=nginx-service
  7. kubectl get service
  8. 3、更新
  9. kubectl set image deployment/nginx nginx=nginx:1.15
  10. 4、回滚
  11. kubectl rollout history deployment/nginx
  12. kubectl rollout undo deployment/nginx
  13. kubectl rollout undo deployment/nginx --to-revision=1
  14. 5、删除
  15. kubectl delete deploy/nginx
  16. kubectl delete svc/nginx-service

image_1dbrvefpcn2c1bk21ptdk6666hm.png-266.4kB

image_1dbrvdh8011gk16bg1ubgfm41l6o9.png-356.3kB

image_1dbrvofrq5lu1eq7bph1o4k14j9.png-370.3kB

image_1dbrvuia11g448g31qle1ekc1tp51m.png-123.5kB

image_1dbrvv4lq1s35c0q2af19pdr2i23.png-238.6kB

8.png-117.6kB

9.png-475.8kB

12.png-498.9kB


三: kubernetes 的 远程连接

3.1 生成config 文件

  1. login192.168.100.11 master 节点
  2. cd /opt/kubernetes/ssl
  3. vim config.sh
  4. ----
  5. kubectl config set-cluster kubernetes \
  6. --certificate-authority=ca.pem \
  7. --embed-certs=true \
  8. --server=https://192.168.100.11:6443 \
  9. --kubeconfig=config
  10. kubectl config set-credentials cluster-admin \
  11. --certificate-authority=ca.pem \
  12. --embed-certs=true \
  13. --client-key=admin-key.pem \
  14. --client-certificate=admin.pem \
  15. --kubeconfig=config
  16. kubectl config set-context default --cluster=kubernetes --user=cluster-admin --kubeconfig=config
  17. kubectl config use-context default --kubeconfig=config
  18. ----
  19. ./config.sh
  20. 生成config 文件
  21. scp config root@192.168.100.13:/root
  1. login : 192.168.100.13 node 节点
  2. kubectl --kubeconfig=./config get pods

image_1dksk79frmm1jfjdsv167qr9716.png-263.5kB

image_1dksk7usi2mg14j3gfhouj1rps1j.png-233.8kB

image_1dkskauk510ve67m8g018mu1e5u9.png-463.1kB

image_1dksm21mk1phnnc11cm310fg1r5r25.png-310.1kB

  1. mv config /root/.kube/
  2. kubectl get node

image_1dksm6e1faet13lijje1rk5dp72i.png-185.3kB

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注