You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- the openfaas-fn namespace is required but was missing from the
command to create secrets and resulted in a user raising an issue
Closes: openfaas/faas-netes#306
- language simplified and bespoke example replaced with a full
example created with the CLI
Signed-off-by: Alex Ellis (VMware) <[email protected]>
Copy file name to clipboardExpand all lines: docs/deployment/kubernetes.md
+30-58Lines changed: 30 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -210,46 +210,17 @@ This section covers additional advanced topics beyond the initial deployment.
210
210
If you are using a hosted private Docker registry ([Docker Hub](https://hub.docker.com/), or other),
211
211
in order to check how to configure it, please visit the Kubernetes [documentation](https://kubernetes.io/docs/concepts/containers/images/#using-a-private-registry).
212
212
213
-
##### Deploy a function from a private Docker image
213
+
If you try to deploy using `faas-cli deploy` it will fail because the Kubernetes kubelet component will not have credentials to authorize the pull request.
214
214
215
-
With the following commands you can deploy a function from a private Docker image, tag and push it to your docker registry account:
215
+
Once you have pushed an image to a private registry using `faas-cli push` follow the instructions below to either create a pull secret that can be referenced by each function which needs it, or create a secret for the ServiceAccount in the `openfaas-fn` namespace so that any functions which need it can make use of it.
216
216
217
-
```bash
218
-
$ docker pull functions/alpine:latest
219
-
$ docker tag functions/alpine:latest $DOCKER_USERNAME/private-alpine:latest
Log into the [Hub](https://hub.docker.com/) and make your image `private-alpine` private.
224
-
225
-
Then create your openfaas project:
226
-
227
-
```bash
228
-
$ mkdir privatefuncs && cd privatefuncs
229
-
$ touch stack.yaml
230
-
```
231
-
232
-
In your favorite editor, open stack.yaml and add
233
-
234
-
```yml
235
-
provider:
236
-
name: faas
237
-
gateway: http://127.0.0.1:8080
238
-
239
-
functions:
240
-
protectedapi:
241
-
lang: Dockerfile
242
-
skip_build: true
243
-
image: username/private-alpine:latest
244
-
```
217
+
If you need to troubleshoot the use of a private image then see the Kubernetes section of the [troubleshooting guide](./troubleshooting.md).
245
218
246
-
##### Create an image pull secret
219
+
##### Option 1 - use an ad-hoc image pull secret
247
220
248
-
If you try to deploy using `faas-cli deploy` it will fail because Kubernetes can not pull the image. You can verify this in the Kubernetes dashboard or via the CLI using the `kubectl describe` command.
221
+
To deploy your function(s) first you need to create an [Image Pull Secret](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/) with the commands below.
249
222
250
-
To deploy the function, you need to create an [Image Pull Secret](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/)
251
-
252
-
You should set the following environmental variables:
223
+
Setup some environmental variables:
253
224
254
225
```bash
255
226
export DOCKER_USERNAME=<your_docker_username>
@@ -261,41 +232,37 @@ Then run this command to create the secret:
Then you need to add the secret to your `stack.yml` file:
241
+
> Note if not using the Docker Hub you will also need to pass `--docker-server` and the address of your remote registry.
270
242
271
-
```yml
272
-
secrets:
273
-
- dockerhub
243
+
The secret *must* be created in the `openfaas-fn` namespace or the equivalent if you have customised this.
244
+
245
+
Create a sample function with a `--prefix` variable:
246
+
247
+
```sh
248
+
faas-cli new --lang go private-fn --prefix=registry:port/repo
249
+
mv private-fn.yml stack.yml
274
250
```
275
251
276
-
This is a `stack.yml` example with the secret added in it:
252
+
Update the `stack.yml` file and add a reference to the new secret:
277
253
278
254
```yml
279
-
provider:
280
-
name: faas
281
-
gateway: http://127.0.0.1:8080
282
-
283
-
functions:
284
-
protectedapi:
285
-
lang: Dockerfile
286
-
skip_build: true
287
-
image: username/private-alpine:latest
288
-
secrets:
255
+
secrets:
289
256
- dockerhub
290
257
```
291
258
292
-
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.
259
+
Now deploy the function using `faas-cli up`.
293
260
294
-
##### Link the image pull secret to a namespace service account
261
+
##### Option 2 - Link an image pull secret to the namespace's ServiceAccount
295
262
296
-
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.
263
+
Rather than specifying the pull secret for each functionthat needs it you can bind the secret to the namespace's ServiceAccount. With this option you do not need to update the `secrets:` section of the `stack.yml` file.
297
264
298
-
Create the image pull secret in the `openfaas-fn` namespace:
265
+
Create the image pull secret in the `openfaas-fn` namespace (or equivalent):
0 commit comments