zoukankan      html  css  js  c++  java
  • kubernetes Label的增删改查

    查:

    [root@k8s-host1 liang]# kubectl get nodes --show-labels
    NAME STATUS ROLES AGE VERSION LABELS
    k8s-host1 Ready master 173d v1.16.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,edgenode=true,ingress=yes,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-host1,kubernetes.io/os=linux,node-role.kubernetes.io/master=
    k8s-host2 Ready master 173d v1.16.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-host2,kubernetes.io/os=linux,node-role.kubernetes.io/master=
    k8s-host3 Ready master 173d v1.16.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-host3,kubernetes.io/os=linux,node-role.kubernetes.io/master=
    

      

    增:

    # 语法
    
    kubectl label nodes <node-name> <label-key>=<label-value> 
    
    #给k8s-host1添加一个标签device为ssd
    
    [root@k8s-host1 liang]# kubectl label nodes k8s-host1 device=ssd
    node/k8s-host1 labeled
    
     
    

      

    改:

    #语法: 需要加上--overwrite参数:
    
    kubectl label nodes <node-name> <label-key>=<label-value> --overwrite
    
    [root@k8s-host1 liang]# kubectl label nodes k8s-host1 device=liang --overwrite
    node/k8s-host1 labeled
    
    #查看修改:
    [root@k8s-host1 liang]# kubectl get nodes k8s-host1 --show-labels
    NAME STATUS ROLES AGE VERSION LABELS
    k8s-host1 Ready master 173d v1.16.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,device=liang,edgenode=true,ingress=yes,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-host1,kubernetes.io/os=linux,node-role.kubernetes.io/master=
    

      

    删:

    # 语法
    kubectl label nodes <node-name> <label-key>-
    [root@k8s-host1 liang]# kubectl label nodes k8s-host1 device-
    node/k8s-host1 labeled
    
    #查看删除:
    
    [root@k8s-host1 liang]# kubectl get nodes k8s-host1 --show-labels
    NAME STATUS ROLES AGE VERSION LABELS
    k8s-host1 Ready master 173d v1.16.2 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,edgenode=true,ingress=yes,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8s-host1,kubernetes.io/os=linux,node-role.kubernetes.io/master=
    

      

    Pod选择label

    # 添加nodeSelector选项用来选择对应的node
    apiVersion: v1
    kind: Pod
    metadata:
      name: nginx
      labels:
        env: test
    spec:
      containers:
      - name: nginx
        image: nginx
        imagePullPolicy: IfNotPresent
      nodeSelector:
        device: ssd
    

      

     
  • 相关阅读:
    史上最全的 Python 3 类型转换指南
    Python 3 进阶 —— print 打印和输出
    Go 标准库 —— sync.Mutex 互斥锁
    Python 判断文件/目录是否存在
    测试用例设计——如何提高测试覆盖率
    多语言的测试经验分享
    robotium教材(一):robotium环境搭建
    Android应用开发中出现appcompat-v7错误
    Android CPU使用率:top和dump cpuinfo的不同
    Kernel Time和User Time分别指什么
  • 原文地址:https://www.cnblogs.com/thirteen-yang/p/12957305.html
Copyright © 2011-2022 走看看