Skip to content

Commit

Permalink
Enable NSX LB healthcheck on kube-apiserver
Browse files Browse the repository at this point in the history
In the VPC network, the vm-operator Pod and Kubernetes
Clusters are in different VPCs. TCP readiness probe does
not work across VPC. Use LB 's healthcheck instead. The
annotation can enable healthcheck if NSX LB is installed.
AVI LB has healthcheck enabled by default.
  • Loading branch information
DanielXiao committed Aug 14, 2024
1 parent 31ee7f1 commit 7888c00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/services/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,10 @@ var _ = Describe("Network provider", func() {
Expect(createdSubnetSet.Spec).To(Equal(initialSubnetSet.Spec), "SubnetSetSpec should not have been modified")
})

It("should successfully retrieve VM service annotations, confirm they are empty", func() {
It("should successfully retrieve VM service annotations, including the annotation to enable LB healthcheck", func() {
annotations, err := np.GetVMServiceAnnotations(ctx, clusterCtx)
Expect(err).ToNot(HaveOccurred())
Expect(annotations).To(Equal(make(map[string]string)))
Expect(annotations).To(HaveKey("virtualmachineservice.vmoperator.vmware.com/service.endpointHealthCheckEnabled"))
})

})
Expand Down
7 changes: 6 additions & 1 deletion pkg/services/network/nsxt_vpc_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ import (
"sigs.k8s.io/cluster-api-provider-vsphere/pkg/services"
)

const (
// AnnotationServiceEndpointHealthCheckEnabledKey is the key of the annotation that is used to enable health check on the VMService endpoint port.
AnnotationServiceEndpointHealthCheckEnabledKey = "virtualmachineservice.vmoperator.vmware.com/service.endpointHealthCheckEnabled"
)

// nsxtVPCNetworkProvider provisions nsx-vpc type cluster network.
type nsxtVPCNetworkProvider struct {
client client.Client
Expand Down Expand Up @@ -168,7 +173,7 @@ func (vp *nsxtVPCNetworkProvider) GetClusterNetworkName(ctx context.Context, clu

// The GetVMServiceAnnotations method always returns an empty map representing annotations.
func (vp *nsxtVPCNetworkProvider) GetVMServiceAnnotations(_ context.Context, _ *vmware.ClusterContext) (map[string]string, error) {
return map[string]string{}, nil
return map[string]string{AnnotationServiceEndpointHealthCheckEnabledKey: ""}, nil
}

// ConfigureVirtualMachine configures a VirtualMachine object based on the networking configuration.
Expand Down

0 comments on commit 7888c00

Please sign in to comment.