kubectl cordon pcl001-desktop
[root@cloud temperature_yaml]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 28d v1.18.6 edge-vm Ready agent,edge 54m v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready,SchedulingDisabled agent,edge 6d6h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1
[root@cloud temperature_yaml]# kubectl get nodes --show-labels NAME STATUS ROLES AGE VERSION LABELS cloud Ready master 28d v1.18.6 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=cloud,kubernetes.io/os=linux,node-role.kubernetes.io/master= edge-vm Ready agent,edge 56m v1.19.3-kubeedge-v1.6.1 kubernetes.io/arch=arm64,kubernetes.io/hostname=edge-vm,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= edge01 Ready <none> 14d v1.21.1 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=edge01,kubernetes.io/os=linux pcl001-desktop Ready,SchedulingDisabled agent,edge 6d6h v1.19.3-kubeedge-v1.6.1 kubernetes.io/arch=arm64,kubernetes.io/hostname=pcl001-desktop,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 app-offline.kubeedge.io=autonomy,kubernetes.io/arch=arm,kubernetes.io/hostname=raspberrypi,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= [root@cloud temperature_yaml]#
[root@cloud temperature_yaml]# cat deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: temperature-simulate-mapper labels: app: temperature spec: replicas: 1 selector: matchLabels: app: temperature template: metadata: labels: app: temperature spec: hostNetwork: true nodeName: pcl001-desktop containers: - name: temperature image: temperature-simulate-mapper:test-0629 imagePullPolicy: IfNotPresent securityContext: privileged: true
[root@cloud temperature_yaml]# kubectl drain pcl001-desktop --delete-local-data --ignore-daemonsets --force node/pcl001-desktop already cordoned WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-qxw82 evicting pod default/temperature-simulate-mapper-5fcfb9d776-x97bt pod/temperature-simulate-mapper-5fcfb9d776-x97bt evicted node/pcl001-desktop evicted [root@cloud temperature_yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d8h temperature-simulate-mapper-5fcfb9d776-xx2nt 1/1 Running 0 29s [root@cloud temperature_yaml]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d8h 10.244.204.1 edge01 <none> <none> temperature-simulate-mapper-5fcfb9d776-xx2nt 1/1 Running 0 37s 192.168.117.50 pcl001-desktop <none> <none> [root@cloud temperature_yaml]#
没有迁移成功
[root@cloud temperature_yaml]# kubectl label nodes pcl001-desktop edge/role= temperature --有空格 error: all resources must be specified before label changes: temperature [root@cloud temperature_yaml]# kubectl get nodes --show-labels NAME STATUS ROLES AGE VERSION LABELS cloud Ready master 29d v1.18.6 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=cloud,kubernetes.io/os=linux,node-role.kubernetes.io/master= edge-vm Ready agent,edge 158m v1.19.3-kubeedge-v1.6.1 kubernetes.io/arch=arm64,kubernetes.io/hostname=edge-vm,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= edge01 Ready <none> 14d v1.21.1 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=edge01,kubernetes.io/os=linux pcl001-desktop Ready,SchedulingDisabled agent,edge 6d8h v1.19.3-kubeedge-v1.6.1 kubernetes.io/arch=arm64,kubernetes.io/hostname=pcl001-desktop,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 app-offline.kubeedge.io=autonomy,kubernetes.io/arch=arm,kubernetes.io/hostname=raspberrypi,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= [root@cloud temperature_yaml]#
标签有问题
[root@cloud temperature_yaml]# kubectl label nodes pcl001-desktop edge/role=temperature node/pcl001-desktop labeled [root@cloud temperature_yaml]# kubectl get nodes --show-labels NAME STATUS ROLES AGE VERSION LABELS cloud Ready master 29d v1.18.6 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=cloud,kubernetes.io/os=linux,node-role.kubernetes.io/master= edge-vm Ready agent,edge 160m v1.19.3-kubeedge-v1.6.1 kubernetes.io/arch=arm64,kubernetes.io/hostname=edge-vm,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= edge01 Ready <none> 14d v1.21.1 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=edge01,kubernetes.io/os=linux pcl001-desktop Ready,SchedulingDisabled agent,edge 6d8h v1.19.3-kubeedge-v1.6.1 edge/role=temperature,kubernetes.io/arch=arm64,kubernetes.io/hostname=pcl001-desktop,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 app-offline.kubeedge.io=autonomy,kubernetes.io/arch=arm,kubernetes.io/hostname=raspberrypi,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= [root@cloud temperature_yaml]#
[root@cloud temperature_yaml]# kubectl uncordon pcl001-desktop node/pcl001-desktop uncordoned [root@cloud temperature_yaml]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 161m v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready agent,edge 6d8h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud temperature_yaml]#
[root@cloud temperature_yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d10h temperature-simulate-mapper-5fcfb9d776-bq8bt 1/1 Running 0 54s [root@cloud temperature_yaml]# ls crds deployment.yaml [root@cloud temperature_yaml]# kubectl delete pods temperature-simulate-mapper-5fcfb9d776-bq8bt --force --grace-period=0 warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. pod "temperature-simulate-mapper-5fcfb9d776-bq8bt" force deleted [root@cloud temperature_yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d10h temperature-simulate-mapper-5fcfb9d776-qnrzz 0/1 Pending 0 4s [root@cloud temperature_yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d10h temperature-simulate-mapper-5fcfb9d776-qnrzz 1/1 Running 0 10s [root@cloud temperature_yaml]#
[root@cloud temperature_yaml]# kubectl delete -f deployment.yaml deployment.apps "temperature-simulate-mapper" deleted [root@cloud temperature_yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d10h [root@cloud temperature_yaml]#
重新部署
[root@cloud ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 175m v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready,SchedulingDisabled agent,edge 6d8h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud ~]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d10h temperature-simulate-mapper-588ff95b6d-l7d4l 0/1 ContainerCreating 0 3m13s [root@cloud ~]#
[root@cloud temperature_yaml]# cat deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: temperature-simulate-mapper labels: app: temperature spec: replicas: 1 selector: matchLabels: app: temperature template: metadata: labels: app: temperature spec: hostNetwork: true #nodeName: pcl001-desktop nodeSelector: edge/role: temperature containers: - name: temperature image: temperature-simulate-mapper:test-0629 imagePullPolicy: IfNotPresent securityContext: privileged: true
[root@cloud temperature_yaml]# kubectl apply -f deployment.yaml
deployment.apps/temperature-simulate-mapper created
[root@cloud temperature_yaml]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 7d10h temperature-simulate-mapper-588ff95b6d-mjk4h 1/1 Running 0 52s [root@cloud temperature_yaml]#
给另外的的node打个label
[root@cloud temperature_yaml]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 169m v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready agent,edge 6d8h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud temperature_yaml]# kubectl label nodes edge-vm edge/role=temperature node/edge-vm labeled [root@cloud temperature_yaml]#
[root@cloud temperature_yaml]# kubectl get nodes --show-labels NAME STATUS ROLES AGE VERSION LABELS cloud Ready master 29d v1.18.6 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=cloud,kubernetes.io/os=linux,node-role.kubernetes.io/master= edge-vm Ready agent,edge 171m v1.19.3-kubeedge-v1.6.1 edge/role=temperature,kubernetes.io/arch=arm64,kubernetes.io/hostname=edge-vm,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= edge01 Ready <none> 14d v1.21.1 beta.kubernetes.io/arch=arm64,beta.kubernetes.io/os=linux,kubernetes.io/arch=arm64,kubernetes.io/hostname=edge01,kubernetes.io/os=linux pcl001-desktop Ready agent,edge 6d8h v1.19.3-kubeedge-v1.6.1 edge/role=temperature,kubernetes.io/arch=arm64,kubernetes.io/hostname=pcl001-desktop,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 app-offline.kubeedge.io=autonomy,kubernetes.io/arch=arm,kubernetes.io/hostname=raspberrypi,kubernetes.io/os=linux,node-role.kubernetes.io/agent=,node-role.kubernetes.io/edge= [root@cloud temperature_yaml]#
kubectl drain驱逐节点上的pod
[root@cloud ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready,SchedulingDisabled agent,edge 16h v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready agent,edge 6d22h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud ~]# kubectl delete pods edge-vm --force --grace-period=0 warning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely. Error from server (NotFound): pods "edge-vm" not found [root@cloud ~]# kubectl drain edge-vm --delete-local-data --ignore-daemonsets --force node/edge-vm already cordoned WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-5hn2t evicting pod default/temperature-simulate-mapper-588ff95b6d-25r2q pod/temperature-simulate-mapper-588ff95b6d-25r2q evicted node/edge-vm evicted [root@cloud ~]# kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-c85df76f4-gj65j 1/1 Running 0 8d temperature-simulate-mapper-588ff95b6d-2cwhb 1/1 Running 0 54s [root@cloud ~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-deployment-c85df76f4-gj65j 1/1 Running 0 8d 10.244.204.1 edge01 <none> <none> temperature-simulate-mapper-588ff95b6d-2cwhb 1/1 Running 0 61s 192.168.117.50 pcl001-desktop <none> <none> [root@cloud ~]#
[root@cloud ~]# kubectl uncordon edge-vm node/edge-vm uncordoned [root@cloud ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 16h v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready agent,edge 6d22h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud ~]#
迁回
[root@cloud ~]# kubectl uncordon edge-vm node/edge-vm uncordoned [root@cloud ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 16h v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready agent,edge 6d22h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud ~]# kubectl cordon pcl001-desktop node/pcl001-desktop cordoned [root@cloud ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 16h v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready,SchedulingDisabled agent,edge 6d22h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud ~]# kubectl drain pcl001-desktop --delete-local-data --ignore-daemonsets --force node/pcl001-desktop already cordoned WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-proxy-qxw82 evicting pod default/temperature-simulate-mapper-588ff95b6d-2cwhb pod/temperature-simulate-mapper-588ff95b6d-2cwhb evicted node/pcl001-desktop evicted
// ip 变了 [root@cloud ~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-deployment-c85df76f4-gj65j 1/1 Running 0 8d 10.244.204.1 edge01 <none> <none> temperature-simulate-mapper-588ff95b6d-hd8hr 1/1 Running 0 92s 12.0.0.122 edge-vm <none> <none> [root@cloud ~]#
[root@cloud ~]# kubectl uncordon pcl001-desktop node/pcl001-desktop uncordoned [root@cloud ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION cloud Ready master 29d v1.18.6 edge-vm Ready agent,edge 16h v1.19.3-kubeedge-v1.6.1 edge01 Ready <none> 14d v1.21.1 pcl001-desktop Ready agent,edge 6d22h v1.19.3-kubeedge-v1.6.1 raspberrypi NotReady agent,edge 26d v1.19.3-kubeedge-v1.6.1 [root@cloud ~]#