refactor chart to latest best practices

refactor-chart
rimas 2018-02-26 13:32:51 +00:00
parent 76da3df510
commit 9ed182b88a
12 changed files with 99 additions and 74 deletions

View File

@ -1,8 +1,8 @@
apiVersion: v1
name: keel
description: Open source, tool for automating Kubernetes deployment updates. Keel is stateless, robust and lightweight.
version: 0.1.2
appversion: 0.5.2
version: 0.1.4
appversion: 0.6.1
keywords:
- kubernetes deployment
- helm release
@ -11,8 +11,8 @@ home: https://keel.sh
sources:
- https://github.com/keel-hq/keel
maintainers:
- name: Rimas Mocevicius
- name: rimusz
email: rmocius@gmail.com
- name: Karolis Rusenas
- name: rusenask
email: karolis.rusenas@gmail.com
engine: gotpl

View File

@ -24,20 +24,12 @@ Keel provides several key features:
**Note**: For now Keel gets installed into `kube-system` _namespace_ by default as where Helm's `Tiller` is installed.
## Installing the Chart with Kubernetes provider support
## Installing
Docker image _polling_ and _Kubernetes_ provider are set by default, then Kubernetes _deployments_ can be upgraded when new Docker image is available:
Docker image _polling_, _Kubernetes provider_ and _Helm provider_ support are set by default, then Kubernetes _deployments_ can be upgraded when new Docker image is available:
```console
helm upgrade --install keel keel"
```
## Installing the Chart with Helm provider support
Docker image _polling_ is set by default, but we need to enable _Helm provider_ support, then Helm _releases_ can be upgraded when new Docker image is available:
```console
helm upgrade --install keel keel --set helmProvider.enabled="true"
helm upgrade --install keel keel/
```
### Setting up Helm release to be automatically updated by Keel
@ -78,7 +70,7 @@ idea how to set automatic updates.
To uninstall/delete the `keel` deployment:
```console
$ helm delete keel
$ helm delete --purge keel
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
@ -90,7 +82,7 @@ The following table lists has the main configurable parameters (polling, trigger
| Parameter | Description | Default |
| --------------------------------- | -------------------------------------- | --------------------------------------------------------- |
| `polling.enabled` | Docker registries polling | `true` |
| `helmProvider.enabled` | Enable/disable Helm provider | `false` |
| `helmProvider.enabled` | Enable/disable Helm provider | `true` |
| `gcr.enabled` | Enable/disable GCR Registry | `false` |
| `gcr.projectID` | GCP Project ID GCR belongs to | |
| `gcr.pubsub.enabled` | Enable/disable GCP Pub/Sub trigger | `false` |
@ -120,6 +112,6 @@ Specify each parameter using the `--set key=value[,key=value]` argument to `helm
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```console
$ helm install --name keel -f values.yaml keel
$ helm install --name keel -f values.yaml keel/
```
> **Tip**: You can use the default [values.yaml](values.yaml)

View File

@ -1,8 +1,8 @@
1. The {{ template "name" .}} is getting provisioned in your cluster. After a few minutes, you can run the following to verify.
1. The {{ template "keel.name" . }} is getting provisioned in your cluster. After a few minutes, you can run the following to verify.
To verify that {{ template "name" . }} has started, run:
To verify that {{ template "keel.name" . }} has started, run:
kubectl --namespace=kube-system get pods -l "app={{ template "name" . }}"
kubectl --namespace=kube-system get pods -l "app={{ template "keel.name" . }}"
{{- if .Values.service.enabled }}
@ -11,20 +11,20 @@ To verify that {{ template "name" . }} has started, run:
{{- if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace kube-system -w {{ template "name" . }}'
Watch the status with: 'kubectl get svc --namespace kube-system -w {{ template "keel.name" . }}'
export SERVICE_IP=$(kubectl get svc --namespace kube-system {{ template "name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export SERVICE_IP=$(kubectl get svc --namespace kube-system {{ template "keel.name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace kube-system -l "app={{ template "name" . }}" -o jsonpath="{.items[0].metadata.name}")
export POD_NAME=$(kubectl get pods --namespace kube-system -l "app={{ template "keel.name" . }}" -o jsonpath="{.items[0].metadata.name}")
echo http://127.0.0.1:{{ .Values.service.externalPort }}
kubectl port-forward --namespace kube-system $POD_NAME {{ .Values.service.externalPort }}:{{ .Values.service.externalPort }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace kube-system -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "name" . }})
export NODE_PORT=$(kubectl get --namespace kube-system -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "keel.name" . }})
export NODE_IP=$(kubectl get nodes --namespace kube-system -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/

View File

@ -2,15 +2,31 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- define "keel.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "fullname" -}}
{{- define "keel.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "keel.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -2,7 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "name" . }}
name: {{ template "keel.name" . }}
rules:
- apiGroups:
- ""

View File

@ -2,13 +2,13 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "name" . }}
name: {{ template "keel.name" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "name" . }}
name: {{ template "keel.name" . }}
subjects:
- kind: ServiceAccount
name: {{ template "name" . }}
name: {{ template "keel.name" . }}
namespace: kube-system
{{ end }}

