• This repository has been archived on 15/Mar/2019
  • Stars
    star
    263
  • Rank 149,973 (Top 4 %)
  • Language
    Go
  • License
    Other
  • Created about 8 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kansible lets you orchestrate operating system processes on Windows or any Unix in the same way as you orchestrate your Docker containers with Kubernetes by using Ansible to provision the software onto hosts and Kubernetes to orchestate the processes

Kansible

Kansible lets you orchestrate operating system processes on Windows or any Unix in the same way as you orchestrate your Docker containers with Kubernetes by using Ansible to provision the software onto hosts and Kubernetes to orchestrate the processes and the containers in a single system.

kansible logo

Kansible uses:

  • Ansible to install, configure and provision your software onto machines using playbooks
  • Kubernetes to run and manage the processes and perform service discovery, scaling, load balancing together with centralised logging, metrics, alerts and management.

Kansible provides a single pane of glass, CLI and REST API to all your processes whether they are inside docker containers or running as vanilla processes on Windows, AIX, Solaris or HP-UX or an old Linux distros that predate docker.

Kansible lets you migrate to a pure container based Docker world at whatever pace suits you, while using Kubernetes to orchestrate all your containers and operating system processes for your entire journey.

Features

  • All your processes appear as Pods inside Kubernetes namespaces so you can visualise, query and watch the status of your processes and containers in a canonical way
  • Each kind of process has its own Replication Controller to ensure processes keep running and so you can manually or automatically scale the number of processes up or down; up to the limit in the number of hosts in your Ansible inventory
  • Reuse Kubernetes liveness checks so that Kubernetes can monitor the state of your process and restart if it goes bad
  • Reuse Kubernetes readiness checks so that Kubernetes can know when your process can be included into the internal or external service load balancer
  • You can view the logs of all your processes in the canonical kubernetes way via the CLI, REST API or web console
  • Port forwarding works from the pods to the remote processes so that you can reuse Kubernetes Services to load balance across your processes automatically
  • Centralised logging and metrics and alerting works equally across your containers and processes
  • You can open a shell into the remote process machine via the CLI, REST API or web console; which is either a unix bash or a windows cmd shell as shown in the fabric8 console screenshot below:

kansible logo

Ansible perspective on Kansible

If you already use Ansible; then one way to think about Kansible is that you continue to use Ansible however you have been doing; using reusable composable playbooks and so forth. The only change to your playbooks that Kansible introduces is that you don't run Unix or Windows services (e.g. like systemd / init.d). You install and configure the software via Ansible playbooks; setting up whatever directories, users and permissions you require. But you don't create services or run the software.

Then we use Kubernetes (and kansible pods) as the alternative to Unix and Windows services. The reason we do this is that Kubernetes is a better distributed version of systemd/init.d/Windows services as it also includes features like:

  • service discovery and load balancing
  • health monitoring
  • centralised logging, metrics and alerts
  • manual and automatic scaling up or down
  • a consistent web console, CLI and REST API across processes running via kansible and Docker containers

Kubernetes perspective on Kansible

If you already use Kubernetes then you could look at Kansible as a way of extending the reach of Kubernetes to manage both Docker containers on a host that supports Docker plus remote processes on operating systems that don't support Docker. That then makes Kubernetes the orchestrator of all your software; whether its Dockerized or not!

All your processes are belong to us! :)

Longer term it would be great for Docker to be ported to more operating systems; along with the kubelet. So ideally more operating systems could use native Docker and kubelet; in which case there's less need for kansible. But at the time of writing, that goal is looking some way off for older versions of Windows along with AIX, Solaris and HPUX.

Whats really compelling about using Kubernetes to manage Docker containers and operating system processes via Kansible is that you can mix and match on a per microservice basis - use the right tool for the job right now - but all the while use a single orchestrator platform, Kubernetes, a single REST API, CLI tools and web console - with standard service discovery, load balancing and management functions.

Using Docker is more optimal; so we hope over time that you can use more Docker and less kansible; but its going to take our industry a while to Dockerize all the things and move everything to Linux; or to have fully working Docker + Kubernetes on Windows + all flavours of Unix. Until then, kansible can help! At least we can now pretend everything's Dockerized and running on Linux from an orchestration and management perspective ;)

How to use Kansible

