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
Copy file name to clipboardExpand all lines: docs/tutorials/local-kind-registry.md
+35-30Lines changed: 35 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,21 @@
1
1
# Use a local registry with KinD
2
2
3
+
> Note: This feature is included for [OpenFaaS Standard & For Enterprises](https://openfaas.com/pricing/) customers.
4
+
3
5
Whilst a remote registry is the easiest way to get started when developing functions, a local registry can be faster for development and testing.
4
6
5
7
Using a local registry is an optimisation, which requires some additional tooling and configuration.
6
8
7
-
> Note: This feature is included for [OpenFaaS Standard & For Enterprises](https://openfaas.com/pricing/) customers.
9
+
You can also test your functions using Docker without deploying them to OpenFaaS via the `local-run` command, learn more: [The faster way to iterate on your OpenFaaS functions](https://www.openfaas.com/blog/develop-functions-locally).
10
+
11
+
12
+
You can find similar solutions for other local Kubernetes distributions:
13
+
14
+
*[k3d](https://k3d.io/v5.6.3/usage/registries/#using-a-local-registry) - local registries
You need to have **Docker** installed on your machine, arkade is also recommended for installing the necessary tools, however you can install them manually if you prefer.
12
21
@@ -46,6 +55,8 @@ These instructions are adapted from the KinD documentation. Our goal is to run K
46
55
47
56
The example below was copied from the [KinD documentation](https://kind.sigs.k8s.io/docs/user/local-registry/).
48
57
58
+
Save as `kind-with-registry.sh`:
59
+
49
60
```bash
50
61
#!/bin/sh
51
62
set -o errexit
@@ -117,35 +128,15 @@ EOF
117
128
118
129
---
119
130
120
-
### Note:
121
-
122
-
You can find similar solutions for other local Kubernetes distributions:
123
-
124
-
*[k3d](https://k3d.io/v5.4.4/usage/registries/#using-a-local-registry) - local registries
Alternatively, install [OpenFaaS Pro](https://docs.openfaas.com/deployment/pro/) with helm, creating the required `openfaas-license` secret, and setting `openfaasPro: true`.
178
-
179
172
Then log in and port-forward OpenFaaS using the instructions given, or run `arkade info openfaas` to get them a second time.
180
173
181
174
### Create a Function
@@ -193,7 +186,7 @@ We will be using the [python3-flask-debian](https://github.com/openfaas-incubato
193
186
Setup your `OPENFAAS_PREFIX` variable to configure the address of your registry:
194
187
195
188
```bash
196
-
export OPENFAAS_PREFIX=localhost:5000
189
+
export OPENFAAS_PREFIX=localhost:5001
197
190
```
198
191
199
192
> Note: Docker for Mac users may need to change "localhost" to the IP address of their LAN or WiFi adapter as shown on `ifconfig` such as `192.168.0.14`
@@ -212,8 +205,10 @@ This will create a directory for your function and a YAML config file with the f
212
205
213
206
Add dependency to the `pydict/requirements.txt` file:
214
207
215
-
```txt
208
+
```bash
209
+
cat <<EOF > pydict/requirements.txt
216
210
PyDictionary
211
+
EOF
217
212
```
218
213
219
214
Update `handler.py` with the following code.
@@ -231,7 +226,7 @@ Our minimal function is complete.
231
226
232
227
### Stack file
233
228
234
-
You will see that the OpenFaaS stack YAML file `pydict.yml` has `localhost:5000` in its image destination.
229
+
You will see that the OpenFaaS stack YAML file `pydict.yml` has `localhost:5001` in its image destination.
{"Noun":["a person who pleads for a cause or propounds an idea","a lawyer who pleads cases in court"],"Verb":["push for something","speak, plead, or argue in favor of"]}
264
259
```
265
260
261
+
## Watch for changes
262
+
263
+
You can also watch for changes in the function's source-code and automatically rebuild and deploy the function.
264
+
265
+
```bash
266
+
faas-cli up -f pydict.yml --watch --tag=digest
267
+
```
268
+
269
+
Now edit the source code for the function, and watch it get rebuilt and deployed automatically.
270
+
266
271
### Wrapping Up
267
272
268
273
Now that you have a local registry, you can speed up your local development of functions by keeping the container images within your local computer.
0 commit comments