Skip to content

Commit 3100cc0

Browse files
committed
Clarify local registries as a commercial feature
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 1c6a9f0 commit 3100cc0

File tree

2 files changed

+43
-17
lines changed

2 files changed

+43
-17
lines changed

docs/reference/ssl/kubernetes-with-cert-manager.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ Caveats:
6060
--set controller.kind=DaemonSet
6161
```
6262

63-
Taken from tutorial: [Setup a private Docker registry with TLS on Kubernetes](https://github.com/alexellis/k8s-tls-registry)
64-
65-
6663
If you do not have a public IP for your Kubernetes cluster, then you can use the [inlets-operator](https://github.com/inlets/inlets-operator) to get a LoadBalancer for your local or private cluster, even behind NAT or a firewall.
6764

6865
### Install OpenFaaS

docs/tutorials/local-kind-registry.md

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Use a local registry with KinD
22

3-
A local registry can save on bandwidth costs and means your OpenFaaS functions don't leave your local computer when running `faas-cli up`
3+
Whilst a remote registry is the easiest way to get started when developing functions, a local registry can be faster for development and testing.
44

5-
Not only is it much quicker, but it's also simple to configure if you're using KinD.
5+
Using a local registry is an optimisation, which requires some additional tooling and configuration.
66

77
## Prerequisite:
88

9-
You need to have **Docker** installed on your machine.
9+
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.
1010

1111
### Install arkade
1212

@@ -48,31 +48,55 @@ The example below was copied from the [KinD documentation](https://kind.sigs.k8s
4848
#!/bin/sh
4949
set -o errexit
5050

51-
# create registry container unless it already exists
51+
# 1. Create registry container unless it already exists
5252
reg_name='kind-registry'
5353
reg_port='5001'
5454
if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then
5555
docker run \
56-
-d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \
56+
-d --restart=always -p "127.0.0.1:${reg_port}:5000" --network bridge --name "${reg_name}" \
5757
registry:2
5858
fi
5959

60-
# create a cluster with the local registry enabled in containerd
60+
# 2. Create kind cluster with containerd registry config dir enabled
61+
# TODO: kind will eventually enable this by default and this patch will
62+
# be unnecessary.
63+
#
64+
# See:
65+
# https://github.com/kubernetes-sigs/kind/issues/2875
66+
# https://github.com/containerd/containerd/blob/main/docs/cri/config.md#registry-configuration
67+
# See: https://github.com/containerd/containerd/blob/main/docs/hosts.md
6168
cat <<EOF | kind create cluster --config=-
6269
kind: Cluster
6370
apiVersion: kind.x-k8s.io/v1alpha4
6471
containerdConfigPatches:
6572
- |-
66-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
67-
endpoint = ["http://${reg_name}:5000"]
73+
[plugins."io.containerd.grpc.v1.cri".registry]
74+
config_path = "/etc/containerd/certs.d"
6875
EOF
6976

70-
# connect the registry to the cluster network if not already connected
77+
# 3. Add the registry config to the nodes
78+
#
79+
# This is necessary because localhost resolves to loopback addresses that are
80+
# network-namespace local.
81+
# In other words: localhost in the container is not localhost on the host.
82+
#
83+
# We want a consistent name that works from both ends, so we tell containerd to
84+
# alias localhost:${reg_port} to the registry container when pulling images
85+
REGISTRY_DIR="/etc/containerd/certs.d/localhost:${reg_port}"
86+
for node in $(kind get nodes); do
87+
docker exec "${node}" mkdir -p "${REGISTRY_DIR}"
88+
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml"
89+
[host."http://${reg_name}:5000"]
90+
EOF
91+
done
92+
93+
# 4. Connect the registry to the cluster network if not already connected
94+
# This allows kind to bootstrap the network but ensures they're on the same network
7195
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${reg_name}")" = 'null' ]; then
7296
docker network connect "kind" "${reg_name}"
7397
fi
7498

75-
# Document the local registry
99+
# 5. Document the local registry
76100
# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry
77101
cat <<EOF | kubectl apply -f -
78102
apiVersion: v1
@@ -136,15 +160,20 @@ Make sure Docker registry is running.
136160
$ docker logs -f kind-registry
137161
```
138162

139-
### Deploy OpenFaaS
163+
### Deploy OpenFaaS Standard or OpenFaaS For Enterprises
140164

141-
Deploy OpenFaaS and its CLI:
165+
Deploy one of the OpenFaaS Pro editions along with faas-cli:
142166

143167
```bash
144-
$ arkade install openfaas
145168
$ arkade get faas-cli
146169
```
147170

171+
```bash
172+
$ arkade install openfaas --license-file ~/.openfaas/LICENSE
173+
```
174+
175+
Alternatively, install [OpenFaaS Pro](https://docs.openfaas.com/deployment/pro/) with helm, creating the required `openfaas-license` secret, and setting `openfaasPro: true`.
176+
148177
Then log in and port-forward OpenFaaS using the instructions given, or run `arkade info openfaas` to get them a second time.
149178

150179
### Create a Function
@@ -236,4 +265,4 @@ $ echo "advocate" | faas-cli invoke pydict
236265

237266
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.
238267

239-
> This tutorial is based upon the KinD docs and [a post by Yankee Maharjan](https://dev.to/yankee/deploy-your-serverless-python-function-locally-with-openfaas-in-kubernetes-18jf).
268+
> This tutorial is based upon the KinD docs and [a post by Yankee Maharjan](https://dev.to/yankee/deploy-your-serverless-python-function-locally-with-openfaas-in-kubernetes-18jf).

0 commit comments

Comments
 (0)