You use kansible as follows:

  • create or reuse an existing Ansible playbook to install and provision the software you wish to run on a number of machines defined by the Ansible inventory

  • if you reuse an existing playbook, make sure you disable running the unix / windows services; as you will run that command instead in the kansible pods.

  • run the Ansible playbook either as part of a CI / CD build pipeline when there's a change to the git repo of the Playbook, or using a command line tool, cron or Ansible Tower

  • define a Replication Controller YAML file at kubernetes/$HOSTS/rc.yml for running the command for your process like this example.

  • the RC YAML file contains the command you need to run remotely to execute your process via $KANSIBLE_COMMAND

    • you can think of the RC YAML file as like the systemd configuration file, describing the command to run to startup the application. Only its a single file for the entire cluster which is stored in Kubernetes. Plus it can include readiness and liveness probes too .
    • You can use the {{ foo_bar }} Ansible variable expressions in the RC YAML to refer to variables from your global Ansible variables file
  • to take advantage of Kubernetes services, you can also define any number of Service YAML files at kubernetes/$HOSTS/service.yml

  • whenever the playbook git repo changes, run the kansible rc command inside a clone of the playbook git repository:

    kansible rc myhosts

where myhosts is the name of the hosts you wish to use in the Ansible inventory.

Then kansible will then create/update Secrets for any SSH private keys in your Ansible inventory and create or update a Replication Controller of kansible pods which will start and supervise your processes, capture the logs and redirect ports to enable liveness checks, centralised metrics and Kubernetes services.

So for each remote process on Windows, Linux, Solaris, AIX, HPUX kansible will create a kansible pod in Kubernetes which starts the command and tails the log to stdout/stderr. You can then use the Replication Controller scaling to start/stop your remote processes!

