• pod 迁移


    一、查看节点上的pod

    root@master:/usr/local/bin# kubectl get pod -o wide
    NAME                             READY   STATUS    RESTARTS   AGE   IP            NODE    NOMINATED NODE   READINESS GATES
    busybox-master-cf9989dc9-bbsdr   1/1     Running   0          28h   10.244.2.6    node1   <none>           <none>
    busybox-master-cf9989dc9-v98bp   1/1     Running   0          25h   10.244.2.10   node1   <none>           <none>
    busybox-master-cf9989dc9-wczpm   1/1     Running   0          28h   10.244.2.7    node1   <none>           <none>
    nginx-master-fbc95f85-g27fm      1/1     Running   0          9h    10.244.2.21   node1   <none>           <none>
    nginx-master-fbc95f85-qg42w      1/1     Running   0          9h    10.244.2.19   node1   <none>           <none>
    nginx-master-fbc95f85-qpxqn      1/1     Running   0          9h    10.244.2.20   node1   <none>           <none>
    ssh-server-66d95b8bd4-zp69j      1/1     Running   0          25h   10.244.2.9    node1   <none>           <none>

    二、标记节点不可用

    root@master:/usr/local/bin# kubectl cordon node1
    node/node1 cordoned

    三、查看节点状态

    root@master:/usr/local/bin# kubectl get node
    NAME     STATUS                     ROLES    AGE     VERSION
    master   Ready                      master   6d23h   v1.19.13
    node     Ready                      <none>   6d10h   v1.19.13
    node1    Ready,SchedulingDisabled   <none>   2d8h    v1.19.13

    四、查看pod状态

    root@master:/usr/local/bin# kubectl get pod -o wide
    NAME                             READY   STATUS    RESTARTS   AGE   IP            NODE    NOMINATED NODE   READINESS GATES
    nginx-master-fbc95f85-g27fm      1/1     Running   0          9h    10.244.2.21   node1   <none>           <none>
    nginx-master-fbc95f85-qg42w      1/1     Running   0          9h    10.244.2.19   node1   <none>           <none>
    nginx-master-fbc95f85-qpxqn      1/1     Running   0          9h    10.244.2.20   node1   <none>           <none>
    

    五、驱赶pod

    root@master:/usr/local/bin# kubectl drain node1 --delete-local-data --ignore-daemonsets --force
    node/node1 already cordoned
    WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-flannel-ds-kvc6x, kube-system/kube-proxy-8znjq, venus-defender/defender-8knnd
    evicting pod kube-system/coredns-f9fd979d6-bb5hf
    evicting pod default/nginx-master-fbc95f85-qg42w
    evicting pod default/ssh-server-66d95b8bd4-zp69j
    evicting pod default/busybox-master-cf9989dc9-bbsdr
    evicting pod default/nginx-master-fbc95f85-qpxqn
    evicting pod default/busybox-master-cf9989dc9-wczpm
    evicting pod default/busybox-master-cf9989dc9-v98bp
    evicting pod default/nginx-master-fbc95f85-g27fm
    pod/coredns-f9fd979d6-bb5hf evicted
    pod/nginx-master-fbc95f85-g27fm evicted
    pod/nginx-master-fbc95f85-qpxqn evicted
    I0819 19:32:46.073806  932974 request.go:645] Throttling request took 1.149915211s, request: GET:https://192.168.33.15:6443/api/v1/namespaces/default/pods/busybox-master-cf9989dc9-v98bp
    pod/ssh-server-66d95b8bd4-zp69j evicted
    pod/nginx-master-fbc95f85-qg42w evicted
    pod/busybox-master-cf9989dc9-wczpm evicted
    pod/busybox-master-cf9989dc9-v98bp evicted
    pod/busybox-master-cf9989dc9-bbsdr evicted
    node/node1 evicted

    六、查看pod状态

    root@master:~# kubectl get pod -o wide
    nginx-master-fbc95f85-kqdnv      1/1     Running            0          4m8s   10.244.1.153   node   <none>           <none>
    nginx-master-fbc95f85-nnzhp      1/1     Running            0          4m8s   10.244.1.149   node   <none>           <none>
    nginx-master-fbc95f85-vvwgn      1/1     Running            0          4m8s   10.244.1.150   node   <none>           <none>

    七、取消标记

    root@master:/k8s/pod# kubectl uncordon node1
    node/node1 uncordoned

    八、查看节点状态

    root@master:/k8s/pod# kubectl get node
    NAME     STATUS   ROLES    AGE     VERSION
    master   Ready    master   6d23h   v1.19.13
    node     Ready    <none>   6d10h   v1.19.13
    node1    Ready    <none>   2d8h    v1.19.13
    作者:赵世渊

    -------------------------------------------

    个性签名:独学而无友,则孤陋而寡闻。

    如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!

  • 相关阅读:
    WAF攻防实战
    简单的Web日志分析脚本
    android multicast 多播(组播)问题
    easyhadoop:failed to open stream:Permission denied in /var/www/html/index.php
    Codeforces Round #215 (Div. 2) A. Sereja and Coat Rack
    删除workspace下的vss的scc文件
    由两代WIN8 Surface平板看微软心态
    C++ 需要返回值的函数却没有返回值的情况 单例模式
    调整系统的inode数量
    平衡树
  • 原文地址:https://www.cnblogs.com/Raphel/p/15163588.html
Copyright © 2020-2023  润新知