Skip to content

Commit aec305f

Browse files
authored
Merge pull request #134 from schinmai-akamai/master
Allow passing linodeApitoken and region as secretRef
2 parents 0427d17 + c0ef7a6 commit aec305f

File tree

5 files changed

+52
-9
lines changed

5 files changed

+52
-9
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ jobs:
1616
run: make docker-build
1717
- name: unit test
1818
run: make test
19+
- name: helm lint
20+
run: make helm-lint
21+
- name: helm template
22+
run: make helm-template

Makefile

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,33 @@ run-debug: build
7474
--stderrthreshold=INFO \
7575
--kubeconfig=${KUBECONFIG} \
7676
--linodego-debug
77-
78-
77+
# Set the host's OS. Only linux and darwin supported for now
78+
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
79+
ifeq ($(filter darwin linux,$(HOSTOS)),)
80+
$(error build only supported on linux and darwin host currently)
81+
endif
82+
83+
HELM_VERSION ?= v3.9.1
84+
TOOLS_HOST_DIR ?= .tmp/tools
85+
HELM := $(TOOLS_HOST_DIR)/helm-$(HELM_VERSION)
86+
87+
.PHONY: $(HELM)
88+
$(HELM):
89+
@echo installing helm $(HELM_VERSION)
90+
@mkdir -p $(TOOLS_HOST_DIR)/tmp-helm
91+
@curl -fsSL https://get.helm.sh/helm-$(HELM_VERSION)-$(HOSTOS)-amd64.tar.gz | tar -xz -C $(TOOLS_HOST_DIR)/tmp-helm
92+
@mv $(TOOLS_HOST_DIR)/tmp-helm/$(HOSTOS)-amd64/helm $(HELM)
93+
@rm -fr $(TOOLS_HOST_DIR)/tmp-helm
94+
@echo installing helm $(HELM_VERSION)
95+
96+
.PHONY: helm-lint
97+
helm-lint: $(HELM)
98+
#Verify lint works when region and apiToken are passed, and when it is passed as reference.
99+
@$(HELM) lint deploy/chart --set apiToken="apiToken",region="us-east"
100+
@$(HELM) lint deploy/chart --set secretRef.apiTokenRef="apiToken",secretRef.name="api",secretRef.regionRef="us-east"
101+
102+
.PHONY: helm-template
103+
helm-template: $(HELM)
104+
#Verify template works when region and apiToken are passed, and when it is passed as reference.
105+
@$(HELM) template foo deploy/chart --set apiToken="apiToken",region="us-east" > /dev/null
106+
@$(HELM) template foo deploy/chart --set secretRef.apiTokenRef="apiToken",secretRef.name="api",secretRef.regionRef="us-east" > /dev/null

deploy/chart/templates/ccm-linode.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if not .Values.secretRef }}
12
apiVersion: v1
23
kind: Secret
34
metadata:
@@ -7,3 +8,5 @@ stringData:
78
apiToken: {{ required ".Values.apiToken required" .Values.apiToken }}
89
region: {{ required ".Values.region required" .Values.region }}
910
type: Opaque
11+
{{- end }}
12+

deploy/chart/templates/daemonset.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ spec:
4040
- name: LINODE_API_TOKEN
4141
valueFrom:
4242
secretKeyRef:
43-
name: ccm-linode
44-
key: apiToken
43+
name: {{ if .Values.secretRef }}{{ .Values.secretRef.name | default "ccm-linode" }}{{ else }}"ccm-linode"{{ end }}
44+
key: {{ if .Values.secretRef }}{{ .Values.secretRef.apiTokenRef | default "apiToken" }}{{ else }}"apiToken"{{ end }}
4545
- name: LINODE_REGION
4646
valueFrom:
4747
secretKeyRef:
48-
name: ccm-linode
49-
key: region
48+
name: {{ if .Values.secretRef }}{{ .Values.secretRef.name | default "ccm-linode" }}{{ else }}"ccm-linode"{{ end }}
49+
key: {{ if .Values.secretRef }}{{ .Values.secretRef.regionRef | default "region" }}{{ else }}"region"{{ end }}
50+
{{if .Values.env}}
5051
{{- toYaml .Values.env | nindent 12 }}
52+
{{end}}
5153
volumes:
5254
- name: k8s
5355
hostPath:
54-
path: /etc/kubernetes
56+
path: /etc/kubernetes

deploy/chart/values.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
# apiToken [Required] - Must be a Linode APIv4 Personal Access Token with all permissions. (https://cloud.linode.com/profile/tokens)
1+
# apiToken [Required if secretRef is not set] - Must be a Linode APIv4 Personal Access Token with all permissions. (https://cloud.linode.com/profile/tokens)
22
apiToken: ""
33

4-
# region [Required] - Must be a Linode region. (https://api.linode.com/v4/regions)
4+
# region [Required if secretRef is not set] - Must be a Linode region. (https://api.linode.com/v4/regions)
55
region: ""
66

7+
# Set these values if your APIToken and region are already present in a k8s secret.
8+
# secretRef:
9+
# name: "linode-ccm"
10+
# apiTokenRef: "apiToken"
11+
# regionRef: "region"
12+
713
# node-role.kubernetes.io/master - if set true, it deploys the svc on the master node
814
nodeSelector:
915
# The CCM will only run on a Node labelled as a master, you may want to change this

0 commit comments

Comments
 (0)