标签:metadata template k8s overwrite -- select 应用 test write
一、创建POD时指定相应标签apiVersion: v1
kind: Pod
metadata:
name: kubia-manual
namespace: test
labels:
app: web_html #定义了app标签为:web_html
env: prod #定义了env标签为:prod
spec:
containers:
- name: kubia
image: luksa/kubia
ports:
- containerPort: 8080
protocol: TCP
[root@test-nodes1 ~]# kubectl get pod --show-labels -n test #查看所有pod的标签
NAME READY STATUS RESTARTS AGE LABELS
kubia-manual 1/1 Running 0 47h app=web_test,env=prod
nginx-dp-856666d759-bfrgj 1/1 Running 0 3d9h app=nginx-proxy,env=test,pod-template-hash=856666d759
nginx-dp-856666d759-c5p4l 1/1 Running 0 3d9h app=nginx-proxy,env=test,pod-template-hash=856666d759
[root@test-nodes1 ~]# kubectl get pod -l env=prod -n test #查看env=prod的标签
NAME READY STATUS RESTARTS AGE
kubia-manual 1/1 Running 0 47h
[root@test-nodes1 ~]# kubectl get pod -l env=prod -n test
NAME READY STATUS RESTARTS AGE
kubia-manual 1/1 Running 0 47h
[root@test-nodes1 ~]# kubectl label pod kubia-manual env=debug --overwrite -n test
pod/kubia-manual labeled
[root@test-nodes1 ~]# kubectl get pod --show-labels -n test | grep env=debug
kubia-manual 1/1 Running 0 47h app=web_test,env=debug
[root@test-nodes1 ~]# kubectl label pod kubia-manual mingkang_test=test -n test
pod/kubia-manual labeled
[root@test-nodes1 ~]# kubectl get pod --show-labels -n test | grep kubia-manual
kubia-manual 1/1 Running 0 47h app=web_test,env=debug,mingkang_test=test
apiVersion: v1
kind: Pod
metadata:
name: kubia-manual
namespace: test
labels:
app: web_html
env: prod
spec:
nodeSelector: #节点标签选择器
gpu: true #gpu为true的节点
containers:
- name: kubia
image: luksa/kubia
ports:
- containerPort: 8080
protocol: TCP
标签:metadata template k8s overwrite -- select 应用 test write
原文地址:https://blog.51cto.com/12965094/2483745