Skip to content

jamroks/YaKEL

Repository files navigation

YaKEL: Yet Another Kubernetes Environment Lab

kubernetes

Abstract

YaKEL (Yet Another Kubernetes Environment Lab) is an ansible lightweight playbook for fast installation (in less than 10 minutes) of a kubernetes lab of 3 hosts that can fit on your laptop, which I build for my own experimentation needs. The kubernetes cluster is highly configurable and requires the following prerequisites:

Ansible will be installed in isolation using python virtualenv so as not to disturb your current version of ansible if you already have one on your laptop

The development of Yakel is largely inspired from "Kubernetes The Hard Way" tutorial, by Kelsey Hightower (developer advocate at google) and to a lesser extent tectonic coreos.

At the end of the installation, 5 to 8 minutes depending on your internet connection or the capacity of your laptop, we will get the cluster as described in the diagram below.

YaKEL is made up the following component:

ℹ️
Here is the infos to access to ui and dashboard respectively for traefik and kubernetes
Traefik will be available locally at: traefik.apps.roklab.ops
Kubernetes will be available locally at: dashboard.apps.roklab.ops
schema

Hands-On :

first step, enabled virtualenv & install ansible. To do this, retrieve the sources from this repository as described below.

setupEnv

extrait 1. git clone & source virtualenv
$ git clone "https://github.com/jamroks/YaKEL.git"
$ cd YaKEL
$ source setupenv.sh

The provisioning of the three nodes cluster, consisting of a master and two workers, can be done in one step, for the impatient it is enough to launch the usual vagrant command. * vagrant up *

For the sake of clarity I am going to break down the steps into 3 commands:

  • clusterplan

  • clusterkube

  • clusterapps

ClusterPlan

First step provision the 3 nodes and configure the system centos 7

$ vagrant up --provision-with clusterplan

You may see the message below appearing in the standard out when vagrant is doing its thing or booting up, but no worries, after a few attempt it will connect succesfully !

node02: SSH address: 127.0.0.1:2222
node02: SSH username: vagrant
node02: SSH auth method: private key
node02: Warning: Connection reset. Retrying...
node02: Warning: Remote connection disconnect. Retrying...

ClusterKube

Second step installation of kubernetes. Launch the vagrant command below in order to trigger the execution of the kubernetes installable playbook.

extrait 2. deploy kube
$ vagrant provision --provision-with clusterkube

If all went well you should get the extra files below highlight:

tree -L 1
.
├── Vagrantfile
├── ansible-2.5.4
├── clustervars.yml
├── "*kubectl*"
├── "*kubectl.kubeconfig*"
├── provisioning
├── requirements.txt
└── setupenv.sh

Let’s check that the cluster is operational by typing the following commands

extrait 3. check clusterStatus
$ ./kubectl --kubeconfig kubectl.kubeconfig get cs (1)
  1. Display the cluster status, cs = componentstatuses

💡
Pro tip: exporting the environment variable "KUBECONFIG=kubectl.kubeconfig" in your shell avoids repeating the --kubeconfig argument for each command
ℹ️
Did you know ? kubens is a tool that allows you to switch between different kubernetes namespace without having to re-type long command each time. https://github.com/ahmetb/kubectx
Instead of: $ kubectl --namespace kube-system (for each command)
you will have: $ kubens kube-system (1 time)

you should get this:

NAME                 STATUS    MESSAGE              ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-0               Healthy   {"health": "true"}

By typing the following we should get a response from kubernetes apiserver .check cluster-infos

$ ./kubectl --kubeconfig kubectl.kubeconfig cluster-infos (1)
Kubernetes master is running at https://192.168.32.7:6443
CoreDNS is running at https://192.168.32.7:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

ClusterApps

Third step, installation of kubernetes apps, here traefik (ingress controller) and kubernetes dashboard are the two basic optionnal apps to deploy. By default dashboard will not be installed, only traefik proxy and ui will be installed. You can if you so wish install kubernetes dashboard by editing clustervars.yml and enabling the dashboard like describe below

apps:
    dashboard:
      enabled: true

Now just deploy apps by launching below command

extrait 4. deploy apps
$ vagrant provision --provision-with clusterapps

After about 1 minutes, you can access the kube apps web interface:

  • traefik: traefik.apps.roklab.ops

  • dashboard: dashboard.apps.roklab.ops

dashboard.apps.roklab.ops :

kubernetes dashboard

traefik.apps.roklab.ops :

Treafik admin ui

Oh and by the way Pull Request are welcome ;)

LICENSE

Copyright [René Okouya]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.