Skip to content

Latest commit

 

History

History
93 lines (68 loc) · 3.45 KB

vagrant.md

File metadata and controls

93 lines (68 loc) · 3.45 KB

PKE in Vagrant

To try out a single- or multi-node PKE Kubernetes cluster you can also use Vagrant.

Install Vagrant

To install Vagrant on a macOS, complete the following steps:

  1. 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).

  2. Install Vagrant: brew cask install vagrant

  3. Install the vagrant-vbguest plugin vagrant plugin install vagrant-vbguest

  4. Clone the PKE repository. If you do not have git installed, you can also download and unzip it into the pke directory:

    git clone git@github.com:banzaicloud/pke.git
    cd pke
  5. 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].

Single node PKE

  1. Start a machine with the following command: vagrant up centos1

  2. Wait until the node starts.

  3. 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
  4. You can use kubectl from now on. Execute the following command to test it: kubectl get nodes

Multi node PKE

  1. Start a machine with the following command: vagrant up centos1 centos2

  2. Wait until the node starts.

  3. 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
  4. 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
  5. Export the TOKEN and CERTHASH environment variables with the values you have retrieved in the previous step.

  6. 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
  7. Repeat the previous step to add additional worker nodes. You can check the status of the containers by issuing the crictl ps command.