# 獨立的 Pod 如果貼上跟 Deployment 做出來的 Pod 相同的 label 會發生什麼事 * 建立 Deployment ``` $ kubectl create deploy test --image=nginx ``` * 建立獨立的 Pod ``` $ kubectl run test2 --image=nginx ``` * 檢查 Pod 的 label ``` $ kubectl get po --show-labels NAME READY STATUS RESTARTS AGE LABELS test-7895cc554-879m2 1/1 Running 0 13m app=test,pod-template-hash=7895cc554 test2 1/1 Running 0 46s run=test2 ``` * 將獨立的 Pod 貼上跟 Deployment 做出來的 Pod 相同的 label ``` $ kubectl label pod test2 app=test pod-template-hash=7895cc554 pod/test2 labeled ``` * 貼上 label 後,Pod 就被刪除了 ``` $ kubectl get po --show-labels NAME READY STATUS RESTARTS AGE LABELS test-7895cc554-879m2 1/1 Running 0 8m3s app=test,pod-template-hash=7895cc554 test2 1/1 Terminating 0 3m47s app=test,pod-template-hash=7895cc554,run=test2 ``` * 檢視 replicaset,在 event 可以發現是 replicaset 刪除了 test2 這個 pod ``` $ kubectl get rs NAME DESIRED CURRENT READY AGE test-7895cc554 1 1 1 15m $ kubectl -n test describe rs test-7895cc554 ...... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal SuccessfulCreate 16m replicaset-controller Created pod: test-7895cc554-879m2 Normal SuccessfulDelete 7m17s (x2 over 14m) replicaset-controller Deleted pod: test2 ``` ## 結論: replicaset 不允許狸貓換太子
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up