Skip to content

Commit 53789db

Browse files
authored
Merge pull request #112 from komer3/adding-helm-chart
Create a Helm Chart
2 parents 6073fa5 + fd6ed61 commit 53789db

12 files changed

Lines changed: 284 additions & 0 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ coverage.txt
3636
*.coverprofile
3737

3838
junit.xml
39+
40+
.DS_Store

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,49 @@ This will create a file `ccm-linode.yaml` which you can use to deploy the CCM.
194194

195195
Note: Your kubelets, controller-manager, and apiserver must be started with `--cloud-provider=external` as noted in the following documentation.
196196

197+
## Deployment Through Helm Chart
198+
199+
Use the helm chart located under './deploy/chart'. This dir has the manifest for Linode CCM. There are two arguments required.
200+
201+
The first argument must be a Linode APIv4 [Personal Access Token](https://cloud.linode.com/profile/tokens) with all permissions.
202+
203+
The second argument must be a Linode [region](https://api.linode.com/v4/regions).
204+
205+
### To deploy CCM run the following helm command once you are in the ccm root dir:
206+
```sh
207+
git clone https://github.com/linode/linode-cloud-controller-manager.git
208+
209+
cd linode-cloud-controller-manager
210+
211+
helm install linode-ccm ./deploy/chart --set apiToken=$LINODE_API_TOKEN,region=$REGION
212+
```
213+
_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._
214+
215+
### To uninstall linode-ccm from kubernetes cluster. Run the following command:
216+
```sh
217+
218+
helm uninstall linode-ccm
219+
220+
```
221+
_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._
222+
223+
### To upgrade when new changes are made to the helm chart. Run the following command:
224+
```sh
225+
226+
helm upgrade linode-ccm ./deploy/chart --install
227+
228+
```
229+
_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._
230+
231+
### Configurations
232+
233+
There are other variables that can be set to a different value. For list of all the modifiable variables/values, take a look at './deploy/chart/values.yaml'.
234+
235+
Values can be set/overrided by using the '--set var=value,...' flag or by passing in a custom-values.yaml using '-f custom-values.yaml'.
236+
237+
Recommendation: Use custom-values.yaml to override the variables to avoid any errors with template rendering
238+
239+
197240
### Upstream Documentation Including Deployment Instructions
198241

199242
[Kubernetes Cloud Controller Manager](https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/).

deploy/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
ccm-linode.yaml
2+
.DS_Store

deploy/chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

deploy/chart/Chart.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
apiVersion: v2
2+
name: ccm-linode
3+
description: The Linode Cloud Controller Manager (CCM) provides a way for Kubernetes clusters to access additional Linode services. Linode's CCM will automatically provision a Linode NodeBalancer for Kubernetes Services of type "LoadBalancer".
4+
type: application
5+
version: 1.0.0
6+
appVersion: "v0.3.16"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "chart.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "chart.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "chart.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "chart.labels" -}}
37+
helm.sh/chart: {{ include "chart.chart" . }}
38+
{{ include "chart.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "chart.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "chart.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "chart.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "chart.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: ccm-linode
5+
namespace: {{ required ".Values.namespace required" .Values.namespace }}
6+
stringData:
7+
apiToken: {{ required ".Values.apiToken required" .Values.apiToken }}
8+
region: {{ required ".Values.region required" .Values.region }}
9+
type: Opaque
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
name: ccm-linode-clusterrole
5+
rules:
6+
- apiGroups: [""]
7+
resources: ["endpoints"]
8+
verbs: ["get", "watch", "list", "update", "create"]
9+
- apiGroups: [""]
10+
resources: ["nodes"]
11+
verbs: ["get", "watch", "list", "update", "delete", "patch"]
12+
- apiGroups: [""]
13+
resources: ["nodes/status"]
14+
verbs: ["get", "watch", "list", "update", "delete", "patch"]
15+
- apiGroups: [""]
16+
resources: ["events"]
17+
verbs: ["get", "watch", "list", "update", "create", "patch"]
18+
- apiGroups: [""]
19+
resources: ["persistentvolumes"]
20+
verbs: ["get", "watch", "list", "update"]
21+
- apiGroups: [""]
22+
resources: ["secrets"]
23+
verbs: ["get"]
24+
- apiGroups: [""]
25+
resources: ["services"]
26+
verbs: ["get", "watch", "list"]
27+
- apiGroups: [""]
28+
resources: ["services/status"]
29+
verbs: ["get", "watch", "list", "update", "patch"]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: ClusterRoleBinding
2+
apiVersion: rbac.authorization.k8s.io/v1
3+
metadata:
4+
name: ccm-linode-clusterrolebinding
5+
roleRef:
6+
apiGroup: rbac.authorization.k8s.io
7+
kind: ClusterRole
8+
name: ccm-linode-clusterrole
9+
subjects:
10+
- kind: ServiceAccount
11+
name: ccm-linode
12+
namespace: {{ required ".Values.namespace required" .Values.namespace }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: apps/v1
2+
kind: DaemonSet
3+
metadata:
4+
name: ccm-linode
5+
labels:
6+
app: ccm-linode
7+
namespace: {{ required ".Values.namespace required" .Values.namespace }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
app: ccm-linode
12+
template:
13+
metadata:
14+
labels:
15+
app: ccm-linode
16+
spec:
17+
serviceAccountName: ccm-linode
18+
{{- if .Values.nodeSelector }}
19+
nodeSelector:
20+
{{ toYaml .Values.nodeSelector | indent 8 }}
21+
{{- end }}
22+
{{- if .Values.tolerations }}
23+
tolerations:
24+
{{ toYaml .Values.tolerations | indent 8 }}
25+
{{- end }}
26+
hostNetwork: true
27+
containers:
28+
- image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
29+
imagePullPolicy: {{ .Values.image.pullPolicy }}
30+
name: ccm-linode
31+
args:
32+
- --leader-elect-resource-lock=endpoints
33+
- --v=3
34+
- --port=0
35+
- --secure-port=10253
36+
volumeMounts:
37+
- mountPath: /etc/kubernetes
38+
name: k8s
39+
env:
40+
- name: LINODE_API_TOKEN
41+
valueFrom:
42+
secretKeyRef:
43+
name: ccm-linode
44+
key: apiToken
45+
- name: LINODE_REGION
46+
valueFrom:
47+
secretKeyRef:
48+
name: ccm-linode
49+
key: region
50+
volumes:
51+
- name: k8s
52+
hostPath:
53+
path: /etc/kubernetes

0 commit comments

Comments
 (0)