Deploy a Kubernetes Cluster to Host the PCG
This section describes one possible method for creating a Kubernetes cluster that will be used to deploy your PCG following the process described in the Nutanix Getting Started resource and the Common Prerequisites specified in the guide.
Prerequisites
-
A Nutanix Prism Central account with Prism Admin role.
-
A Nutanix Prism Element cluster created.
-
A Nutanix subnet created in Nutanix Prism Central that will be assigned to the virtual machines (VMs) deployed in the Kubernetes cluster.
-
A Nutanix Cluster API (CAPI) OS image. For guidance on creating the image, refer to Building CAPI Images for Nutanix Cloud Platform.
-
The following software installed on the machine that will be used to create the clusters:
Create Bootstrap Cluster
-
Log in to your Nutanix Prism account.
-
Create a local kind cluster. This cluster will bootstrap Cluster API and provision the target workload cluster in the Nutanix account. The workload cluster is then used to deploy the PCG.
kind create cluster --name pcg-pilot
Deploy Workload Cluster
-
Copy the required variables shown in the examples below to your terminal, add your environment-specific information, and export the variables. The table describes the environment variables. For more information, review the Nutanix Getting Started guide.
Variable Description NUTANIX_ENDPOINT
The Prism Central IP address or FQDN. NUTANIX_USER
The Prism Central user name. NUTANIX_PASSWORD
The Prism Central user password. NUTANIX_INSECURE
The SSL behavior you used in the cloudClusterTemplate.yaml
file. The default behavior isfalse
.NUTANIX_SSH_AUTHORIZED_KEY
Provide your public SSH key. NUTANIX_PRISM_ELEMENT_CLUSTER_NAME
The Nutanix Prism Element cluster name. NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME
The Nutanix CAPI OS Image NUTANIX_SUBNET_NAME
The subnet of the Nutanix workload cluster. KUBERNETES_VERSION
The Kubernetes version the workload cluster uses. Precede the version with v
.WORKER_MACHINE_COUNT
The number of nodes in the workload cluster. Copy the following Nutanix environment variables to your terminal, provide values, and export the variables.
export NUTANIX_ENDPOINT=""
export NUTANIX_USER=""
export NUTANIX_PASSWORD=""
export NUTANIX_INSECURE=false
export NUTANIX_SSH_AUTHORIZED_KEY=""
export NUTANIX_PRISM_ELEMENT_CLUSTER_NAME=""
export NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME=""
export NUTANIX_SUBNET_NAME=""
You can ensure the Nutanix variables were successfully exported by issuing the following command in your terminal.
env | grep "NUTANIX"
Copy the following environment variables to your terminal, provide values, and export the variables.
export KUBERNETES_VERSION="v1.22.9"
export WORKER_MACHINE_COUNT=1
To verify the KUBERNETES_VERSION and WORKER_MACHINE_COUNT variables were successfully exported, you can issue the following command for each variable.
echo $variable_name
-
Instantiate Nutanix Cluster API.
clusterctl init --infrastructure nutanix
-
Deploy a workload cluster in Nutanix by issuing the following command. Replace
mytestcluster
with the cluster name that you assigned to your workload cluster andmytestnamespace
and with your namespace name. Provide the Nutanix Prism Central IP address for CONTROL_PLANE_ENDPOINT_IP.export TEST_CLUSTER_NAME=mytestcluster
export TEST_NAMESPACE=mytestnamespace
CONTROL_PLANE_ENDPOINT_IP=x.x.x.x clusterctl generate cluster ${TEST_CLUSTER_NAME} \
-i nutanix \
--target-namespace ${TEST_NAMESPACE} \
> ./cluster.yaml
kubectl create namespace ${TEST_NAMESPACE}
kubectl apply --filename ./cluster.yaml --namespace ${TEST_NAMESPACE}The snippet below displays the output of the command.
namespace/mytestnamespace created
configmap/user-ca-bundle created
secret/mytestcluster created
kubeadmconfigtemplate.bootstrap.cluster.x-k8s.io/mytestcluster-kcfg-0 created
cluster.cluster.x-k8s.io/mytestcluster created
machinedeployment.cluster.x-k8s.io/mytestcluster-wmd created
machinehealthcheck.cluster.x-k8s.io/mytestcluster-mhc created
kubeadmcontrolplane.controlplane.cluster.x-k8s.io/mytestcluster-kcp created
nutanixcluster.infrastructure.cluster.x-k8s.io/mytestcluster created
nutanixmachinetemplate.infrastructure.cluster.x-k8s.io/mytestcluster-mt-0 created
Install CNI on Workload Cluster
-
After your Nutanix workload cluster is deployed, retrieve its kubeconfig file with the command described below.
clusterctl get kubeconfig $TEST_CLUSTER_NAME > $TEST_CLUSTER_NAME.kubeconfig --namespace $TEST_NAMESPACE
-
Deploy a Container Network Interface (CNI) pod in the workload cluster to enable pod-to-pod communication. For more information, refer to Deploy a CNI solution in the Nutanix Quick Start reference. Calico is used as the CNI solution in this example.
kubectl apply --filename https://raw.githubusercontent.com/projectcalico/calico/v3.26.1/manifests/calico.yaml
-
To verify that the CNI was deployed successfully, issue the following command.
kubectl --kubeconfig=./$TEST_CLUSTER_NAME.kubeconfig get nodes
The output should display your nodes with a Ready status.
NAME STATUS ROLES AGE VERSION
test-cluster-kcp-qhb5h Ready control-plane 26h v1.26.7
test-cluster-wmd-gdjps-gx267 Ready <none> 26h v1.26.7
Validate
Use the steps below to verify your virtual machines (VMs) are created.
-
In the Nutanix Prism Element web console, navigate to VM.
-
Next, in the Table tab, verify the VMs you created are listed.
Cleanup
Once you have successfully installed a Nutanix PCG in Palette, delete the kind cluster you used to bootstrap the workload cluster.
kind delete cluster --name pcg-pilot