An open API service indexing awesome lists of open source software.

https://github.com/flavio/salt-kubernetes-demo

Demo of kubernetes-salt integration
https://github.com/flavio/salt-kubernetes-demo

kubernetes salt saltstack

Last synced: 5 months ago
JSON representation

Demo of kubernetes-salt integration

Awesome Lists containing this project

README

          

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](https://filr.attachmategroup.com/ssf/s/readFile/share/88236/4263111497095896051/publicLink/kubernetes-101.qcow2.xz).
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](https://github.com/kubernetes-incubator/client-python)
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](https://github.com/flavio/salt/tree/kubernetes-modules)

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:

[![asciicast](https://asciinema.org/a/103881.png)](https://asciinema.org/a/103881)

or to remove them:

[![asciicast](https://asciinema.org/a/103881.png)](https://asciinema.org/a/103881)

### Managing deployments and services

It's also possible to deploy the complete [guestbook 101 application](https://github.com/kubernetes/kubernetes/tree/master/examples/guestbook) using salt:

Deploying the full stack:

[![asciicast](https://asciinema.org/a/103883.png)](https://asciinema.org/a/103883)

Removing the entire stack:

[![asciicast](https://asciinema.org/a/103884.png)](https://asciinema.org/a/103884)