salt-kubernetes-demo

Demo of kubernetes-salt integration

APACHE-2.0 License

Stars
9

This is a demo playground of the salt-kubernetes module.

Requirements

Getting the Kubernetes up and running

Download k8s all-in-one libvirt machine from here. This is a openSUSE VM that has all the kubernetes bits and pieces already configured.

Right now it's not possible to use minikube images because they don't have python installed. I'm currently working on a minikube image based on openSUSE that has all the required pieces.

Once you download the image extract it to a storage location known by your libvirtd daemon and edit the kubernetes.xml file shipped inside of this repo by putting the location of the VM into the FIXME field.

Then execute the following command:

sudo virsh define kubernetes.xml
sudo virsh start kubernetes

The VMs credentials are:

  • username root: password linux
  • username geeko: password linux

Install Kubernetes python client

The Kubernetes salt module relies on the official python client to be installed inside of the VM.

You can do that by ssh-ing into the machine and then doing:

sudo zypper in python-pip
sudo pip install kubernetes

Checkout the kubernetes module (optional)

Right now the code defining the kubernetes modules lives inside of this public repository

For convenience reasons this repository has a copy of the kubernetes module and state files. These files are going to be out of sync with the contents of the original PR.

You can clone the repository holding the official source code of the kubernetes module and then replace the following files with hard links:

  • srv/salt/_modules/kubernetes.py
  • srv/salt/_states/kubernetes.py

Configure salt-ssh

Make sure salt-ssh is installed on your host.

Once the VM is up and running you can obtain its IP address by doing:

sudo virsh domifaddr kubernetes

Then edit the etc/salt/roster file shipped inside of this repo and put the right IP address of the kubernetes VM inside of it.

Now you can test everything is working properly by doing:

$ salt-ssh 'kubernetes' kubernetes.ping
kubernetes:
    True

Playing with Kubernetes

Managing deployments

This salt module can be used to create kubernetes deployments:

or to remove them:

Managing deployments and services

It's also possible to deploy the complete guestbook 101 application using salt:

Deploying the full stack:

Removing the entire stack:

Badges
Extracted from project README
asciicast asciicast asciicast asciicast
Related Projects