To try out a single- or multi-node PKE Kubernetes cluster you can also use Vagrant.
To install Vagrant on a macOS, complete the following steps:
-
Install VirtualBox:
brew cask install virtualbox
You may need to download VirtualBox 6.0 manually, because VirtualBox 6.1 support of Vagrant is not yet released (as of early 2020).
-
Install Vagrant:
brew cask install vagrant
-
Install the vagrant-vbguest plugin
vagrant plugin install vagrant-vbguest
-
Clone the PKE repository. If you do not have git installed, you can also download and unzip it into the pke directory:
git clone [email protected]:banzaicloud/pke.git cd pke
-
Decide whether you want to install a single-node or a multi-node cluster.
- To start a single-node cluster, proceed to (Single node PKE)[#single-node-pke].
- To start a multi-node cluster, proceed to (Multi node PKE)[#single-node-pke].
-
Start a machine with the following command:
vagrant up centos1
-
Wait until the node starts.
-
Issue the following commands:
vagrant ssh centos1 -c 'sudo -s' curl -vL https://github.com/banzaicloud/pke/releases/download/0.9.0/pke-0.9.0 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ pke install single mkdir -p $HOME/.kube cp -i /etc/kubernetes/admin.conf $HOME/.kube/config chown $(id -u):$(id -g) $HOME/.kube/config
-
You can use
kubectl
from now on. Execute the following command to test it:kubectl get nodes
-
Start a machine with the following command:
vagrant up centos1 centos2
-
Wait until the node starts.
-
Issue the following commands to start the master node:
vagrant ssh centos1 -c 'sudo -s' curl -vL https://github.com/banzaicloud/pke/releases/download/0.9.0/pke-0.9.0 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ pke install master --kubernetes-advertise-address=192.168.64.11 --kubernetes-api-server=192.168.64.11:6443 mkdir -p $HOME/.kube cp -i /etc/kubernetes/admin.conf $HOME/.kube/config chown $(id -u):$(id -g) $HOME/.kube/config
-
Get the token and certhash from the logs, or issue the following PKE command to print the token and cert hash needed by workers to join the cluster.
pke token list # Print token and cert hash needed by workers to join the cluster
Note: If the tokens have expired or you'd like to create a new one, issue:
pke token create
-
Export the TOKEN and CERTHASH environment variables with the values you have retrieved in the previous step.
-
Start a worker node using the following commands:
vagrant ssh centos2 sudo -s curl -vL https://github.com/banzaicloud/pke/releases/download/0.9.0/pke-0.9.0 -o /usr/local/bin/pke chmod +x /usr/local/bin/pke export PATH=$PATH:/usr/local/bin/ # copy values from centos1 export TOKEN="" export CERTHASH="" pke install worker --kubernetes-node-token $TOKEN --kubernetes-api-server-ca-cert-hash $CERTHASH --kubernetes-api-server 192.168.64.11:6443
-
Repeat the previous step to add additional worker nodes. You can check the status of the containers by issuing the
crictl ps
command.