Skip to main content

Helm alternative

Picture of Maciej Olesiński, null

Maciej Olesiński

Nov 2, 2018|5 min read
Helm alternative
Image Alt

Image Alt

1find . -type f -not -name kube2iam.yaml.tmpl -not -name NOTES.txt -not -name _helpers.tpl -exec echo "---" \; -exec cat {} \; > kube2iam.yaml.tmpl
1sed -i '/.Chart/d' ./kube2iam.yaml.tmpl
2sed -i '/.Release/d' ./kube2iam.yaml.tmpl
1sed -e 's/.Values//g' -i ./kube2iam.yaml.tmpl
1---
2{{- if .rbac.create -}}
3apiVersion: v1
4kind: ServiceAccount
5metadata:
6 labels:
7 app: {{ .Name }}
8 name: {{ .FullName }}
9{{- end -}}
10---
11{{- if .rbac.create -}}
12apiVersion: rbac.authorization.k8s.io/v1beta1
13kind: ClusterRoleBinding
14metadata:
15 labels:
16 app: {{ .Name }}
17 name: {{ .FullName }}
18roleRef:
19 apiGroup: rbac.authorization.k8s.io
20 kind: ClusterRole
21 name: {{ .FullName }}
22subjects:
23 - kind: ServiceAccount
24 name: {{ .FullName }}
25{{- end -}}
26---
27{{- if .rbac.create -}}
28apiVersion: rbac.authorization.k8s.io/v1beta1
29kind: ClusterRole
30metadata:
31 labels:
32 app: {{ .Name }}
33 name: {{ .FullName }}
34rules:
35 - apiGroups:
36 - ""
37 resources:
38 - namespaces
39 - pods
40 verbs:
41 - list
42 - watch
43{{- end -}}
44---
45apiVersion: extensions/v1beta1
46kind: DaemonSet
47metadata:
48 labels:
49 app: {{ .Name }}
50 name: {{ .FullName }}
51spec:
52 template:
53 metadata:
54 {{- if .podAnnotations }}
55 annotations:
56{{ toYaml .podAnnotations | indent 8 }}
57 {{- end }}
58 labels:
59 app: {{ .Name }}
60 {{- if .podLabels }}
61{{ toYaml .podLabels | indent 8 }}
62 {{- end }}
63 spec:
64 containers:
65 - name: kube2iam
66 image: "{{ .image.repository }}:{{ .image.tag }}"
67 imagePullPolicy: "{{ .image.pullPolicy }}"
68 args:
69 - --host-interface={{ .host.interface }}
70 {{- if .host.iptables }}
71 - --host-ip={{ .host.ip }}
72 {{- end }}
73 - --iptables={{ .host.iptables }}
74 {{- range $key, $value := .extraArgs }}
75 {{- if $value }}
76 - --{{ $key }}={{ $value }}
77 {{- else }}
78 - --{{ $key }}
79 {{- end }}
80 {{- end }}
81 {{- if .verbose }}
82 - --verbose
83 {{- end }}
84 - --app-port={{ .host.port }}
85 env:
86 - name: HOST_IP
87 valueFrom:
88 fieldRef:
89 fieldPath: status.podIP
90 {{- if and .aws.secret_key .aws.access_key }}
91 - name: AWS_ACCESS_KEY_ID
92 valueFrom:
93 secretKeyRef:
94 name: {{ .FullName }}
95 key: aws_access_key_id
96 - name: AWS_SECRET_ACCESS_KEY
97 valueFrom:
98 secretKeyRef:
99 name: {{ .FullName }}
100 key: aws_secret_access_key
101 {{- end }}
102 {{- if .aws.region }}
103 - name: AWS_DEFAULT_REGION
104 value: {{ .aws.region }}
105 {{- end }}
106 {{- range $name, $value := .extraEnv }}
107 - name: {{ $name }}
108 value: {{ quote $value }}
109 {{- end }}
110 ports:
111 - containerPort: {{ .host.port }}
112 {{- if .probe }}
113 livenessProbe:
114 httpGet:
115 path: /healthz
116 port: {{ .host.port }}
117 scheme: HTTP
118 initialDelaySeconds: 30
119 periodSeconds: 5
120 successThreshold: 1
121 failureThreshold: 3
122 timeoutSeconds: 1
123 {{- end }}
124 resources:
125{{ toYaml .resources | indent 12 }}
126 {{- if .host.iptables }}
127 securityContext:
128 privileged: true
129 {{- end }}
130 hostNetwork: true
131 {{- if .nodeSelector }}
132 nodeSelector:
133{{ toYaml .nodeSelector | indent 8 }}
134 {{- end }}
135 {{- if .affinity }}
136 affinity:
137{{ toYaml .affinity | indent 8 }}
138 {{- end }}
139 serviceAccountName: {{ if .rbac.create }}{{ .FullName }}{{ else }}"{{ .rbac.serviceAccountName }}"{{ end }}
140 tolerations:
141{{ toYaml .tolerations | indent 8 }}
142 updateStrategy:
143 type: {{ .updateStrategy }}
144---
145{{- if and .aws.secret_key .aws.access_key -}}
146apiVersion: v1
147kind: Secret
148metadata:
149 labels:
150 app: {{ .Name }}
151 name: {{ .FullName }}
152type: Opaque
153data:
154 aws_access_key_id: {{ .aws.access_key | b64enc | quote }}
155 aws_secret_access_key: {{ .aws.secret_key | b64enc | quote }}
156{{- end }}
1./render --in kube2iam.yaml.tmpl --config values.yaml --out kube2iam.yaml --set Name=kube2iam --set FullName=kube2iam_fullname
1kubectl -n kube-system apply -f kube2iam.yaml

Subscribe to our newsletter and never miss an article