NKP Post 1: Preparing the setup environment
Before we kick off this series, I would like to extend a big thank you to Winson Sou at Nutanix for his excellent video series on this topic on YouTube. You can find his channel here:
This is the first post in the series on how to deploy the Nutanix Kubernetes Platform (NKP) in your Nutanix environment.
The first step is to prepare the installation environment. You'll need to fulfill these prerequisites to set up NKP:
- A bastion/jump host to perform the installation and administration from
- I chose to deploy a Rocky Linux VM in my Nutanix environment. - Container Engine of your choice:
- Podman version 4 or later
- Docker Container Engine version 18, version 20 or later - Kubectl installed in your installation environment
- SSH keys on your installation environment
Som toughts on the prerequiesites
When you set up NKP, the installer creates a bootstrap cluster in your Container Engine. This "bootstrap cluster" is then used to provision the NKP cluster in your Nutanix environment. I highly recommend setting up a bastion host for this, mainly to avoid bloating your local workstation and for security reasons.
Additionally, for easier management of your NKP cluster, I highly recommend setting up these tools in your environment as well:
- K9s for TUI-based management of your Kubernetes resources
- Proxy registry cache using Harbor (covered in Post 2 of this series)
- Bash completion enabled for kubectl
Setting up my bastion host
So, let's get this party started.
First, I set up a Rocky Linux bastion host in our Nutanix Test Environment. Below you'll find the link to the Rocky Linux Download page. Visit the page and copy the download link of the Boot ISO.
After you have copied the link to the Boot ISO, log in to your Prism Central environment. Under the Infrastructure tab, go to "Compute and Storage" -> "Images."
Click "Add Image" and choose URL -> paste your link and click "+ Add URL" -> Click "Next."
Place the images on the clusters of your choice.
Now head back to the menu and go to "Compute and Storage" and click "VMs" -> "New VM."
Follow the instructions on the screen to enter the specifics for your Bastion/Jump VM:
Add your newly created Rocky Linux Boot ISO.
Note: Add a good amount of disk space to your bastion, since we will be downloading some pretty bulky bundles, etc., on the jump host. I chose to add 300 GB of disk space to the bastion.
Create the VM and power it on.
Launch the console and follow the on-screen instructions.
After you have configured everything to your liking, click "Begin Installation".
Note: In my lab environment, I have DHCP. This is an online installer that requires network access for the installation. If you are installing in an environment that does not have internet access, you'll need to download the offline installer ISO from Rocky, which is quite large (over 10GB).
Install tools on your jump/bastion host
Now that we have our jump host installed and ready for action, I connect to it via SSH and configure the various tools we need to deploy the NKP management cluster.
First, we install Docker Container Engine by following the instructions in this link.
Run the following commands
# Add the Repo
sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
# Install using dnf
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Enable docker
sudo systemctl --now enable docker
# Add the current user
sudo usermod -a -G docker $(whoami)
# Add a specific user
sudo usermod -a -G docker custom-user
Now we have Docker installed. Try out the command below:
docker ps
It should give an output like this:
[administrator@joho-nkp-jumphost ~]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
Next, we need to install various tools to handle the NKP installation, like kubectl and K9s (optional, but recommended). Luckily, Winson Sou has made a script for us to use to install all these tools.
#Install Bash Completion if not already installed
dnf install -y bash-completion
#Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
rm -f kubectl
#Configure kubectl bash completion
source <(kubectl completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
echo "alias k=kubectl" >> ~/.bashrc
echo "complete -o default -F __start_kubectl k" >> ~/.bashrc
#Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
source <(helm completion bash) # set up autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(helm completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
#Install K9s
wget https://github.com/derailed/k9s/releases/latest/download/k9s_Linux_amd64.tar.gz
tar zxvf k9s_Linux_amd64.tar.gz
mv k9s /usr/local/bin
rm -f k9s_Linux_amd64.tar.gz
This script installs kubectl, configures kubectl bash completion, Helm, Helm bash completion, and K9s.
Install the NKP CLI tool: Go to the Nutanix support portal. Navigate to Downloads -> Nutanix Kubernetes Platform (NKP) and find the package called NKP for Linux.
Click the three dots to the right of the Download button and click "Copy Download Link." Then run this command on your bastion host (remember to put "" around the download URL):
curl -Lo nkp_v2.12.1_linux_amd64.tar.gz "<COPIED_URL_FROM_SUPPORT_PORTAL>"
Now, let's untar the NKP binaries and move them to our /usr/local/bin/ folder:
# Untar
tar -zvxf nkp_v2.12.1_linux_amd64.tar.gz
# Move file to bin folder
sudo mv nkp /usr/local/bin/
Now you should be able to run the following command:
nkp version
It should provide this output:
[administrator@joho-nkp-jumphost ~]$ nkp version
diagnose: v0.10.1
imagebuilder: v0.13.3
kommander: v2.12.1
konvoy: v2.12.1
mindthegap: v1.13.1
nkp: v2.12.1
Now we're almost done with our installation environment, but we need to do one more thing: upload the OS image for the Kubernetes nodes to our Prism Central environment.
Go back to the Nutanix support portal. Locate the package named "NKP Node OS Image (Rocky Linux) for AHV" and click the three dots to the right of the Download button. Copy the download link provided.
Head into Prism Central -> Compute & Storage -> Images -> Click "Add Image." Choose URL -> paste the URL and click "Add URL."
Click "Next" and choose your clusters -> click "Save."
Now you should have an image with a name similar to this in your image repository in Prism Central:
Lastly we need to generate some SSH keys by running the following command.
ssh-keygen
You should now have som files in the /home/<user>/.ssh/ witch contains your ssh key files:
[joho-nkp-jumphost ~]$ ll /home/administrator/.ssh/
total 8
-rw-------. 1 administrator administrator 2622 Nov 1 11:36 id_rsa
-rw-r--r--. 1 administrator administrator 585 Nov 1 11:36 id_rsa.pub
And that's all for this post, folks. Now we are ready to start deploying our first NKP management cluster onto our Nutanix platform. But before we go ahead and deploy our first cluster, it's highly recommended to have a local registry cache for all your container images. This is because of Docker Hub's pull rate limit, but that's covered in my next post.
Thanks for reading.