Add Weave Flux Helm Operator

This commit is contained in:
Stefan Prodan
2018-04-22 13:39:29 +03:00
parent 1330decdaa
commit 68babf42e1
7 changed files with 101 additions and 12 deletions

View File

@@ -5,7 +5,7 @@ It is most useful when used as a deployment tool at the end of a Continuous Deli
## Introduction
This chart bootstraps an [Weave Flux](https://github.com/weaveworks/flux) deployment on
This chart bootstraps a [Weave Flux](https://github.com/weaveworks/flux) deployment on
a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
## Prerequisites
@@ -23,6 +23,20 @@ $ helm install --name cd \
./charts/weave-flux
```
To install Flux with the Helm operator:
```console
$ helm install --name cd \
--set git.url=git@github.com:stefanprodan/weave-flux-helm-demo \
--set git.user="Stefan Prodan" \
--set git.email="stefan.prodan@gmail.com" \
--set helmOperator.create=true \
--namespace flux \
./charts/weave-flux
```
Be aware that the Helm operator is alpha quality, DO NOT use it on a production cluster.
The [configuration](#configuration) section lists the parameters that can be configured during installation.
### Setup Git deploy
@@ -31,8 +45,8 @@ At startup Flux generates a SSH key and logs the public key.
Find the SSH public key with:
```bash
FLUX_POD=$(kubectl get pods --namespace flux -l "app=weave-flux,release=cd" -o jsonpath="{.items[0].metadata.name}")
kubectl logs $FLUX_POD | grep identity.pub | cut -d '"' -f2 | sed 's/.\{2\}$//'
export FLUX_POD=$(kubectl get pods --namespace flux -l "app=weave-flux,release=cd" -o jsonpath="{.items[0].metadata.name}")
kubectl -n flux logs $FLUX_POD | grep identity.pub | cut -d '"' -f2 | sed 's/.\{2\}$//'
```
In order to sync your cluster state with GitHub you need to copy the public key and
@@ -69,6 +83,11 @@ The following tables lists the configurable parameters of the Weave Flux chart a
| `git.path` | Path within git repo to locate Kubernetes manifests (relative path) | None
| `git.user` | Username to use as git committer | `Weave Flux`
| `git.email` | Email to use as git committer | `support@weave.works`
| `git.chartsPath` | Path within git repo to locate Helm charts (relative path) | `charts`
| `helmOperator.create` | If `true`, install the Helm operator | `false`
| `helmOperator.repository` | Helm operator image repository | `quay.io/weaveworks/helm-operator`
| `helmOperator.tag` | Helm operator image tag | `master-6f427cb`
| `helmOperator.pullPolicy` | Helm operator image pull policy | `IfNotPresent`
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example:

View File

@@ -10,10 +10,10 @@
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "weave-flux.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward $POD_NAME 8080:3030
kubectl -n {{ .Release.Namespace }} port-forward $POD_NAME 8080:3030
{{- end }}
2. Get the Git deploy key by running these commands:
export FLUX_POD=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "weave-flux.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
kubectl logs $FLUX_POD | grep identity.pub | cut -d '"' -f2 | sed 's/.\{2\}$//'
kubectl -n {{ .Release.Namespace }} logs $FLUX_POD | grep identity.pub | cut -d '"' -f2 | sed 's/.\{2\}$//'

View File

@@ -0,0 +1,19 @@
{{- if .Values.helmOperator.create -}}
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: fluxhelmreleases.helm.integrations.flux.weave.works
labels:
app: {{ template "weave-flux.name" . }}
chart: {{ template "weave-flux.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
group: helm.integrations.flux.weave.works
names:
kind: FluxHelmRelease
listKind: FluxHelmReleaseList
plural: fluxhelmreleases
scope: Namespaced
version: v1alpha
{{- end -}}

View File

@@ -0,0 +1,43 @@
{{- if .Values.helmOperator.create -}}
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "weave-flux.fullname" . }}-helm-operator
labels:
app: {{ template "weave-flux.name" . }}-helm-operator
chart: {{ template "weave-flux.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ template "weave-flux.name" . }}-helm-operator
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "weave-flux.name" . }}-helm-operator
release: {{ .Release.Name }}
spec:
{{- if .Values.serviceAccount.create }}
serviceAccountName: {{ template "weave-flux.serviceAccountName" . }}
{{- end }}
volumes:
- name: git-key
secret:
secretName: {{ template "weave-flux.fullname" . }}-git-deploy
defaultMode: 0400
containers:
- name: flux-helm-operator
image: "{{ .Values.helmOperator.repository }}:{{ .Values.helmOperator.tag }}"
imagePullPolicy: {{ .Values.helmOperator.pullPolicy }}
volumeMounts:
- name: git-key
mountPath: /etc/fluxd/ssh
readOnly: true
args:
- --git-url={{ .Values.git.url }}
- --git-branch={{ .Values.git.branch }}
- --git-charts-path={{ .Values.git.chartsPath }}
{{- end -}}

View File

@@ -11,6 +11,12 @@ service:
type: ClusterIP
port: 3030
helmOperator:
create: false
repository: quay.io/weaveworks/helm-operator
tag: master-6f427cb
pullPolicy: IfNotPresent
rbac:
# Specifies whether RBAC resources should be created
create: true
@@ -49,3 +55,5 @@ git:
user: "Weave Flux"
# Email to use as git committer
email: "support@weave.works"
# Path within git repo to locate Helm charts (relative path)
chartsPath: "charts"

View File

@@ -3,7 +3,7 @@ entries:
ambassador:
- apiVersion: v1
appVersion: 0.29.0
created: 2018-04-22T12:15:20.174766976+03:00
created: 2018-04-22T13:38:40.997174933+03:00
description: A Helm chart for Datawire Ambassador
digest: a30c8cb38e696b09fda8269ad8465ce6fec6100cfc108ca85ecbc85913ca5c7f
engine: gotpl
@@ -19,7 +19,7 @@ entries:
grafana:
- apiVersion: v1
appVersion: "1.0"
created: 2018-04-22T12:15:20.175783483+03:00
created: 2018-04-22T13:38:40.998183639+03:00
description: A Helm chart for Kubernetes
digest: abdcadc5cddcb7c015aa5bb64e59bfa246774ad9243b3eb3c2a814abb38f2776
name: grafana
@@ -29,7 +29,7 @@ entries:
ngrok:
- apiVersion: v1
appVersion: "1.0"
created: 2018-04-22T12:15:20.176151057+03:00
created: 2018-04-22T13:38:40.998537731+03:00
description: A Ngrok Helm chart for Kubernetes
digest: 7bf5ed2ef63ccd5efb76bcd9a086b04816a162c51d6ab592bccf58c283acd2ea
name: ngrok
@@ -39,7 +39,7 @@ entries:
podinfo:
- apiVersion: v1
appVersion: 0.2.1
created: 2018-04-22T12:15:20.176642386+03:00
created: 2018-04-22T13:38:40.998990682+03:00
description: Podinfo Helm chart for Kubernetes
digest: f762207915a73faee72683b8ef8ac53da9db2dcbcf2107b2479d11beeb8f661f
engine: gotpl
@@ -56,10 +56,10 @@ entries:
weave-flux:
- apiVersion: v1
appVersion: 1.2.5
created: 2018-04-22T12:15:20.177557232+03:00
created: 2018-04-22T13:38:40.999693028+03:00
description: Flux is a tool that automatically ensures that the state of a cluster
matches what is specified in version control
digest: 40a06aa6a6eb1f2a82090b429406af934cc69ea5af0f028d4d041832461bc693
digest: a69e714356f331f89f272a43028ad3f3d7bfde373aff2ad98a34c44731bf7458
engine: gotpl
home: https://weave.works
icon: https://www.weave.works/assets/images/bltd108e8f850ae9e7c/weave-logo-512.png
@@ -72,4 +72,4 @@ entries:
urls:
- https://stefanprodan.github.io/k8s-podinfo/weave-flux-0.1.0.tgz
version: 0.1.0
generated: 2018-04-22T12:15:20.17383917+03:00
generated: 2018-04-22T13:38:40.996475166+03:00

Binary file not shown.