Create an L7 ingress resource to trigger the creation of an L7 Virtual Server. When you rotate the certificate using the following steps, NCP replaces the existing/old certificate.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
annotations:
kubernetes.io/ingress.class: "nsx"
spec:
tls:
- hosts:
- test.example.com
secretName: test-secret
rules:
- host: test.example.com
http:
paths:
- path: /tmp
pathType: ImplementationSpecific
backend:
service:
name: test-svc
port:
number: 80 Run the following command once the file ingress.yaml is populated with the preceding content: kubectl apply -f ingress.yaml
Confirm ingress creation: kubectl get ingress -A
Confirm that the L7 HTTP Virtual Server exists on NSX Manager. Navigate to Networking > Load Balancing > Virtual Servers and filter for Type: L7 HTTP.
Generate CSR from vCenter vSphere Client under Cluster -> Configure -> Supervisor Cluster -> Certificates -> NSX Load Balancer Pane -> Actions > Generate CSR
Provide the details for the certificate. Once the CSR is generated, click Copy.
Copy CSR to the vCenter in order to get it signed by VMCA. (you can get the CSR signed by your own CA if you are using custom CA)
Login to the vCenter through SSH using the root
Type shell and press Enter.
Generate the certificate using the above CSR: /usr/lib/vmware-vmca/bin/certool --gencertfromcsr --csrfile cert.csr --cert lb-renew.crt
Copy the content of lb-renew.crt and replace it under Actions > Replace Certificate.
Check NSX Manager -> System -> Certificates. The new certificate should be visible.
Note: If you have not created Ingress initially or not followed Create Ingress steps and directly tried to REPLACE CERT, then there would be two certificates on NSX manager. Follow the steps in "Additional information" to delete the old certificate
Confirm the new certificate is imported. NSX Manager automatically removes the old certificate under System > Certificates.
Delete the ingress created in Step 1 with command: kubectl delete -f ingress.yaml
Note: This does not require an NCP restart.
Note: You cannot access the L7 ingress resources deployed across the clusters (Supervisor and TKGs) during this process because NSX uses this certificate as the default certificate for HTTPS traffic for L7 Ingress.
To delete the old certificate if it is still present (as per Step 6):
In NSX manager, copy the old certificate ID with the name lb-domain-#### issued to defaultingress.local under System > Certificates. Alternatively, fetch this using the following command: GET /policy/api/v1/infra/certificates/
Compare pem_encoded or _create_time in the returned JSON.
Use the following API call to remove the expiring certificate: curl -k -u 'admin:<NSX_admin_Password>' -X DELETE https://<NSX_Manager>/policy/api/v1/infra/certificates/<Certificate_ID> -H "X-Allow-Overwrite:true"
NSX performs a dependency check and blocks deletion if the certificate is in use.
Restart the NCP pod. Restart the NCP pod by either touching the NCP deployment or deleting the NCP pod. This is required to sync the NCP certificate cache and prevents the stale certificate from being referenced in future L7 VirtualServer creation calls.