K8S中的cordon趴生、uncordon和drain

node及pod狀態(tài)

[root@hanyu-210 ~]# kubectl get nodes
NAME        STATUS   ROLES    AGE   VERSION
hanyu-210   Ready    master   31d   v1.16.0
hanyu-211   Ready    <none>   31d   v1.16.0
hanyu-212   Ready    <none>   31d   v1.16.0
[root@hanyu-210 ~]# kubectl get pods -o wide|grep nginx
nginx-deployment-test-557d8b6448-4pb46   1/1     Running     0          67s     10.244.1.62   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-52fk9   1/1     Running     0          67s     10.244.0.42   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-h675g   1/1     Running     0          67s     10.244.2.40   hanyu-212   <none>           <none>

cordon節(jié)點hanyu-212阀趴,hanyu-212變?yōu)椴豢烧{(diào)度

[root@hanyu-210 ~]# kubectl cordon hanyu-212
node/hanyu-212 cordoned
[root@hanyu-210 ~]# kubectl get nodes
NAME        STATUS                     ROLES    AGE   VERSION
hanyu-210   Ready                      master   31d   v1.16.0
hanyu-211   Ready                      <none>   31d   v1.16.0
hanyu-212   Ready,SchedulingDisabled   <none>   31d   v1.16.0

將pod副本數(shù)擴到10個,可以看到新增的pod分布到hanyu-210和hanyu-211上

[root@hanyu-210 ~]# kubectl scale --replicas=10 deployment nginx-deployment-test
deployment.apps/nginx-deployment-test scaled
[root@hanyu-210 ~]# kubectl get pods -o wide|grep nginx
nginx-deployment-test-557d8b6448-2jx9j   1/1     Running     0          4m32s   10.244.0.45   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-4pb46   1/1     Running     0          8m37s   10.244.1.62   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-52fk9   1/1     Running     0          8m37s   10.244.0.42   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-cjlrp   1/1     Running     0          4m32s   10.244.0.44   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-h675g   1/1     Running     0          8m37s   10.244.2.40   hanyu-212   <none>           <none>
nginx-deployment-test-557d8b6448-hklq5   1/1     Running     0          5m11s   10.244.1.63   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-k9vbj   1/1     Running     0          5m11s   10.244.0.43   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-nbzh4   1/1     Running     0          4m32s   10.244.1.66   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-qlm9p   1/1     Running     0          4m32s   10.244.1.65   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-xrxp9   1/1     Running     0          5m11s   10.244.1.64   hanyu-211   <none>           <none>

unrdon節(jié)點hanyu-212苍匆,hanyu-212變?yōu)榭烧{(diào)度

[root@hanyu-210 ~]# kubectl uncordon hanyu-212
node/hanyu-212 uncordoned
[root@hanyu-210 ~]# kubectl get nodes
NAME        STATUS   ROLES    AGE   VERSION
hanyu-210   Ready    master   31d   v1.16.0
hanyu-211   Ready    <none>   31d   v1.16.0
hanyu-212   Ready    <none>   31d   v1.16.0

再次副本數(shù)擴到15刘急,可以看到新增的pod分布到hanyu-210、hanyu-211和hanyu-212上

[root@hanyu-210 ~]# kubectl scale --replicas=15 deployment nginx-deployment-test
deployment.apps/nginx-deployment-test scaled
[root@hanyu-210 ~]# kubectl get pods -o wide|grep nginx
nginx-deployment-test-557d8b6448-2jx9j   1/1     Running     0          7m39s   10.244.0.45   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-4jfqv   1/1     Running     0          2m9s    10.244.1.67   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-4pb46   1/1     Running     0          11m     10.244.1.62   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-52fk9   1/1     Running     0          11m     10.244.0.42   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-bmgl5   1/1     Running     0          2m9s    10.244.2.42   hanyu-212   <none>           <none>
nginx-deployment-test-557d8b6448-cjlrp   1/1     Running     0          7m39s   10.244.0.44   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-ggd8d   1/1     Running     0          2m9s    10.244.2.43   hanyu-212   <none>           <none>
nginx-deployment-test-557d8b6448-h675g   1/1     Running     0          11m     10.244.2.40   hanyu-212   <none>           <none>
nginx-deployment-test-557d8b6448-hklq5   1/1     Running     0          8m18s   10.244.1.63   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-k9vbj   1/1     Running     0          8m18s   10.244.0.43   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-lhqzz   1/1     Running     0          2m9s    10.244.2.44   hanyu-212   <none>           <none>
nginx-deployment-test-557d8b6448-nbzh4   1/1     Running     0          7m39s   10.244.1.66   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-qlm9p   1/1     Running     0          7m39s   10.244.1.65   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-s94d4   1/1     Running     0          2m9s    10.244.2.41   hanyu-212   <none>           <none>
nginx-deployment-test-557d8b6448-xrxp9   1/1     Running     0          8m18s   10.244.1.64   hanyu-211   <none>           <none>

drain節(jié)點hanyu-212浸踩,hanyu-212變?yōu)椴豢烧{(diào)度叔汁,同時驅(qū)逐了原來hanyu-212上的pod

[root@hanyu-210 ~]# kubectl drain hanyu-212
node/hanyu-212 already cordoned
error: unable to drain node "hanyu-212", aborting command...

There are pending nodes to be drained:
 hanyu-212
cannot delete Pods with local storage (use --delete-local-data to override): default/nginx-deployment-test-557d8b6448-bmgl5, default/nginx-deployment-test-557d8b6448-ggd8d, default/nginx-deployment-test-557d8b6448-h675g, default/nginx-deployment-test-557d8b6448-lhqzz, default/nginx-deployment-test-557d8b6448-s94d4
cannot delete DaemonSet-managed Pods (use --ignore-daemonsets to ignore): kube-system/kube-flannel-ds-amd64-djgjx, kube-system/kube-proxy-qj5wn
[root@hanyu-210 ~]# kubectl drain hanyu-212 --delete-local-data --ignore-daemonsets
node/hanyu-212 already cordoned
WARNING: ignoring DaemonSet-managed Pods: kube-system/kube-flannel-ds-amd64-djgjx, kube-system/kube-proxy-qj5wn
evicting pod "zookeeper-2"
evicting pod "mariadb-slave-0"
evicting pod "nginx-deployment-test-557d8b6448-bmgl5"
evicting pod "nginx-deployment-test-557d8b6448-h675g"
evicting pod "nginx-deployment-test-557d8b6448-lhqzz"
evicting pod "nginx-deployment-test-557d8b6448-s94d4"
evicting pod "nginx-deployment-test-557d8b6448-ggd8d"
pod/nginx-deployment-test-557d8b6448-bmgl5 evicted
pod/nginx-deployment-test-557d8b6448-s94d4 evicted
pod/nginx-deployment-test-557d8b6448-h675g evicted
pod/nginx-deployment-test-557d8b6448-ggd8d evicted
pod/zookeeper-2 evicted
pod/nginx-deployment-test-557d8b6448-lhqzz evicted
pod/mariadb-slave-0 evicted
node/hanyu-212 evicted
[root@hanyu-210 ~]# kubectl get node
NAME        STATUS                     ROLES    AGE   VERSION
hanyu-210   Ready                      master   31d   v1.16.0
hanyu-211   Ready                      <none>   31d   v1.16.0
hanyu-212   Ready,SchedulingDisabled   <none>   31d   v1.16.0
[root@hanyu-210 ~]# kubectl get pods -o wide|grep nginx
nginx-deployment-test-557d8b6448-2jx9j   1/1     Running             0          11m     10.244.0.45   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-4jfqv   1/1     Running             0          5m45s   10.244.1.67   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-4pb46   1/1     Running             0          15m     10.244.1.62   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-52fk9   1/1     Running             0          15m     10.244.0.42   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-5ftf8   0/1     ContainerCreating   0          24s     <none>        hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-7chpj   0/1     ContainerCreating   0          24s     <none>        hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-cjlrp   1/1     Running             0          11m     10.244.0.44   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-cw2bv   1/1     Running             0          24s     10.244.1.68   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-hklq5   1/1     Running             0          11m     10.244.1.63   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-k9vbj   1/1     Running             0          11m     10.244.0.43   hanyu-210   <none>           <none>
nginx-deployment-test-557d8b6448-nbzh4   1/1     Running             0          11m     10.244.1.66   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-qlm9p   1/1     Running             0          11m     10.244.1.65   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-tb2p8   0/1     ContainerCreating   0          24s     <none>        hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-xrxp9   1/1     Running             0          11m     10.244.1.64   hanyu-211   <none>           <none>
nginx-deployment-test-557d8b6448-zlgsr   0/1     ContainerCreating   0          24s     <none>        hanyu-211   <none>           <none>
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市检碗,隨后出現(xiàn)的幾起案子据块,更是在濱河造成了極大的恐慌,老刑警劉巖折剃,帶你破解...
    沈念sama閱讀 219,270評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件另假,死亡現(xiàn)場離奇詭異,居然都是意外死亡怕犁,警方通過查閱死者的電腦和手機边篮,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,489評論 3 395
  • 文/潘曉璐 我一進店門己莺,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人戈轿,你說我怎么就攤上這事凌受。” “怎么了凶杖?”我有些...
    開封第一講書人閱讀 165,630評論 0 356
  • 文/不壞的土叔 我叫張陵胁艰,是天一觀的道長。 經(jīng)常有香客問我智蝠,道長腾么,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,906評論 1 295
  • 正文 為了忘掉前任杈湾,我火速辦了婚禮解虱,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘漆撞。我一直安慰自己殴泰,他們只是感情好,可當我...
    茶點故事閱讀 67,928評論 6 392
  • 文/花漫 我一把揭開白布浮驳。 她就那樣靜靜地躺著悍汛,像睡著了一般。 火紅的嫁衣襯著肌膚如雪至会。 梳的紋絲不亂的頭發(fā)上离咐,一...
    開封第一講書人閱讀 51,718評論 1 305
  • 那天,我揣著相機與錄音奉件,去河邊找鬼宵蛀。 笑死,一個胖子當著我的面吹牛县貌,可吹牛的內(nèi)容都是我干的术陶。 我是一名探鬼主播,決...
    沈念sama閱讀 40,442評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼煤痕,長吁一口氣:“原來是場噩夢啊……” “哼梧宫!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起摆碉,我...
    開封第一講書人閱讀 39,345評論 0 276
  • 序言:老撾萬榮一對情侶失蹤塘匣,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后兆解,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,802評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡跑揉,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,984評論 3 337
  • 正文 我和宋清朗相戀三年锅睛,在試婚紗的時候發(fā)現(xiàn)自己被綠了埠巨。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,117評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡现拒,死狀恐怖辣垒,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情印蔬,我是刑警寧澤勋桶,帶...
    沈念sama閱讀 35,810評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站侥猬,受9級特大地震影響例驹,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜退唠,卻給世界環(huán)境...
    茶點故事閱讀 41,462評論 3 331
  • 文/蒙蒙 一鹃锈、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧瞧预,春花似錦屎债、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,011評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至滩愁,卻和暖如春躯喇,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背惊楼。 一陣腳步聲響...
    開封第一講書人閱讀 33,139評論 1 272
  • 我被黑心中介騙來泰國打工玖瘸, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人檀咙。 一個月前我還...
    沈念sama閱讀 48,377評論 3 373
  • 正文 我出身青樓雅倒,卻偏偏與公主長得像,于是被迫代替她去往敵國和親弧可。 傳聞我的和親對象是個殘疾皇子蔑匣,可洞房花燭夜當晚...
    茶點故事閱讀 45,060評論 2 355