From 6ca2875c8135c30e8a54cdcfc0fb3c8ac81ed289 Mon Sep 17 00:00:00 2001 From: Evan Steitz Date: Fri, 15 Sep 2017 19:57:50 +0000 Subject: [PATCH] feat(main): Armada as a plugin Added in functionality that allows users to use access armada as a plugin for helm. Closes 164 https://github.com/att-comdev/armada/issues/164 Change-Id: I6f43d373155454c713bff90977b1551357f22abe --- controller.sh | 37 ++++++++++++++++++++ docs/source/operations/guide-helm-plugin.rst | 23 ++++++++++++ plugin.yaml | 11 ++++++ 3 files changed, 71 insertions(+) create mode 100755 controller.sh create mode 100644 docs/source/operations/guide-helm-plugin.rst create mode 100644 plugin.yaml diff --git a/controller.sh b/controller.sh new file mode 100755 index 00000000..2a449a58 --- /dev/null +++ b/controller.sh @@ -0,0 +1,37 @@ +#!/bin/bash +clean_container(){ + echo "Destroying $1 container..." + docker stop $1 >/dev/null + docker rm $1 >/dev/null + echo "...container destroyed" +} + +readlink(){ + ( + cd $(dirname $1) + echo $PWD/$(basename $1) + ) +} + +# Check to see if the aramada container exists +if [ -n "$( sudo docker ps -a | grep quay.io/attcomdev/armada )" ]; then + echo "Armada container already exists..." + clean_container armada +fi + +# Check to see if the user is trying to apply a chart +if [ $1 = "apply" ]; then + # TODO Handle erroneous or missing inputs + # Bring up a new armada container with passed in yaml mounted to the container + echo "Creating an Armada container..." + docker run -d --net host -p 8000:8000 --name armada -v $(readlink $(dirname $2)):$(readlink $(dirname $2)) -v ~/.kube/config:/armada/.kube/config -v ~/.kube/plugins/armada/examples/:/examples quay.io/attcomdev/armada:latest + docker exec armada armada apply $(readlink $2) +else + # For any other command the chart does not need to be mounted to the container + # Bring up a new armada container + echo "Creating an Armada container..." + docker run -d --net host -p 8000:8000 --name armada -v ~/.kube/config:/armada/.kube/config -v ~/.kube/plugins/armada/examples/:/examples quay.io/attcomdev/armada:latest + docker exec armada armada "$@" +fi +clean_container armada + diff --git a/docs/source/operations/guide-helm-plugin.rst b/docs/source/operations/guide-helm-plugin.rst new file mode 100644 index 00000000..b5a65a16 --- /dev/null +++ b/docs/source/operations/guide-helm-plugin.rst @@ -0,0 +1,23 @@ +Armada Plugin +============ + +The armada plugin extends all the functionality of Armada to be used as a plugin with Helm. + +Install Plugin +--------------- +:: + + To install the Armada plugin, all you have to do is copy the plugin directory into ~/.helm/plugins/ + +.. code-block:: bash + + git clone https://github.com/att-comdev/armada.git ~/.helm/plugins/ + +Usage +------ + +**helm [options]** +:: + + helm armada tiller --status + helm armada apply ~/.helm/plugins/armada/examples/simple.yaml diff --git a/plugin.yaml b/plugin.yaml new file mode 100644 index 00000000..fbf91654 --- /dev/null +++ b/plugin.yaml @@ -0,0 +1,11 @@ +name: "armada" +version: "0.0.3" +usage: "Manages multiple helm charts with a centralized armada yaml" +description: |- + This plugin provides helm access to armada. A tool for managing multiple helm charts with dependencies by centralizing all configurations in a single Armada yaml and providing lifecycle hooks for all helm releases + usage: + $ helm armada tiller --status + $ helm armada apply /examples/openstack-helm.yaml +ignoreFlags: false +useTunnel: false +command: "sh $HELM_PLUGIN_DIR/controller.sh"