Kubernetes 的命令管理

Kubernetes 的命令管理

標籤(空格分隔): kubernetes系列node


  • 一: kubernetes 的命令介紹
  • 二: kubernetes 的 生命週期管理
  • 三: kubernetes 的遠程鏈接處理

一: kubernetes的命令的介紹

image_1dbriuljtjvneo1s6fmf1pnd19.png-1011.5kB

kubectl get all

image_1dbrjis441cu61kb71714rs2186h9.png-263.2kB

kubectl get all -o wide

image_1dbrjlh6tj2fqfqg6o2foaj71m.png-315kB

kubectl get all -o wide -n kube-system

image_1dbrjn0281kr11o4u1sgag45mds23.png-326.1kB

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

image_1dksecpqj13s31tmvutq14241vdf9.png-565.8kB


二: kubernetes 部署項目的 生命週期

kubectl 部署一個nginx 

一、建立
kubectl run nginx --replicas=3 --image=nginx:1.14 --port=80
kubectl get deploy,pods

二、發佈
kubectl expose deployment nginx --port=80 --type=NodePort --target-port=80 --name=nginx-service
kubectl get service

三、更新
kubectl set image deployment/nginx nginx=nginx:1.15

四、回滾

kubectl rollout history deployment/nginx
kubectl rollout undo deployment/nginx

kubectl rollout undo deployment/nginx --to-revision=1

五、刪除

kubectl delete deploy/nginx
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 文件

login:192.168.100.11 master 節點
cd /opt/kubernetes/ssl

vim config.sh
----
kubectl config set-cluster kubernetes \
  --certificate-authority=ca.pem \
  --embed-certs=true \
  --server=https://192.168.100.11:6443 \
  --kubeconfig=config

kubectl config set-credentials cluster-admin \
  --certificate-authority=ca.pem \
  --embed-certs=true \
  --client-key=admin-key.pem \
  --client-certificate=admin.pem \
  --kubeconfig=config

kubectl config set-context default --cluster=kubernetes --user=cluster-admin --kubeconfig=config
kubectl config use-context default --kubeconfig=config
----

./config.sh

生成config 文件

scp config root@192.168.100.13:/root
login : 192.168.100.13 node 節點

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

mv config /root/.kube/

kubectl get node

image_1dksm6e1faet13lijje1rk5dp72i.png-185.3kB

相關文章
相關標籤/搜索