2021-09-02

When you deploy your Tanzu Kubernetes cluster TKC, you possibly want to use your own container registry. Your own container registry may use your enterprise CA signed certificate. By default, all TKC nodes trust all public CA signed certificates. To ensure your enterprise CA signed certificate is trusted by TKC, you need to update TKG Service Configurations to include your enterprise CA. In this blog, I will show you how to do it.

Step 1: Connect to the supervisor context

root@photon-machine [ ~ ]# k config use-context k8s.cluster-1.vcenter.sddc-10-180-30-145.vmwarevmc.com
Switched to context "k8s.cluster-1.vcenter.sddc-10-180-30-145.vmwarevmc.com".

Step 2: Verify the current setting of tkgserviceconfigurations

root@photon-machine [ ~ ]# kubectl get tkgserviceconfigurations
NAME                        DEFAULT CNI
tkg-service-configuration   antrea
root@photon-machine [ ~ ]# kubectl get tkgserviceconfigurations tkg-service-configuration -o yaml
apiVersion: run.tanzu.vmware.com/v1alpha1
kind: TkgServiceConfiguration
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"run.tanzu.vmware.com/v1alpha1","kind":"TkgServiceConfiguration","metadata":{"annotations":{},"name":"tkg-service-configuration"},"spec":{"defaultCNI":"antrea"}}
  creationTimestamp: "2021-08-29T08:38:10Z"
  generation: 2
  managedFields:
  - apiVersion: run.tanzu.vmware.com/v1alpha1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
      f:spec:
        .: {}
        f:defaultCNI: {}
    manager: kubectl-client-side-apply
    operation: Update
    time: "2021-08-29T08:38:10Z"
  - apiVersion: run.tanzu.vmware.com/v1alpha1
    fieldsType: FieldsV1
    fieldsV1:
      f:spec:
        f:trust:
          .: {}
          f:additionalTrustedCAs: {}
    manager: kubectl-edit
    operation: Update
    time: "2021-09-02T00:23:37Z"
  name: tkg-service-configuration
  resourceVersion: "2938228"
  selfLink: /apis/run.tanzu.vmware.com/v1alpha1/tkgserviceconfigurations/tkg-service-configuration
  uid: 4466e3c2-ccb1-4a36-b12a-256344ee1c4a
spec:
  defaultCNI: antrea

Step 3: Edit the tkg-service-configuration to trust additional certificate

Please note that the certificate should be include as base64-encoded string.

kubectl edit tkgserviceconfigurations tkg-service-configuration
root@photon-machine [ ~ ]# kubectl get tkgserviceconfigurations tkg-service-configuration -o yaml
apiVersion: run.tanzu.vmware.com/v1alpha1
kind: TkgServiceConfiguration
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"run.tanzu.vmware.com/v1alpha1","kind":"TkgServiceConfiguration","metadata":{"annotations":{},"name":"tkg-service-configuration"},"spec":{"defaultCNI":"antrea"}}
  creationTimestamp: "2021-08-29T08:38:10Z"
  generation: 2
  managedFields:
  - apiVersion: run.tanzu.vmware.com/v1alpha1
    fieldsType: FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .: {}
          f:kubectl.kubernetes.io/last-applied-configuration: {}
      f:spec:
        .: {}
        f:defaultCNI: {}
    manager: kubectl-client-side-apply
    operation: Update
    time: "2021-08-29T08:38:10Z"
  - apiVersion: run.tanzu.vmware.com/v1alpha1
    fieldsType: FieldsV1
    fieldsV1:
      f:spec:
        f:trust:
          .: {}
          f:additionalTrustedCAs: {}
    manager: kubectl-edit
    operation: Update
    time: "2021-09-02T00:23:37Z"
  name: tkg-service-configuration
  resourceVersion: "2938228"
  selfLink: /apis/run.tanzu.vmware.com/v1alpha1/tkgserviceconfigurations/tkg-service-configuration
  uid: 4466e3c2-ccb1-4a36-b12a-256344ee1c4a
spec:
  defaultCNI: antrea
  trust:
    additionalTrustedCAs:
    - data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tDQpNSUlGMHpDQ0E3dWdBd0lCQWdJVUtCSjZGZ0VKaEpwR0lpOEtMYkNDRW5FNG9lb3dEUVlKS29aSWh2Y05BUUVODQpCUUF3ZVRFTE1Ba0dBMVVFQmhNQ1EwNHhFREFPQmdOVkJBZ01CMEpsYVdwcGJtY3hFREFPQmdOVkJBY01CMEpsDQphV3BwYm1jeEVEQU9CZ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VRtYU1xM2xPb2daQWlYMFRjbmw3WDVsbG1MZXZleGExVG5KazEwdTdJR2Z4ZlhCTXA1DQoxc1BkMGNwQmxmQ1ZOR0V0MDFhdVBLK055Y2pLcUcvR0xqeVJLc1F5TGsxMDFBY3VrUElQU20zTFM4VXdpaGo4DQpPRHh5K2FOaVE1V3dGdlp4blFrRnluN014QThaSTU1N0pFalRIU0pFK3RKUDFzRERTN3lNWExFSUk1UW5ZOFhkDQpKRU5Vd2VIR2VDUHRGNFlZYlROTk1jc01COTFQbEd0Rm5YZkRuYnd4ZGJocjgxZ29kRDNkakhQNjRnNGt5bGlRDQpvM0dGUnV0eEpSSzBRZWZwRXRBcUJGZENEMTY3YmZpZFJRanNSdWxLaU5rSlJQTTZMR2QwSURXSGxBQVc3aE9RDQpQK3BQZ1FzbCtBPT0NCi0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
      name: harbor-ca

When you create a new cluster, your own certificate CA will be trusted automatically on all your k8s nodes.

Reference:

Configuration Parameters for the Tanzu Kubernetes Grid Service