View File

@ -1,30 +1,37 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "name" . }}
name: {{ template "keel.fullname" . }}
namespace: kube-system
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app: {{ template "keel.name" . }}
chart: {{ template "keel.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "keel.name" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "name" . }}
app: {{ template "keel.name" . }}
release: {{ .Release.Name }}
spec:
serviceAccountName: {{ template "name" . }}
serviceAccountName: {{ template "keel.name" . }}
containers:
- name: keel
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/bin/keel"]
{{- if .Values.googleApplicationCredentials }}
volumeMounts:
- name: google
mountPath: "/google"
readOnly: true
{{- end }}
env:
{{- if .Values.googleApplicationCredentials }}
- name: GOOGLE_APPLICATION_CREDENTIALS
@ -103,23 +110,33 @@ spec:
- name: KEY
valueFrom:
secretKeyRef:
name: {{ template "name" . }}-webhookrelay
name: {{ template "keel.name" . }}-webhookrelay
key: key
- name: SECRET
valueFrom:
secretKeyRef:
name: {{ template "name" . }}-webhookrelay
name: {{ template "keel.name" . }}-webhookrelay
key: secret
- name: BUCKET
value: "{{ .Values.webhookRelay.bucket }}"
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- if .Values.googleApplicationCredentials }}
volumes:
- name: google
secret:
secretName: {{ template "name" . }}-google
{{- end }}
secretName: {{ template "keel.name" . }}-google
{{- end }}

View File

@ -2,14 +2,14 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "name" . }}-google
name: {{ template "keel.name" . }}-google
namespace: kube-system
labels:
app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app: {{ template "keel.name" . }}
chart: {{ template "keel.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
google-application-credentials.json: {{ .Values.googleApplicationCredentials | b64enc | quote }}
{{- end }}
{{- end }}

View File

@ -2,13 +2,13 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "name" . }}-webhookrelay
name: {{ template "keel.name" . }}-webhookrelay
namespace: kube-system
labels:
app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app: {{ template "keel.name" . }}
chart: {{ template "keel.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
key: {{ .Values.webhookRelay.key | b64enc }}

View File

@ -1,10 +1,10 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "name" . }}
name: {{ template "keel.name" . }}
namespace: kube-system
labels:
app: {{ template "name" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
app: {{ template "keel.name" . }}
chart: {{ template "keel.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}

View File

@ -2,11 +2,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "name" . }}
name: {{ template "keel.name" . }}
namespace: kube-system
labels:
app: {{ template "name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
app: {{ template "keel.name" . }}
chart: {{ template "keel.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
@ -17,6 +17,6 @@ spec:
protocol: TCP
name: keel
selector:
app: {{ template "name" . }}
app: {{ template "keel.name" . }}
sessionAffinity: None
{{- end }}

View File

@ -4,7 +4,7 @@
image:
repository: keelhq/keel
tag: 0.5.2
tag: 0.6.1
pullPolicy: IfNotPresent
# Polling is enabled by default,
@ -14,7 +14,7 @@ polling:
# Helm provider support
helmProvider:
enabled: false
enabled: true
# Google Container Registry
# GCP Project ID
@ -107,14 +107,14 @@ nodeSelector: {}
# json of service account
# googleApplicationCredentials: |-
# {
# "type":
# "type":
# "project_id"
# "private_key_id":
# "private_key":
# "client_email":
# "client_id":
# "auth_uri":
# "token_uri":
# "auth_provider_x509_cert_url":
# "client_x509_cert_url":
# }
# "private_key_id":
# "private_key":
# "client_email":
# "client_id":
# "auth_uri":
# "token_uri":
# "auth_provider_x509_cert_url":
# "client_x509_cert_url":
# }