Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Adds helm chart for heptio/ark #3795

Merged
merged 47 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
65ac2e3
first commit
domcar Feb 21, 2018
f675cb1
changes SA name
domcar Feb 21, 2018
5aa0747
adds correct rbac rules
domcar Feb 21, 2018
14ea5ff
renames files; add more customizable vars
domcar Feb 21, 2018
536c688
updates readme
domcar Feb 21, 2018
4ead002
adds notes
domcar Feb 21, 2018
3f0aad2
removes config values
domcar Feb 21, 2018
d5858f5
changes email in chart
domcar Feb 21, 2018
b65504c
updates readme
domcar Feb 21, 2018
bf9b51c
test changes author
domcar Feb 21, 2018
adf608d
test change email
domcar Feb 21, 2018
e4d1e82
test change email
domcar Feb 21, 2018
9373293
adds prerequisites in readme
domcar Feb 21, 2018
d80dd98
fixes typo
domcar Feb 22, 2018
44d8acd
adds AWS
domcar Feb 22, 2018
669ce07
updates to version 0.7
domcar Feb 22, 2018
f47b895
updates version in chart
domcar Feb 22, 2018
e85c4f0
adds repo source; removes unnecessary values
domcar Feb 22, 2018
4802657
moves deployment to templates
domcar Feb 23, 2018
e6b9d24
renames folder
domcar Feb 23, 2018
ff4b980
updaates to 0.7.1
domcar Feb 23, 2018
8eb6040
creates ark sa in helpers; separates files according to object type
domcar Feb 23, 2018
261d611
updates version in chart
domcar Feb 23, 2018
61a05b8
adds home to chart
domcar Feb 23, 2018
8c74bc3
updates to v0.7.1
domcar Feb 23, 2018
bb0ff5a
modifies chart according to best practices
domcar Feb 26, 2018
e305418
removes blank line
domcar Feb 26, 2018
5463c3f
adds delete backup hook to solve issue crd backup not deleting
domcar Feb 27, 2018
fb90ec9
adjusts indentation, renames file with using hyphene
domcar Mar 13, 2018
ac6d7bc
moves folder to stable
domcar Mar 13, 2018
be5596c
remove unnecessary test condition
domcar Apr 10, 2018
2c74977
Update to v0.8.1; Add support for Azure
domcar Apr 25, 2018
e5b514f
Update readme
domcar Apr 30, 2018
e564f4e
Add annotation for kube2iam
domcar Apr 30, 2018
00d250e
Add image for hooks. Update readme
domcar Apr 30, 2018
0f7cb0a
Rename serviceaccount
domcar May 9, 2018
8984ec0
Use Get instead of Glob
domcar May 9, 2018
9b80a0b
Remove namespace
domcar May 9, 2018
00e6649
Add PullPolicy; Modify readme
domcar May 9, 2018
fb6a6fd
Rename Chart ark
domcar May 9, 2018
2af806e
Add standard labels to resources
domcar May 9, 2018
b78fceb
Add customizable tolertion and nodeselector
domcar May 9, 2018
2a9682b
Add missing labels; Use image with tag
domcar May 16, 2018
7df92c4
Implement suggestion
domcar Jun 4, 2018
6cd1fd9
Various updates
unguiculus Jun 7, 2018
d6bb35b
Merge remote-tracking branch 'upstream/master' into feature/ark
unguiculus Jun 11, 2018
6901ca2
Add missing if block around delete hook
unguiculus Jun 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions incubator/ark-server/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
10 changes: 10 additions & 0 deletions incubator/ark-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for ark-server
name: ark-server
version: 0.7.0
sources:
- https://github.com/heptio/ark
maintainers:
- name: domcar
email: d-caruso@hotmail.it
46 changes: 46 additions & 0 deletions incubator/ark-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Ark-server

This helm chart install ark-server version v0.7.0

## Premise
Helm cannot handle properly CRD becauses it has a validation mechanism that checks the installation before the CRD are actually created,
hence each resource that uses a CRD cannot be validated because the CRD doesn't exist yet!