Working with kansible pods

  • As processes start and stop, you'll see the processes appear or disappear inside kubernetes, the CLI, REST API or the console as a kansible pod.
  • You can scale up and down the kansible Replication Controller via CLI, REST API or console.
  • You can then view the logs of any process in the usual kubernetes way via the command line, REST API or web console.
  • Centralised logging then works great on all your processes (providing the command you run outputs logs to stdout / stderr

Exposing ports

Any ports defined in the Replication Controller YAML file will be automatically forwarded to the remote process. See this example rc.yml file to see how to expose ports.

This means you can take advantage of things like centralised metrics and alerting, liveness checks, Kubernetes Services along with the built in service discovery and load balancing inside Kubernetes!

To see the use of Kubernetes Services and load balancing across remote processes with kansible check out the fabric8-ansible-hawtapp demo.

Opening a shell on the remote process

You can open a shell directly on the remote machine via the web console or by running

oc exec -it -p mypodname bash

Then you'll get a remote shell on the Windows or Unix box!

Examples

Before you start with the kansible examples you'll need:

These examples assume you have a working Kubernetes or OpenShift cluster running.

If you don't yet have a Kubernetes cluster to play with, try using the Fabric8 Vagrant image that includes OpenShift Origin as the Kubernetes cluster.

fabric8-ansible-spring-boot

To run this example type the following to setup the VMs and provision things with Ansible:

git clone https://github.com/fabric8io/fabric8-ansible-spring-boot.git
cd fabric8-ansible-spring-boot
vagrant up
ansible-playbook -i inventory provisioning/site.yml -vv

You now should have 2 sample VMs (app1 and app2) with a Spring Boot based Java application provisioned onto the machines in the /opt folder, but with nothing actually running yet.

Now to setup the kansible Replication Controller run the following, where appservers is the hosts from the Ansible inventory in the inventory file

kansible rc appservers

This should now create a Replication Controller called springboot-demo along with 2 pods for each host in the appservers inventory file.

You should be able to look at the logs of those 2 pods in the usual Kubernetes / OpenShift way; e.g. via the fabric8 or OpenShift console or via the CLI:

e.g.

oc get pods
oc logs -f springboot-demo-81ryw

where springboot-demo-81ryw is the name of the pod you wish to view the logs.

You can now scale down / up the number of pods using the web console or the command line:

oc scale rc --replicas=2 springboot-demo

Important files

The examples use the following files:

fabric8-ansible-hawtapp

This demonstration is similar to the above but it also demonstrates:

  • using both Windows and Linux boxes as the hosts
  • using Kubernetes Services to load balance across the processes

To run this example type the following to setup the VMs and provision things with Ansible:

git clone https://github.com/fabric8io/fabric8-ansible-hawtapp.git
cd fabric8-ansible-hawtapp
vagrant up
ansible-playbook -i inventory provisioning/site.yml -vv

Now to setup the Replication Controller for the supervisors run the following, where appservers is the hosts from the inventory

kansible rc appservers

The pods should now start up for each host in the inventory.

Using windows machines

This example uses 1 windows box and 1 linux box in the inventory. The example shows that kansible can support both operating systems just fine; it does require the playbooks to handle the differences though.

Also you typically will need to use different commands to run on Unix versus Windows which is configured in the rc.yml file. For more details see the documentation on the KANSIBLE_COMMAND_WINRM environment variable

To use windows you may need to first make sure you've installed pywinrm:

sudo pip install pywinrm

If you try to open shells via the fabric8 console or oc exec -it -p podName bash for both pods running, you'll see that one runs on a Linux box and one runs on a Windows machine like this example screenshot!

Trying out Kubernetes Services

This example also creates a Kubernetes Service which loads balances across the remote processes thanks to the kubernetes/appservers/service.yml file which is then exposed via the LoadBalancer type (on OpenShift a Route is created for this).

If you are using the fabric8 console you'll see the hawtapp-demo service in the Services tab.

You can try out the service in your browser via: http://hawtapp-demo-default.vagrant.f8/camel/hello?name=Kansible

Or using the CLI:

curl http://hawtapp-demo-default.vagrant.f8/camel/hello?name=Kansible

Each request load balances over the available processes. You can scale the Replication Controller down to 1 pod or up to 2 and each request should still work.

Configuration

To configure kansible you need to configure a Replication Controller in a file called kubernetes/$HOSTS/rc.yml.

Specify a name and optionally some labels for the replication controller inside the metadata object. There's no need to specify the spec.selector or spec.template.containers[0].metadata.labels values as those are inherited by default from the metadata.labels.

Environment variables

You can specify the following environment variables in the spec.template.spec.containers[0].env array like the use of KANSIBLE_COMMAND below.

These values can use Ansible variable expressions too.

KANSIBLE_COMMAND

Then you must specify a command to run via the $KANSIBLE_COMMAND environment variable:

apiVersion: "v1"
kind: "ReplicationController"
metadata:
  name: "myapp"
  labels:
    project: "myapp"
    version: "{{ app_version }}"
spec:
  template:
    spec:
      containers:
      - env:
        - name: "KANSIBLE_COMMAND"
          value: "/opt/foo-{{ app_version }}/bin/run.sh"
      serviceAccountName: "fabric8"

KANSIBLE_COMMAND_WINRM

This environment variable lets you provide a Windows specific command. It works the same as the KANSIBLE_COMMAND environment variable above, but this value is only used for Ansible connections of the form winrm. i.e. to supply a windows only command to execute.

Its quite common to have a foo.sh script to run sh/bash scripts on unix and then a foo.bat or foo.cmd file for Windows.

KANSIBLE_EXPORT_ENV_VARS

Specify a space separated list of environment variable names which should be exported into the remote shell when running the remote command.

Note that typically your sshd_config will disable the use of most environment variables being exported that don't start with LC_* so you may need to configure your sshd in /etc/ssh/sshd_config to enable this.

KANSIBLE_BASH

This defines the path where the bash script will be generated for running a remote bash shell. This allows running the command bash inside the kansible pod to remotely execute either /bin/bash or cmd.exe for Windows machines on the remote machine when you try to open a shell inside the Web Console or via:

oc exec -p mypodname bash

KANSIBLE_PORT_FORWARD

Allows port forwarding to be disabled.

export KANSIBLE_PORT_FORWARD=false

This is mostly useful to allow the bash command within a pod to not also try to port forward as this will fail ;)

SSH or WinRM

The best way to configure if you want to connect via SSH for unix machines or WinRM for windows machines is via the Ansible Inventory.

By default SSH is used on port 22 unless you specify ansible_port in the inventory or specify --port on the command line.

You can configure Windows machines using the ansible_connection=winrm property in the inventory:

[winboxes]
windows1 ansible_host=localhost ansible_port=5985 ansible_user=foo ansible_pass=somepasswd! ansible_connection=winrm

[unixes]
app1 ansible_host=10.10.3.20 ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/app1/virtualbox/private_key
app2 ansible_host=10.10.3.21 ansible_user=vagrant ansible_ssh_private_key_file=.vagrant/machines/app2/virtualbox/private_key

You can also enable WinRM via the --winrm command line flag:

export KANSIBLE_WINRM=true
kansible pod --winrm somehosts somecommand

or by setting the environment variable KANSIBLE_WINRM which is a little easier to configure on the RC YAML:

export KANSIBLE_WINRM=true
kansible pod somehosts somecommand

Checking the runtime status of the supervisors

To see which pods own which hosts run the following command:

oc export rc hawtapp-demo | grep ansible.fabric8  | sort

Where hawtapp-demo is the name of the RC for the supervisors.

The output is of the format:

pod.kansible.fabric8.io/app1: supervisor-znuj5
pod.kansible.fabric8.io/app2: supervisor-1same

