Skip to content

Commit

Permalink
feat(*): add a helm mode to steward (#123)
Browse files Browse the repository at this point in the history
Fixes #10
Fixes #139
Ref #23

Tests forthcoming as part of #158
  • Loading branch information
arschles committed Sep 2, 2016
1 parent deb1706 commit c359809
Show file tree
Hide file tree
Showing 39 changed files with 1,704 additions and 229 deletions.
1 change: 1 addition & 0 deletions DATA_STRUCTURES.md
Expand Up @@ -46,6 +46,7 @@ This object is submitted by the application as JSON in a [`ConfigMap`][configMap
- `status-description` - a human-readable explanation of the current `status`. Steward will modify this value, but will ignore any modifications by the application
- `instance-id` - for internal use only. The application should not modify this field
- `bind-id` - for internal use only. The application should not modify this field
- `extra` - for internal use only. The application should not modify this field

# `ServicePlanCreation`

Expand Down
89 changes: 74 additions & 15 deletions Makefile
Expand Up @@ -44,7 +44,7 @@ install-3prs:

STEWARD_IMAGE ?= quay.io/deisci/steward:devel

install-steward:
install-cf-steward:
ifndef CF_BROKER_NAME
$(error CF_BROKER_NAME is undefined)
endif
Expand All @@ -63,19 +63,78 @@ endif
ifndef CF_BROKER_PASSWORD
$(error CF_BROKER_PASSWORD is undefined)
endif
sed "s/#cf_broker_name#/${CF_BROKER_NAME}/g" manifests/steward-template.yaml > manifests/${CF_BROKER_NAME}-steward.yaml
sed -i.bak "s/#cf_broker_scheme#/${CF_BROKER_SCHEME}/g" manifests/${CF_BROKER_NAME}-steward.yaml
sed -i.bak "s/#cf_broker_hostname#/${CF_BROKER_HOSTNAME}/g" manifests/${CF_BROKER_NAME}-steward.yaml
sed -i.bak "s/#cf_broker_port#/${CF_BROKER_PORT}/g" manifests/${CF_BROKER_NAME}-steward.yaml
sed -i.bak "s/#cf_broker_username#/${CF_BROKER_USERNAME}/g" manifests/${CF_BROKER_NAME}-steward.yaml
sed -i.bak "s/#cf_broker_password#/${CF_BROKER_PASSWORD}/g" manifests/${CF_BROKER_NAME}-steward.yaml
sed -i.bak "s#\#steward_image\##${STEWARD_IMAGE}#g" manifests/${CF_BROKER_NAME}-steward.yaml
rm manifests/${CF_BROKER_NAME}-steward.yaml.bak
sed "s/#cf_broker_name#/${CF_BROKER_NAME}/g" manifests/steward-template-cf.yaml > manifests/${CF_BROKER_NAME}-cf-steward.yaml
sed -i.bak "s/#cf_broker_scheme#/${CF_BROKER_SCHEME}/g" manifests/${CF_BROKER_NAME}-cf-steward.yaml
sed -i.bak "s/#cf_broker_hostname#/${CF_BROKER_HOSTNAME}/g" manifests/${CF_BROKER_NAME}-cf-steward.yaml
sed -i.bak "s/#cf_broker_port#/${CF_BROKER_PORT}/g" manifests/${CF_BROKER_NAME}-cf-steward.yaml
sed -i.bak "s/#cf_broker_username#/${CF_BROKER_USERNAME}/g" manifests/${CF_BROKER_NAME}-cf-steward.yaml
sed -i.bak "s/#cf_broker_password#/${CF_BROKER_PASSWORD}/g" manifests/${CF_BROKER_NAME}-cf-steward.yaml
sed -i.bak "s#\#steward_image\##${STEWARD_IMAGE}#g" manifests/${CF_BROKER_NAME}-cf-steward.yaml
rm manifests/${CF_BROKER_NAME}-cf-steward.yaml.bak
kubectl get deployment ${CF_BROKER_NAME}-steward --namespace=steward && \
kubectl apply -f manifests/${CF_BROKER_NAME}-steward.yaml || \
kubectl create -f manifests/${CF_BROKER_NAME}-steward.yaml
kubectl apply -f manifests/${CF_BROKER_NAME}-cf-steward.yaml || \
kubectl create -f manifests/${CF_BROKER_NAME}-cf-steward.yaml

deploy: install-namespace install-3prs install-steward

dev-deploy: docker-build docker-push
STEWARD_IMAGE=${IMAGE} $(MAKE) deploy
install-helm-steward:
ifndef HELM_CHART_NAME
$(error HELM_CHART_NAME is undefined)
endif
ifndef HELM_TILLER_IP
$(error HELM_TILLER_IP is undefined)
endif
ifndef HELM_TILLER_PORT
$(error HELM_TILLER_PORT is undefined)
endif
ifndef HELM_CHART_URL
$(error HELM_CHART_URL is undefined)
endif
ifndef HELM_CHART_INSTALL_NAMESPACE
$(error HELM_CHART_INSTALL_NAMESPACE is undefined)
endif
ifndef HELM_PROVISION_BEHAVIOR
$(error HELM_PROVISION_BEHAVIOR is undefined)
endif
ifndef HELM_SERVICE_ID
$(error HELM_SERVICE_ID is undefined)
endif
ifndef HELM_SERVICE_NAME
$(error HELM_SERVICE_NAME is undefined)
endif
ifndef HELM_SERVICE_DESCRIPTION
$(error HELM_SERVICE_DESCRIPTION is undefined)
endif
ifndef HELM_PLAN_ID
$(error HELM_PLAN_ID is undefined)
endif
ifndef HELM_PLAN_NAME
$(error HELM_PLAN_NAME is undefined)
endif
ifndef HELM_PLAN_DESCRIPTION
$(error HELM_PLAN_DESCRIPTION is undefined)
endif
sed "s/#helm_name#/${HELM_CHART_NAME}/g" manifests/steward-template-helm.yaml > manifests/${HELM_CHART_NAME}-steward.yaml
sed "s/#helm_tiller_ip#/${HELM_TILLER_IP}/g" manifests/steward-template-helm.yaml > manifests/${HELM_CHART_NAME}-steward.yaml
sed -i.bak "s/#helm_tiller_port#/${HELM_TILLER_PORT}/g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s/#helm_chart_url#/${HELM_CHART_URL}/g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s/#helm_chart_install_namespace#/${HELM_CHART_INSTALL_NAMESPACE}/g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s/#helm_provision_behavior#/${HELM_PROVISION_BEHAVIOR}/g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s/#helm_service_id#/${HELM_SERVICE_ID}/g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s#\#helm_service_name\##${HELM_SERVICE_NAME}#g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s#\#helm_service_description\##${HELM_SERVICE_DESCRIPTION}#g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s#\#helm_plan_id\##${HELM_PLAN_ID}#g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s#\#helm_plan_name\##${HELM_PLAN_NAME}#g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
sed -i.bak "s#\#helm_plan_description\##${HELM_PLAN_DESCRIPTION}#g" manifests/${HELM_CHART_NAME}-helm-steward.yaml
rm manifests/${HELM_CHART_NAME}-helm-steward.yaml.bak
kubectl get deployment ${HELM_CHART_NAME}-steward --namespace=steward && \
kubectl apply -f manifests/${HELM_CHART_NAME}-helm-steward.yaml || \
kubectl create -f manifests/${HELM_CHART_NAME}-helm-steward.yaml

deploy-cf: install-namespace install-3prs install-cf-steward

deploy-helm: install-namespace install-3prs install-helm-steward

dev-deploy-cf: docker-build docker-push
STEWARD_IMAGE=${IMAGE} $(MAKE) deploy-cf

dev-deploy-helm: docker-build docker-push
STEWARD_IMAGE=${IMAGE} $(MAKE) deploy-helm
48 changes: 47 additions & 1 deletion README.md
Expand Up @@ -92,7 +92,53 @@ export STEWARD_CF_PASSWORD=foo

## Helm mode

TODO
Steward can integrate with any standard [Helm Tiller](https://github.com/kubernetes/helm) server to provide a broker in front of [Helm charts](https://github.com/kubernetes/charts). See Helm's [quick start](https://github.com/kubernetes/helm/blob/master/docs/quickstart.md) documentation for a guide on installing both the Helm CLI and the Tiller server. Note that because of [Helm issue #1083](https://github.com/kubernetes/helm/issues/1083#issuecomment-243520610), you'll have to install the Tiller server v2.0.0-alpha3 with the following command:

```console
helm init --image gcr.io/kubernetes-helm/tiller:v2.0.0-alpha.3
```

### Configuration

Configure steward to run in helm mode by setting the `STEWARD_MODE` environment variable to `helm`. Then, configure its behavior with the following environment variables:

- `HELM_TILLER_IP` - the IP address of the Tiller server to talk to
- `HELM_TILLER_PORT` - the port of that the Tiller server at `HELM_TILLER_IP` is listening on
- `HELM_CHART_URL` - the URL of the chart to install
- `HELM_CHART_INSTALL_NAMESPACE` - the Kubernetes namespace in which to install charts
- `HELM_PROVISION_BEHAVIOR` - See the "Provision and Deprovision Operations" section below
- `HELM_SERVICE_ID` - the service ID to list in the service catalog for this steward instance
- `HELM_SERVICE_NAME` - the service name to list in the service catalog for this steward instance
- `HELM_SERVICE_DESCRIPTION` - the service description to list in the service catalog for this steward instance
- `HELM_PLAN_ID` - the plan ID to list in the service catalog for this steward instance
- `HELM_PLAN_NAME` - the plan name to list in the service catalog for this steward instance
- `HELM_PLAN_DESCRIPTION` - the plan description to list in the service catalog for this steward instance


### Provision and Deprovision Operations

Steward can be configured to take one of two different actions when it receives a provision or deprovision operation. Configure this behavior with one of the folowing two values for the `HELM_PROVISION_BEHAVIOR` env var:

- `noop` - steward will not install or uninstall the chart specified at `HELM_CHART_URL`. In this confifguration, steward expects the following state of the cluster when it starts:
- The operator has installed the same chart as specfied in the `HELM_CHART_URL` environment variable
- The ConfigMaps specified in the chart's `values.yaml` file (see below) exist and represent valid credentials for the bindable services the chart has started
- The operator will not uninstall or otherwise modify the chart in such a way that bound consumers cannot properly interact with the chart's exposed services
- `active` - steward will download and install the chart specified at `HELM_CHART_URL` on provision operations, and uninstall it on deprovision operations

### Bind and Unbind Operations

On bind operations, steward reads a set of chart-specified `ConfigMap`s to get the credentials to return to the consumer. The namespace and name for each `ConfigMap` should be specified in the chart's top-level `values.yaml` file as such:

```yaml
stewardConfigMaps:
- name: cm1
namespace: ns1
- name: cm2
namespace: ns2
```

On unbind operations, steward will attempt to delete this same set of `ConfigMap`s.


# Development & Testing

Expand Down
2 changes: 1 addition & 1 deletion config.go
Expand Up @@ -6,7 +6,7 @@ import (
)

type rootConfig struct {
Mode string `envconfig:"MODE" default:"cf"`
Mode string `envconfig:"MODE" required:"true"`
LogLevel string `envconfig:"LOG_LEVEL" default:"info"`
WatchNamespaces []string `envconfig:"WATCH_NAMESPACES" default:"default"`
}
Expand Down

0 comments on commit c359809

Please sign in to comment.