Skip to content

Commit c359f44

Browse files
authored
Change custom templates to Helm charts (#445)
1 parent ec8ed8e commit c359f44

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1942
-1334
lines changed

Makefile

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@ DOCKERFILE := Dockerfile
3131
DOCKERTESTFILE := Dockerfile.test
3232
DOCKERDURATIONTESTFILE := tests/duration/Dockerfile
3333

34+
HELM_CMD = $(HELM) template "$(ROOTDIR)/chart/$(CHART_NAME)" \
35+
--name "$(NAME)" \
36+
--set "operator.image=$(OPERATORIMAGE)" \
37+
--set "operator.imagePullPolicy=Always" \
38+
--namespace "$(DEPLOYMENTNAMESPACE)"
39+
3440
ifndef LOCALONLY
3541
PUSHIMAGES := 1
36-
IMAGESHA256 := true
37-
else
38-
IMAGESHA256 := false
3942
endif
4043

4144
ifdef IMAGETAG
@@ -197,15 +200,62 @@ endif
197200

198201
# Manifests
199202

203+
.PHONY: manifests-crd
204+
manifests-crd: export CHART_NAME := kube-arangodb-crd
205+
manifests-crd: export NAME := crd
206+
manifests-crd:
207+
@echo Building manifests for CRD - $(MANIFESTPATHCRD)
208+
@$(HELM_CMD) > "$(MANIFESTPATHCRD)"
209+
210+
.PHONY: manifests-test
211+
manifests-test: export CHART_NAME := kube-arangodb-test
212+
manifests-test: export NAME := arangodb-test
213+
manifests-test:
214+
@echo Building manifests for test - $(MANIFESTPATHTEST)
215+
@$(HELM_CMD) > "$(MANIFESTPATHTEST)"
216+
217+
.PHONY: manifests-operator-deployment
218+
manifests-operator-deployment: export CHART_NAME := kube-arangodb
219+
manifests-operator-deployment: export NAME := deployment
220+
manifests-operator-deployment:
221+
@echo Building manifests for Operator Deployment - $(MANIFESTPATHDEPLOYMENT)
222+
@$(HELM_CMD) \
223+
--set "rbac.scope=ClusterRole" \
224+
--set "operator.features.deployment=true" \
225+
--set "operator.features.deploymentReplications=false" \
226+
--set "operator.features.storage=false"> "$(MANIFESTPATHDEPLOYMENT)"
227+
228+
.PHONY: manifests-operator-deployment-replication
229+
manifests-operator-deployment-replication: export CHART_NAME := kube-arangodb
230+
manifests-operator-deployment-replication: export NAME := deployment-replication
231+
manifests-operator-deployment-replication:
232+
@echo Building manifests for Operator Deployment Replication - $(MANIFESTPATHDEPLOYMENTREPLICATION)
233+
@$(HELM_CMD) \
234+
--set "rbac.scope=ClusterRole" \
235+
--set "operator.features.deployment=false" \
236+
--set "operator.features.deploymentReplications=true" \
237+
--set "operator.features.storage=false"> "$(MANIFESTPATHDEPLOYMENTREPLICATION)"
238+
239+
.PHONY: manifests-operator-storage
240+
manifests-operator-storage: export CHART_NAME := kube-arangodb
241+
manifests-operator-storage: export NAME := storage
242+
manifests-operator-storage:
243+
@echo Building manifests for Operator Storage - $(MANIFESTPATHSTORAGE)
244+
@$(HELM_CMD) \
245+
--set "rbac.scope=ClusterRole" \
246+
--set "operator.features.deployment=false" \
247+
--set "operator.features.deploymentReplications=false" \
248+
--set "operator.features.storage=true"> "$(MANIFESTPATHSTORAGE)"
249+
250+
.PHONY: manifests-operator
251+
manifests-operator: manifests-operator-deployment manifests-operator-deployment-replication manifests-operator-storage
252+
200253
.PHONY: manifests
201-
manifests: $(GOBUILDDIR)
202-
@echo Building manifests
203-
GOPATH=$(GOBUILDDIR) go run $(ROOTDIR)/tools/manifests/manifest_builder.go \
204-
--output-suffix=$(MANIFESTSUFFIX) \
205-
--image=$(OPERATORIMAGE) \
206-
--image-sha256=$(IMAGESHA256) \
207-
--namespace=$(DEPLOYMENTNAMESPACE) \
208-
--allow-chaos=$(ALLOWCHAOS)
254+
manifests: manifests-crd manifests-operator manifests-test
255+
@mkdir -p "$(ROOTDIR)/bin/charts"
256+
@$(HELM) package "$(ROOTDIR)/chart/kube-arangodb" -d "$(ROOTDIR)/bin/charts" --save=false
257+
@$(HELM) package "$(ROOTDIR)/chart/kube-arangodb-crd" -d "$(ROOTDIR)/bin/charts" --save=false
258+
209259

210260
# Testing
211261

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/
9191
# The following will install the operator for `ArangoDeployment` &
9292
# `ArangoDeploymentReplication` resources.
9393
helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/kube-arangodb.tgz
94-
# To use `ArangoLocalStorage`, also run
95-
helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/kube-arangodb-storage.tgz
94+
# To use `ArangoLocalStorage`, set field `operator.features.storage` to true
95+
helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/kube-arangodb.tgz --set "operator.features.storage=true"
9696
```
9797

9898
## Upgrading the operator using Helm
@@ -111,15 +111,13 @@ list` output:
111111
```
112112
% helm list
113113
NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE
114-
intent-camel 1 Mon Apr 8 11:37:52 2019 DEPLOYED kube-arangodb-storage-0.3.10-preview default
115114
steely-mule 1 Sun Mar 31 21:11:07 2019 DEPLOYED kube-arangodb-crd-0.3.9 default
116115
vetoed-ladybird 1 Mon Apr 8 11:36:58 2019 DEPLOYED kube-arangodb-0.3.10-preview default
117116
```
118117

119118
So here, you would have to do
120119

121120
```bash
122-
helm delete intent-camel
123121
helm delete vetoed-ladybird
124122
```
125123

@@ -130,8 +128,8 @@ with `helm install` as normal:
130128
# The following will install the operator for `ArangoDeployment` &
131129
# `ArangoDeploymentReplication` resources.
132130
helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/kube-arangodb.tgz
133-
# To use `ArangoLocalStorage`, also run
134-
helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/kube-arangodb-storage.tgz
131+
# To use `ArangoLocalStorage`, set field `operator.features.storage` to true
132+
helm install https://github.com/arangodb/kube-arangodb/releases/download/0.3.14/kube-arangodb.tgz --set "operator.features.storage=true"
135133
```
136134

137135
## Building

chart/kube-arangodb-crd/Chart.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
name: kube-arangodb-crd
4+
version: 1.0.0
5+
6+
description: "ArangoDB Kubernetes Custom Resource Definitions"
7+
tillerVersion: ">2.7"
8+
9+
appVersion: 3.5.0

chart/kube-arangodb-crd/LICENSE

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Copyright 2018 ArangoDB GmbH, Cologne, Germany
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
15+
Copyright holder is ArangoDB GmbH, Cologne, Germany
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Expand the name of the chart.
5+
*/}}
6+
{{- define "kube-arangodb-crd.name" -}}
7+
{{- printf "%s" .Chart.Name | trunc 63 | trimSuffix "-" -}}
8+
{{- end -}}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: arangodeploymentreplications.replication.database.arangodb.com
5+
labels:
6+
app.kubernetes.io/name: {{ template "kube-arangodb-crd.name" . }}
7+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
release: {{ .Release.Name }}
11+
spec:
12+
group: replication.database.arangodb.com
13+
names:
14+
kind: ArangoDeploymentReplication
15+
listKind: ArangoDeploymentReplicationList
16+
plural: arangodeploymentreplications
17+
shortNames:
18+
- arangorepl
19+
singular: arangodeploymentreplication
20+
scope: Namespaced
21+
version: v1alpha
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: arangodeployments.database.arangodb.com
5+
labels:
6+
app.kubernetes.io/name: {{ template "kube-arangodb-crd.name" . }}
7+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
8+
app.kubernetes.io/managed-by: {{ .Release.Service }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
release: {{ .Release.Name }}
11+
spec:
12+
group: database.arangodb.com
13+
names:
14+
kind: ArangoDeployment
15+
listKind: ArangoDeploymentList
16+
plural: arangodeployments
17+
shortNames:
18+
- arangodb
19+
- arango
20+
singular: arangodeployment
21+
scope: Namespaced
22+
version: v1alpha
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
3+
name: kube-arangodb-test
4+
version: 1.0.0
5+
6+
description: "ArangoDB Kubernetes Test Access"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{/* vim: set filetype=mustache: */}}
2+
3+
{{/*
4+
Expand the name of the chart.
5+
*/}}
6+
{{- define "kube-arangodb-test.name" -}}
7+
{{- printf "%s" .Chart.Name | trunc 63 | trimSuffix "-" -}}
8+
{{- end -}}
9+
10+
{{/*
11+
Expand the name of the release.
12+
*/}}
13+
{{- define "kube-arangodb-test.releaseName" -}}
14+
{{- printf "%s" .Release.Name | trunc 63 | trimSuffix "-" -}}
15+
{{- end -}}
16+
17+
{{/*
18+
Combine name of the deployment.
19+
*/}}
20+
{{- define "kube-arangodb-test.fullName" -}}
21+
{{- printf "%s-%s" .Chart.Name .Release.Name | trunc 63 | trimSuffix "-" -}}
22+
{{- end -}}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRoleBinding
3+
metadata:
4+
name: {{ template "kube-arangodb-test.fullName" . }}
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
app.kubernetes.io/name: {{ template "kube-arangodb-test.name" . }}
8+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
9+
app.kubernetes.io/managed-by: {{ .Release.Service }}
10+
app.kubernetes.io/instance: {{ .Release.Name }}
11+
release: {{ .Release.Name }}
12+
roleRef:
13+
apiGroup: rbac.authorization.k8s.io
14+
kind: ClusterRole
15+
name: cluster-admin
16+
subjects:
17+
- kind: ServiceAccount
18+
name: {{ template "kube-arangodb-test.releaseName" . }}
19+
namespace: {{ .Release.Namespace }}

0 commit comments

Comments
 (0)