DevOps engineers can create self-service namespaces with annotations and labels using the kubectl command line.

DevOps engineers can use a YAML manifest with user-defined annotations and labels.

Procedure

  1. Log in to the Supervisor Cluster.
    kubectl vsphere login --server IP-ADDRESS-SUPERVISOR-CLUSTER --vsphere-username VCENTER-SSO-USERNAME
  2. Create a namespace YAML manifest file with annotations and labels.
    kubectl create -f ns-create.yaml
    For example, create the following ns-create.yaml file:
    apiVersion: v1
    kind: Namespace
    metadata:
      name: test-ns-yaml
      labels:
        my-label: "my-label-val-yaml"
      annotations:
        my-ann-yaml: "my-ann-val-yaml"
  3. Apply the YAML manifest.
    kubectl create -f ns-create.yaml

    Or

    kubectl apply -f ns-create.yaml
  4. Describe the namespace that you created to see the changes.
    root@localhost [ /tmp ]# kubectl describe ns test-ns-yaml
    Name:         test-ns-yaml
    Labels:       my-label=my-label-val-yaml
                  vSphereClusterID=domain-c50
    Annotations:  my-ann-yaml: my-ann-val-yaml
                  vmware-system-namespace-owner-count: 1
                  vmware-system-resource-pool: resgroup-171
                  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-v172
    Status:       Active
     
    Resource Quotas
     Name:             test-ns-yaml
     Resource          Used  Hard
     --------          ---   ---
     requests.storage  0     5000Mi
     
     Name:                                                                           test-ns-yaml-storagequota
     Resource                                                                        Used  Hard
     --------                                                                        ---   ---
     namespace-service-storage-profile.storageclass.storage.k8s.io/requests.storage  0     9223372036854775807
     
    No LimitRange resource.