Where the output is of the form pod.ansible.fabric8.io/$HOSTNAME: $PODNAME

More Repositories

1

kubernetes-client

Java client for Kubernetes & OpenShift
Java
3,266
star
2

docker-maven-plugin

Maven plugin for running and creating Docker images
Java
1,822
star
3

fabric8

fabric8 is an open source microservices platform based on Docker, Kubernetes and Jenkins
1,773
star
4

spring-cloud-kubernetes

Kubernetes integration with Spring Cloud
Java
703
star
5

fabric8-pipeline-library

Fabric8 Pipeline for Jenkins
Groovy
431
star
6

fluent-plugin-kubernetes_metadata_filter

Enrich your fluentd events with Kubernetes metadata
Ruby
349
star
7

fabric8-maven-plugin

๐Ÿ“ข This project is migrated to ๐Ÿ‘‰ https://github.com/eclipse/jkube
Java
335
star
8

jenkins-pipeline-library

a collection of reusable jenkins pipelines and pipeline functions
Groovy
274
star
9

kubeflix

Kubernetes integration with Netflix OSS
267
star
10

configmapcontroller

Go
206
star
11

fabric8-jenkinsfile-library

This repository contains a library of reusable Jenkinsfiles that you can use on your projects. Its reused by the fabric8 console to associate Jenkinsfiles to projects
Groovy
187
star
12

elasticsearch-cloud-kubernetes

Java
169
star
13

gofabric8

CLI used when working with fabric8 running on Kubernetes or OpenShift
Go
147
star
14

mockwebserver

An extension of okhttp's mockwebserver, that provides a DSL and is easier to use
Java
112
star
15

fabric8-platform

Generates the distribution of the fabric8 microservices platform
Shell
104
star
16

shootout-docker-maven

A comparison between the four major docker-maven-plugins
Java
84
star
17

jenkins-docker

docker file for a jenkins docker image
Groovy
82
star
18

kubernetes-zipkin

Kubernetes integration with OpenZipkin
Java
69
star
19

ipaas-quickstarts

quickstarts for the fabric8 project
Java
66
star
20

fabric8-devops

Contains the pluggable apps that can be run as part of the fabric8 DevOps platform on any OpenShift v3 or Kubernetes environment
63
star
21

agent-bond

A Super Java Agent
Java
46
star
22

gitcontroller

A simple microservice which watches Kubernetes Deployments which are using gitRepo volumes and if git has changed, updates the Deployment
Go
44
star
23

docker-fluentd-kubernetes

Shell
43
star
24

kubernetes-model

JSON schema generator for OpenShift Origin API objects
36
star
25

fabric8-docker

Dockerfiles to create Fuse containers in docker.io
Shell
33
star
26

fabric8-console

Angular 1.x console for fabric8
28
star
27

openshift-elasticsearch-plugin

Java
27
star
28

jube

jube is a deprecated pure java implementation of kubernetes. Please look at kansible now instead!
Java
27
star
29

vertx-maven-plugin

Vert.x Maven Plugin - moved to https://github.com/reactiverse/vertx-maven-plugin
Java
25
star
30

openshift-auth-proxy

A reverse proxy that authenticates the request against OpenShift, retrieving user information & setting the configured header with the appropriate details.
JavaScript
18
star
31

fabric8-zookeeper-docker

Shell
18
star
32

fluent-plugin-kubernetes

Ruby
16
star
33

fabric8-ipaas

This repository contains the iPaaS related apps that can be run as part of the fabric8 platform on any OpenShift v3 and Kubernetes environment
14
star
34

osio-pipeline

DSL and utility functions in groovy for running Jenkins OSIO Pipeline
Groovy
13
star
35

fabric8-installer

To install fabric8 into a Kubernetes, OpenShift or Atomic environment
Ruby
12
star
36

kubernetes-alexa

A skill that allows Alexa to interact with a Kubernetes / Openshift cluster
Java
12
star
37

docker-gerrit

a docker image for gerrit
Shell
12
star
38

sandbox-fabric8-devops

A repository of devops examples for automatically provisioning and testing fabrics on different infrastructure
Ruby
12
star
39

fabric8-jenkins-workflow-steps

fabric8 based jenkins workflow steps
11
star
40

docker-client

11
star
41

kubernetes-assertions

This library provides a bunch of helpful assertj assertions for working with the kubernetes-api
Java
10
star
42

fabric8-forge

Supports JBoss Forge plugins for the Fabric8 iPaaS along with using Forge as a REST service inside Fabric8 DevOps
Java
10
star
43

docker-gogs

Go
9
star
44

