<file_sep>## Kedge Plugin for Helm

#### Using the plugin -

1. Install the plugin
   `helm plugin install https://github.com/kedgeproject/kedge-helm-plugin.git`

2. Package the chart using
   `helm kedge package <path to chart>`
 
   An example Kedge application is located at examples/wordpress/kedge/
   
   Run,
   `helm kedge package examples/wordpress/kedge/`
   
   The plugin generates Kubernetes artifacts and places in examples/wordpress/templates/kedge-generated.yaml 
   
3. Deploy the generated chart
   `helm install wordpress-0.1.0.tgz`

#### Short PoC:
[![asciicast](https://asciinema.org/a/dmGQDj0X89S3YCrYZ2oPEHF7G.png)](https://asciinema.org/a/dmGQDj0X89S3YCrYZ2oPEHF7G)

##### What's next?

- Add support for parameterization
<file_sep># Wordpress

Deploy a Wordpress container with a database (MariaDB) as well as secrets using Kedge!

In all, we will define a:
 - service
 - secret
 - configmap
 - deployment

# How to deploy

1. Download the files

```sh
wget https://raw.githubusercontent.com/kedgeproject/kedge/master/examples/wordpress/wordpress.yaml
wget https://raw.githubusercontent.com/kedgeproject/kedge/master/examples/wordpress/mariadb.yaml
```

2. Deploy using `kedge`

```sh
$ kedge apply -f wordpress.yaml -f mariadb.yaml
persistentvolumeclaim "database" created
service "database" created
secret "database-root-password" created
secret "database-user-password" created
configmap "database" created
deployment "database" created
service "wordpress" created
deployment "wordpress" created
```

3. Access your Wordpress instance

If you are using `minikube` for local Kubernetes deployment, you can access your Wordpress instance using `minikube service`

```sh
$ minikube service wordpress
Opening kubernetes service default/wordpress in default browser...
```
<file_sep>Helm chart defined using the Kedge spec
<file_sep>#!/bin/bash

set -eu

usage() {
cat << EOF
This plugin provides integration with the kedge project.

Available Commands:
  build   Build the Kedge files into Kubernetes artifacts, but don't package.
  package Generated a packaged Helm chart.

Typical usage:

   $ helm create mychart
   $ mkdir -p mychart/kedge
   $ place kedge files in mychart/kedge/
   $ helm kedge package mychart
   $ helm install ./mychart-0.1.0.tgz 

EOF
}

build() {
  kedge generate -f $1/kedge/ > $1/templates/kedge-generated.yaml
}

package() {
  build $1
  helm package $1
}

if [[ $# < 1 ]]; then
  echo "===> ERROR: Subcommand required. Try 'helm kedge help'"
  exit 1
elif [[ $# < 2 && $1 != "help" ]]; then
  echo "===> ERROR: Missing chart path. Use '.' for the present directory."
  exit 1
fi

case "${1:-"help"}" in
  "package")
    package $2
    ;;
  "show")
    show $2
    ;;
  "build")
    build $2
    ;;
  "help")
    usage
    ;;
  *)
    echo $1
    usage
    exit 1
    ;;
esac

