EnablevSphere with Tanzu on a Cluster withNSX-T Data Center as the Networking Stack
vSphere with Tanzu
on a Cluster withNSX-T Data Center
as the Networking StackThrough the
vSphere
Automation
APIs, you can enable a vSphere cluster for managing Kubernetes workloads. A cluster configured withNSX-T Data Center
supports runningvSphere Pod
andTanzu Kubernetes
clusters.- Verify that your environment meets the system requirements for enablingvSphere with Tanzuon the cluster. For more information about the requirements, see the documentation.
- Verify that theNSX-T Data Centeris installed and configured. See Configuring NSX-T Data Center for vSphere with Tanzu.
- Create storage policies for the placement of pod ephemeral disks, container images, andSupervisor Clustercontrol plane cache.
- Verify that DRS is enabled in fully automated mode and HA is also enabled on the cluster.
- Configure shared storage for the cluster. Shared storage is required for vSphere DRS, HA, and storing persistent volumes of containers.
- Verify that the user who you use to access thevSphere Automationservices has theModify cluster-wide configurationprivilege on the cluster.
- Create a subscribed content library on thevCenter Serversystem to accommodate the VM image that is used for creating the nodes of theTanzu Kubernetesclusters.
To enable a vSphere cluster for Kubernetes workload management, you use the services under the
namespace_management
package.- Retrieve the IDs of the tag-based storage policies that you configured forvSphere with Tanzu.Use thePoliciesservice to retrieve a list of all storage policies and then filter the policies to get the IDs of the policies that you configured for theSupervisor Cluster.
- Retrieve the IDs of the vSphere Distributed Switch and theNSX Edgecluster that you created when configuring theNSX-T Data CenterforvSphere with Tanzu.Use theDistributedSwitchCompatibilityservice to list all vSphere Distributed Switches associated with the specific vSphere cluster and then retrieve the ID of the Distributed Switch that you configured to handle overlay networking for theSupervisor Cluster. Use theEdgeClusterCompatibilityservice to retrieve a list of the createdNSX Edgeclusters for the specific vSphere cluster and associated with the specific vSphere Distributed Switch. Retrieve the ID of theNSX Edgecluster that has the tier-0 gateway that you want to use for the namespaces networking.
- Retrieve the ID of the port group for the management network that you configured for the management traffic.Use theNetworksservice to list the visible networks available on thevCenter Serverinstance that match some criteria and then retrieve the ID of the management network you previously configured.
- Create aClustersTypes.EnableSpecinstance anddefinethe parameters of theSupervisor Clusterthat you want to create.You must specify the following required parameters of the enable specification:
- Storage policies settings and file volume support. The storage policy you set for each of the following parameters ensures that the respective object is placed on the datastore referenced in the storage policy. You can use the same or different storage policy for the different inventory objects.ParameterDescriptionsetEphemeralStoragePolicy(java.lang.String ephemeralStoragePolicy)Specify the ID of the storage policy that you created to control the storage placement of thevSphere Pods.setImageStorage(ClustersTypes.ImageStorageSpec imageStorage)Set the specification of the storage policy that you created to control the placement of the cache of container images.setMasterStoragePolicy(java.lang.String masterStoragePolicy)Specify the ID of the storage policy that you created to control the placement of theSupervisor Clustercontrol plane cache.Optionally, you can activate the file volume support by usingsetCnsFileConfig(CNSFileConfig cnsFileConfig). See Enabling ReadWriteMany Support.
- Management network settings. Configure the management traffic settings for theSupervisor Clustercontrol plane.ParameterDescriptionsetNetworkProvider(ClustersTypes.NetworkProvider networkProvider)Specify the networking stack that must be used when theSupervisor Clusteris created. To use theNSX-T Data Centeras the network solution for the cluster, selectNSXT_CONTAINER_PLUGIN.setMasterManagementNetwork(ClustersTypes.NetworkSpec masterManagementNetwork)Enter the cluster network specification for theSupervisor Clustercontrol plane. You must enter values for the following required properties:
- setNetwork(java.lang.String network)- Use the management network ID retrieved in Step 3.
- setMode(ClustersTypes.NetworkSpec.Ipv4Mode mode)- SetSTATICRANGEorDHCPfor the IPv4 address assignment mode. TheDHCPmode allows an IPv4 address to be automatically assigned to theSupervisor Clustercontrol plane by a DHCP server. You must also set the floating IP address used by the HA primary cluster by usingsetFloatingIP(java.lang.String floatingIP). Use the DHCP mode only for test purposes. TheSTATICRANGEmode, allows theSupervisor Clustercontrol plane to have a stable IPv4 address. You can use it in a production environment.
- setAddressRange(ClustersTypes.Ipv4Range addressRange)- Optionally, you can configure the IPv4 addresses range for one or more interfaces of the management network. Specify the following settings:
- The starting IP address that must be used for reserving consecutive IP addresses for theSupervisor Clustercontrol plane. Use up to 5 consecutive IP addresses.
- The number of IP addresses in the range.
- The IP address of the gateway associated with the specified range.
- The subnet mask to be used for the management network.
setMasterDNS(java.util.List<java.lang.String> masterDNS)Enter a list of the DNS server addresses that must be used from theSupervisor Clustercontrol plane. If yourvCenter Serverinstance is registered with an FQDN, you must enter the IP addresses of the DNS servers that you use with the vSphere environment so that the FQDN is resolvable in theSupervisor Cluster. The list of DNS addresses must be specified in the order of preference.setMasterDNSSearchDomains(java.util.List<java.lang.String> masterDNSSearchDomains)Set a list of domain names that DNS searches when looking up for a host name in the Kubernetes API server. Order the domains in the list by preference.setMasterNTPServers(java.util.List<java.lang.String> masterNTPServers)Specify a list of IP addresses or DNS names of the NTP server that you use in your environment, if any. Make sure that you configure the same NTP servers for thevCenter Serverinstance, all hosts in the cluster, theNSX-T Data Center, andvSphere with Tanzu. If you do not set an NTP server, VMware Tools time synchronization is enabled. - Workload network settings. Configure the settings for the networks for the namespaces. The namespace network settings provide connectivity tovSphere Pods and namespaces created in theSupervisor Cluster.ParameterDescriptionsetNcpClusterNetworkSpec(ClustersTypes.NCPClusterNetworkEnableSpec ncpClusterNetworkSpec)Set the specification for theSupervisor Clusterconfigured with theNSX-T Data Centernetworking stack. Specify the following cluster networking configuration parameters forNCPClusterNetworkEnableSpec:
- setClusterDistributedSwitch(java.lang.String clusterDistributedSwitch)- The vSphere Distributed Switch that handles overlay networking for theSupervisor Cluster.
- setNsxEdgeCluster(java.lang.String nsxEdgeCluster)- TheNSX Edgecluster that has tier-0 gateway that you want to use for namespace networking.
- setNsxTier0Gateway(java.lang.String nsxTier0Gateway)- The tier-0 gateway that is associated with the cluster tier-1gateway. You can retrieve a list ofNSXTier0Gatewayobjects associated with a particular vSphere Distributed Switch and determine the ID of the tier-0 gateway you want to set.
- setNamespaceSubnetPrefix(java.lang.Long namespaceSubnetPrefix)- The subnet prefix that defines the size of the subnet reserved for namespaces segments. Default is 28.
- setRoutedMode(java.lang.Boolean routedMode)- The NAT mode of the workload network. If set tofalse:
- The IP addresses of the workloads are directly accessible from outside the tier-o gateway and you do not need to configure the egress CIDRs.
- File Volume storage is not supported.
true. - setEgressCidrs(java.util.List<Ipv4Cidr> egressCidrs)- The external CIDR blocks from which the NSX Manager assigns IP addresses used for performing source NAT (SNAT) from internalvSphere Pods IP addresses to external IP addresses. Only one egress IP address is assigned for each namespace in theSupervisor Cluster. These IP ranges must not overlap with the IP ranges of thevSphere Pods, ingress, Kubernetes services, or other services running in the data center.
- setIngressCidrs(java.util.List<Ipv4Cidr> ingressCidrs)- The external CIDR blocks from which the ingress IP range for the Kubernetes services is determined. These IP ranges are used for load balancer services and Kubernetes ingress. All Kubernetes ingress services in the same namespace share a common IP address. Each load balancer service is assigned a unique IP address. The ingress IP ranges must not overlap with the IP ranges of thevSphere Pods, egress, Kubernetes services, or other services running in the data center.
- setPodCidrs(java.util.List<Ipv4Cidr> podCidrs)- The internal CIDR blocks from which the IP ranges forvSphere Pods are determined. The IP ranges must not overlap with the IP ranges of the ingress, egress, Kubernetes services, or other services running in the data center. AllvSphere Pods CIDR blocks must be of at least /23 subnet size.
setWorkerDNS(java.util.List<java.lang.String> workerDNS)Set a list of the IP addresses of the DNS servers that must be used on the worker nodes. Use different DNS servers than the ones you set for theSupervisor Clustercontrol plane.setServiceCidr(Ipv4Cidr serviceCidr)Specify the CIDR block from which the IP addresses for Kubernetes services are allocated. The IP range must not overlap with the ranges of thevSphere Pods, ingress, egress, or other services running in the data center.For the Kubernetes services and thevSphere Pods, you can use the default values which are based on the cluster size that you specify. - Supervisor Clustersize. You must set a size to theSupervisor Clusterwhich affects the resources allocated to the Kubernetes infrastructure. The cluster size also determines default maximum values for the IP addresses ranges for thevSphere Pods and Kubernetes services running in the cluster. You can use theClusterSizeInfo.get()calls to retrieve information about the default values associated with each cluster size.
- Optional. Associate theSupervisor Clusterwith the subscribed content library that you created for provisioningTanzu Kubernetesclusters. See Creating, Securing, and Synchronizing Content Libraries for Tanzu Kubernetes Releases.To set the library, use thesetDefaultKubernetesServiceContentLibrary(java.lang.String defaultKubernetesServiceContentLibrary)method and pass the subscribed content library ID.
- EnablevSphere with Tanzuon a specific cluster by passing the cluster enable specification to theClustersservice.
A task runs on
vCenter Server
for turning the cluster into aSupervisor Cluster
. Once the task completes, Kubernetes control plane nodes are created on the hosts that are part of the cluster enabled withvSphere with Tanzu
. Now you can createvSphere Namespace
s.Create and configure namespaces on the
Supervisor Cluster
. See Create a vSphere Namespace.- Java
- This example enablesvSphere with Tanzuon a cluster that has NSX-T configured as the networking stack.The following code snippet is part of theEnableSupervisorCluster.javasample. Some parts of the original code sample are omitted to save space. You can view the complete and up-to-date version of this sample in thevsphere-automation-sdk-javaVMware repository at GitHub.(...) @Override protected void run() throws Exception { System.out.println("We are building the Spec for enabling vSphere supervisor cluster"); ClustersTypes.EnableSpec spec = new ClustersTypes.EnableSpec(); (...) spec.setSizeHint(SizingHint.TINY); (...) spec.setServiceCidr(serCidr); spec.setNetworkProvider(ClustersTypes.NetworkProvider.NSXT_CONTAINER_PLUGIN); (...) spec.setNcpClusterNetworkSpec(NCPSpec); (...) spec.setMasterManagementNetwork(masterNet); (...) spec.setMasterDNS(masterDNS); (...) spec.setWorkerDNS(workerDNS); (...) spec.setMasterNTPServers(NTPserver); spec.setMasterStoragePolicy(this.storagePolicyId); // Storage policy identifier spec.setEphemeralStoragePolicy(this.storagePolicyId);// Storage policy identifier spec.setLoginBanner("This is your first Project pacific cluster"); (...) spec.setImageStorage(imageSpec); this.ppClusterService.enable(clusterId, spec); System.out.println("Invocation is successful for enabling vSphere supervisor cluster, check H5C"); } (...)