@@ -121,3 +121,68 @@ Status: Downloaded newer image for alpine:latest
121
121
Hello
122
122
+ exit 0
123
123
```
124
+
125
+ ## Kubernetes
126
+
127
+ If you use kubernetes and would like to run your docker file directly on the kubernetes host, use the following script:
128
+
129
+ ```
130
+ # shellcheck shell=bash
131
+ # Bash script that calls docker as a client to the host daemon
132
+ # See documentation: https://www.windmill.dev/docs/advanced/docker
133
+ msg="${1:-world}"
134
+
135
+ IMAGE="docker/whalesay:latest"
136
+ COMMAND=(sh -c "cowsay $msg")
137
+
138
+ APISERVER=https://kubernetes.default.svc
139
+ SERVICEACCOUNT=/var/run/secrets/kubernetes.io/serviceaccount
140
+ NAMESPACE=$(cat ${SERVICEACCOUNT}/namespace)
141
+ TOKEN=$(cat ${SERVICEACCOUNT}/token)
142
+ CACERT=${SERVICEACCOUNT}/ca.crt
143
+
144
+ kubectl config set-cluster local --server="${APISERVER}" --certificate-authority="${CACERT}"
145
+ kubectl config set-credentials local --token="${TOKEN}"
146
+ kubectl config set-context local --cluster=local --user=local --namespace="${NAMESPACE}"
147
+ kubectl config use-context local
148
+
149
+ kubectl run task -it --rm --restart=Never --image="$IMAGE" -- "${COMMAND[@]}"
150
+ ```
151
+
152
+ and use the following additional privileges
153
+
154
+ ``` yaml
155
+ ---
156
+ apiVersion : rbac.authorization.k8s.io/v1
157
+ kind : Role
158
+ metadata :
159
+ namespace : windmill
160
+ name : pod-management
161
+ rules :
162
+ - apiGroups : ['']
163
+ resources : ['pods']
164
+ verbs : ['get', 'list', 'watch', 'create', 'update', 'patch', 'delete']
165
+ - apiGroups : ['']
166
+ resources : ['pods/log']
167
+ verbs : ['get', 'list', 'watch']
168
+ - apiGroups : ['']
169
+ resources : ['pods/attach']
170
+ verbs : ['get', 'list', 'watch', 'create', 'update', 'patch', 'delete']
171
+ - apiGroups : ['']
172
+ resources : ['events']
173
+ verbs : ['get', 'list', 'watch']
174
+ ---
175
+ apiVersion : rbac.authorization.k8s.io/v1
176
+ kind : RoleBinding
177
+ metadata :
178
+ name : pod-management
179
+ namespace : windmill
180
+ subjects :
181
+ - kind : ServiceAccount
182
+ name : windmill-chart
183
+ namespace : windmill
184
+ roleRef :
185
+ kind : Role
186
+ name : pod-management
187
+ apiGroup : rbac.authorization.k8s.io
188
+ ` ` `
0 commit comments