fabric8-ansible-spring-boot

an Ansible playbook for provisioning Spring Boot apps
9
star
45

docker-dirsrv-389ds

Docker Image repo for 389ds Fedora Directory Server
Shell
9
star
46

fabric8-kit

Building blocks for the fabric8 Developer Toolbox (i.e. the Maven plugins)
Java
9
star
47

templates

the default templates to use inside the fabric8 console
Shell
9
star
48

data-mapper

data mapper tooling
7
star
49

jenkins-pipeline-dsl

Groovy
7
star
50

fabric8-online-docs

Shell
7
star
51

docker-cfssl

Shell
7
star
52

docker-grafana

Shell
7
star
53

hawtio-docker

NOTE: now replaced by fabric8/fabric8-console image. This project creates the fabric8/hawtio docker image
Shell
6
star
54

fluent-plugin-docker_metadata_filter

Ruby
6
star
55

default-jenkins-dsl

The default jenkins job DSL build for automatically performing CI and CD on local gogs repositories inside fabric8
Groovy
6
star
56

jenkins_exporter

Prometheus exporter for Jenkins
Go
4
star
57

fabric8-test

Python
4
star
58

fabric8-ansible-hawtapp

a sample Ansible playbook that provisions a fabric8 hawtapp onto boxes
Shell
4
star
59

docker-kibana4

Shell
4
star
60

jadvisor

Go
4
star
61

fabric8-keycloak-theme

CSS
4
star
62

fabric8-envoy

a distribution of Envoy for running on kubernetes or openshift
Shell
4
star
63

grafana-kubernetes-app

JavaScript
4
star
64

fabric8-eclipse-orion

docker packaging of eclipse orion web based IDE
3
star
65

jenkinshift

A simple REST Facade that makes Jenkins Jobs and Build Runs appear as if they are OpenShift BuildConfig / Build objects so that the fabric8-console can still view apps/builds when using Jenkins on vanilla kubernetes
Go
3
star
66

traefik

a kubernetes app for running traefik.io
3
star
67

envsubst

docker image to replace placeholders in a file with env var values
Shell
3
star
68

docker-iptables-redirector

A simple Docker image that redirects traffic via DNAT to a different address/port
Shell
3
star
69

hubot-mattermost

2
star
70

docker-prometheus

2
star
71

hubot-slack

2
star
72

fabric8-release-pipelines

fabric8 release pipeline project that contains the Jenkinsfiles for multi project release
Groovy
2
star
73

hubot-base

2
star
74

jenkins-jnlp-client

Jenkins JNLP Client Docker Image
Shell
2
star
75

fabric8-ci-seed

a Jenkins Job DSL script to auto generate pull request CI jobs for projects such as the quickstarts
Groovy
2
star
76

fabric8-online

Groovy
2
star
77

fabric8-hubot-scripts

scripts for running hubot on fabric8
CoffeeScript
2
star
78

jenkins-slave-docker

Jenkins Slave Docker Image
Shell
2
star
79

dirsrv-389ds

389ds application for OpenShift/Kubernetes
Groovy
2
star
80

jenkernetes-docker

Shell
2
star
81

fabric8-gogs-find-projects

creates a docker container to find repos in gogs for use in jenkins workflow scripts
Java
2
star
82

fabric8-spring

A project to help folks use Spring Boot with Kubernetes or OpenShift
2
star
83

go-builder

Builder image used by Kubernetes Workflow and Jenkinsfile to build golang images
1
star
84

hubot-irc

1
star
85

insight

1
star
86

fabric8-brackets

a docker package for the http://brackets.io/ editor
1
star
87

django-examples

Camel iPaaS functionality examples
1
star
88

docker-logstash

Shell
1
star
89

maven-nexus-docker

a nexus aware docker image for maven
1
star
90

jenkins-slave-dind-maven

a jenkins slave with dind and a pre-installed maven docker image
Shell
1
star
91

ianaservicehelper

Java
1
star
92

gitcollector

collects git and github related events from projects inside OpenShift
Go
1
star
93

jenkins-slave-dind

A Docker in Docker Jenkins Slave
Shell
1
star
94

docker-fluentd

1
star
95

caddy-server

1
star
96

ipaas-platform

Generates the distribution of the ipaas platform
Groovy
1
star
97

docker-influxdb

Go
1
star
98

fabric8-generator

a jboss forge add on for the fabric8 upstream and SaaS generator wizards
Java
1
star
99

fabric8-jbpm-designer

Shell
1
star
100

fabric8-profiles

fabric8-profiles provides an abstraction for sharing configuration across apps in a convention over configuration way
1
star