The trick here is to create CRD via helm chart, and only after (using a `post-install`) to install the resources with a container.
The container has the only job to execute a `kubectl create -f filename` and create the resources.

At the same time the resources created with the hook are completely transparent to Helm, that is, when you delete the
chart those resources remain there. Hence we need a sencond hook for deleting them (see delete.yaml)

## Content
- `templates/prerequisites.yaml` this file contains the CRD and SA needed by Ark Server
- `hook.yaml` This is the container that will deploy or delete ark-server and its configuration
it creates also the necessary SA and RBAC
- `configmap.yaml` Configmap will be mounted to the hook container as a file and subsequently used as k8s manifest for deploy or deletion

## ConfigMap customization
Since we want to have a customizable chart it's important that the configmap is a template and not a static file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why don't you put it into the templates folder directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I answered you in another comment:

For the reason I explained in the Premise Helm cannot handle properly CRD becauses it has a validation mechanism that checks the installation before the CRD are actually created, hence each resource that uses a CRD cannot be validated because the CRD doesn't exist yet!.

If you move the file in templates you get the error Error: apiVersion "ark.heptio.com/v1" in ark-server/templates/01-config-deploy.yaml is not available.

But I agree that the name static is not appropriate

To do this we add the keyword `tpl` when reading the file
- {{ (tpl (.Files.Glob "static/*").AsConfig .) | indent 2 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you just add it to the templates folder? It doesn't make sense to me to have it in a static folder when it is not static.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reason I explained in the Premise Helm cannot handle properly CRD becauses it has a validation mechanism that checks the installation before the CRD are actually created, hence each resource that uses a CRD cannot be validated because the CRD doesn't exist yet!.

If you move the file in templates you get the error Error: apiVersion "ark.heptio.com/v1" in ark-server/templates/01-config-deploy.yaml is not available.

But I agree that the name static is not appropriate



## Prerequisites

### Heptio Secret
Ark server needs a IAM service accoutn in order to run, if you don't have it you must create it:
https://github.com/heptio/ark/blob/v0.6.0/docs/cloud-provider-specifics.md#gcp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.7.0



And then
```
kubectl create secret generic cloud-credentials --namespace heptio-ark --from-file cloud=credentials-ark
```

### Bucket and Project name
Please change bucket and project/region name in the values.yaml file
See here for possible values: https://github.com/heptio/ark/blob/v0.6.0/docs/cloud-provider-specifics.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.7.0


## How to
```
helm install --name ark-server --namespace heptio-ark ./ark-server
```
62 changes: 62 additions & 0 deletions incubator/ark-server/static/01-config-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
apiVersion: ark.heptio.com/v1
kind: Config
metadata:
namespace: {{ .Values.namespace.name }}
name: default
persistentVolumeProvider:
name: {{ required "PLEASE SET VALUE" .Values.configuration.cloudprovider }}
config:
{{- if eq .Values.configuration.cloudprovider "gcp" }}
project: {{ required "PLEASE SET VALUE" .Values.configuration.project }}
{{- else if eq .Values.configuration.cloudprovider "aws" }}
region: {{ required "PLEASE SET VALUE" .Values.configuration.region }}
{{- end }}
backupStorageProvider:
name: {{ required "PLEASE SET VALUE" .Values.configuration.cloudprovider }}
bucket: {{ required "PLEASE SET VALUE" .Values.configuration.bucket }}
{{- if eq .Values.configuration.cloudprovider "aws" }}
config:
region: {{ required "PLEASE SET VALUE" .Values.configuration.region }}
{{- end }}
backupSyncPeriod: {{ .Values.configuration.backupSyncPeriod }}
gcSyncPeriod: {{ .Values.configuration.gcSyncPeriod }}
scheduleSyncPeriod: {{ .Values.configuration.scheduleSyncPeriod }}
restoreOnlyMode: {{ .Values.configuration.restoreOnlyMode }}

---
apiVersion: apps/v1beta1
kind: Deployment
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this not in templates?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to templates

metadata:
namespace: {{ .Values.namespace.name }}
name: ark
spec:
replicas: 1
template:
metadata:
labels:
component: ark
spec:
restartPolicy: Always
serviceAccountName: ark
containers:
- name: ark
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command:
- /ark
args:
- server
volumeMounts:
- name: cloud-credentials
mountPath: /credentials
- name: plugins
mountPath: /plugins
env:
- name: {{ required "PLEASE CHANGE VALUE" .Values.configuration.credentials }}
value: /credentials/cloud
volumes:
- name: cloud-credentials
secret:
secretName: {{ .Values.secret.name }}
- name: plugins
emptyDir: {}
11 changes: 11 additions & 0 deletions incubator/ark-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Check that the ark-server is up and running:
kubectl get pod --namespace {{ .Values.namespace.name }}

Check that the secret has been created:
kubectl get secret --namespace {{ .Values.namespace.name }} {{ .Values.secret.name }}

Once ark server is up and running you need the client before you can use it
1. wget https://github.com/heptio/ark/releases/download/{{ .Values.image.tag }}/ark-{{ .Values.image.tag }}-darwin-amd64.tar.gz
2. tar -xvf ark-{{ .Values.image.tag }}-darwin-amd64.tar.gz -C ark-client

More info on the official site: https://github.com/heptio/ark#install-client
43 changes: 43 additions & 0 deletions incubator/ark-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "ark-server.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 "ark-server.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 "ark-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account to use for deploying or deleting
*/}}
{{- define "ark-server.hookSA" -}}
{{- if .Values.serviceAccount.hook.create -}}
{{ default (include "ark-server.fullname" .) .Values.serviceAccount.hook.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.hook.name }}
{{- end -}}
{{- end -}}
7 changes: 7 additions & 0 deletions incubator/ark-server/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: ark-server-config
namespace: {{ .Values.namespace.name }}
data:
{{ (tpl (.Files.Glob "static/*").AsConfig .) | indent 2 }}
115 changes: 115 additions & 0 deletions incubator/ark-server/templates/hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
apiVersion: batch/v1
kind: Job
metadata:
name: deploy-ark
namespace: {{ .Values.namespace.name }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: deploy-ark
namespace: {{ .Values.namespace.name }}
spec:
restartPolicy: Never
containers:
- name: deploy-ark
image: claranet/gcloud-kubectl-docker
imagePullPolicy: Always
command: ["kubectl","create","-f","/tmp/"]
volumeMounts:
- name: ark-server-config
mountPath: /tmp
volumes:
- name: ark-server-config
configMap:
name: ark-server-config
serviceAccountName: {{ template "ark-server.hookSA" . }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: delete-ark
namespace: {{ .Values.namespace.name }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: delete-ark
namespace: {{ .Values.namespace.name }}
spec:
restartPolicy: Never
containers:
- name: delete-ark
image: claranet/gcloud-kubectl-docker
imagePullPolicy: Always
command: ["kubectl","delete","-f","/tmp/"]
volumeMounts:
- name: ark-server-config
mountPath: /tmp
volumes:
- name: ark-server-config
configMap:
name: ark-server-config
serviceAccountName: {{ template "ark-server.hookSA" . }}

{{- if .Values.serviceAccount.hook.create }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "ark-server.hookSA" . }}
namespace: {{ .Values.namespace.name }}
labels:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
app: {{ template "ark-server.name" . }}
{{- end }}

{{- if .Values.rbac.create }}
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
labels:
kubernetes.io/bootstrapping: rbac-defaults
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
app: {{ template "ark-server.name" . }}
name: deploy-ark
rules:
- apiGroups: ['']
resources: ['pods','deployments']
verbs: ['*']
- apiGroups: ['extensions','apps']
resources: ['deployments','replicasets']
verbs: ['*']
- apiGroups: ['ark.heptio.com']
verbs: ["*"]
resources: ["*"]
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: deploy-ark
labels:
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
app: {{ template "ark-server.name" . }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: deploy-ark
subjects:
- kind: ServiceAccount
name: {{ template "ark-server.hookSA" . }}
namespace: {{ .Values.namespace.name }}
{{- end }}
Loading