身為 DevOps 工程師,您可以使用 kubectl edit 命令更新自助服務命名空間。

必要條件

確認您具有要更新的命名空間的擁有者權限。

程序

  1. 登入主管叢集。
    kubectl vsphere login --server IP-ADDRESS-SUPERVISOR-CLUSTER --vsphere-username VCENTER-SSO-USERNAME
  2. 說明要更新的命名空間。
    kubectl describe ns testns-1
    Name:         testns
    Labels:       vSphereClusterID=domain-c50
    Annotations:  my-ann: test-ann-2
                  vmware-system-namespace-owner-count: 2
                  vmware-system-resource-pool: resgroup-153
                  vmware-system-resource-pool-cpu-limit: 0.4770
                  vmware-system-resource-pool-memory-limit: 2000Mi
                  vmware-system-self-service-namespace: true
                  vmware-system-vm-folder: group-v154
    Status:       Active
     
     
    Resource Quotas
     Name:             testns-1
     Resource          Used  Hard
     --------          ---   ---
     requests.storage  0     5000Mi
     
     
     Name:                                                                           testns-1-storagequota
     Resource                                                                        Used  Hard
     --------                                                                        ---   ---
     namespace-service-storage-profile.storageclass.storage.k8s.io/requests.storage  0     9223372036854775807
  3. 使用 kubectl edit 命令編輯命名空間。
    例如, kubectl edit ns testns-1
    kubectl edit 命令會在 KUBE_EDITOR 或 EDITOR 環境變數所定義的文字編輯器中開啟命名空間資訊清單。
  4. 更新標籤。
    例如, my-label=test-label
  5. 更新註解。
    例如, my-ann: test-ann
  6. 說明要查看更新的命名空間。
    root@localhost [ /tmp ]# kubectl describe ns testns-1
    Name:         testns-1
    Labels:       my-label=test-label
                  vSphereClusterID=domain-c50
    Annotations:  my-ann: test-ann
                  vmware-system-namespace-owner-count: 1
                  vmware-system-resource-pool: resgroup-173
                  vmware-system-resource-pool-cpu-limit: 0.4770
                  vmware-system-resource-pool-memory-limit: 2000Mi
                  vmware-system-self-service-namespace: true
                  vmware-system-vm-folder: group-v174
    Status:       Active
     
     
    Resource Quotas
     Name:             testns-1
     Resource          Used  Hard
     --------          ---   ---
     requests.storage  0     5000Mi
     
     
     Name:                                                                           testns-1-storagequota
     Resource                                                                        Used  Hard
     --------                                                                        ---   ---
     namespace-service-storage-profile.storageclass.storage.k8s.io/requests.storage  0     9223372036854775807
     
     
    No LimitRange resource.