Skip to content

Commit 4d091f9

Browse files
jmo808alexellis
authored andcommitted
Add k8s imagePullSecret to namespace service account
Signed-off-by: Jules Ouellette <[email protected]>
1 parent 001bf97 commit 4d091f9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/deployment/kubernetes.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,34 @@ This is a `stack.yml` example with the secret added in it:
271271
272272
You can deploy your function using `faas-cli deploy`. If you inspect the Kubernetes pods, you will see that it can pull the docker image.
273273
274+
#### Link the image pull secret to a namespace service account
275+
276+
Instead of always editing the function .yml you can link your private Docker repository secret to the Kubernetes namespace service account manifest. This will auto add the `imagePullSecret` property to any deployment/pod manifest refrencing an image in that particular private repo.
277+
278+
Create the image pull secret in the `openfaas-fn` namespace:
279+
280+
```bash
281+
$ kubectl create secret docker-registry myPrivateRepo \
282+
--docker-username=$DOCKER_USERNAME \
283+
--docker-password=$DOCKER_PASSWORD \
284+
--docker-email=$DOCKER_EMAIL \
285+
--namespace openfaas-fn
286+
```
287+
288+
Open up the service account manifest for editing:
289+
290+
`kubectl edit serviceaccount default -n openfaas-fn`
291+
292+
At the bottom of the manifest add:
293+
294+
``` yaml
295+
imagePullSecrets:
296+
- name: myPrivateRepo
297+
```
298+
299+
Save your changes.
300+
OpenFaaS will now deploy functions with images in private repositories without having to specify the secret in the deployment manifests.
301+
274302
## 3.1 Start the hands-on labs
275303
276304
Learn how to build serverless functions with OpenFaaS and Python in our half-day workshop. You can follow along online at your own pace.

0 commit comments

Comments
 (0)