| 1 | # Set up KIND cluster with multiple KCP and worker nodes running konnectivity |
| 2 | |
| 3 | Change to the `examples/kind-multinode-kcp` folder and run `./quickstart-kind`. This script |
| 4 | performs the following operations: |
| 5 | |
| 6 | 1. Render config templates in `templates/` using provided values. |
| 7 | 2. Create a new `kind` cluster with the desired number of KCP and worker nodes. |
| 8 | 3. Changes `kubectl` context to point to the new `kind` cluster. |
| 9 | 4. Deploys `konnectivity` proxy servers and agents to the KCP and worker nodes. |
| 10 | |
| 11 | |
| 12 | ## `./quickstart-kind.sh` command-line flags |
| 13 | - `--cluster-name <NAME>`: Name of the `kind` cluster to be created Default: `knp-test-cluster` |
| 14 | - `--overwrite-cluster`: Overwrite existing `kind` cluster if necessary. Default: do not overwrite. |
| 15 | - `--server-image <IMAGE_NAME>[:<IMAGE_TAG>]`: Proxy server image to deploy. Default: `gcr.io/k8s-staging-kas-network-proxy/proxy-server:master` |
| 16 | - `--agent-image <IMAGE_NAME>[:<IMAGE_TAG>]`: Proxy server image to deploy. Default: `gcr.io/k8s-staging-kas-network-proxy/proxy-agent:master` |
| 17 | - `--num-kcp-nodes <NUM>`: Number of control plane nodes to spin up. Default: 2. |
| 18 | - `--num-worker-nodes <NUM>`: Number of worker nodes to spin up. Default: 1. |
| 19 | - `--server-count-override <NUM>`: If this flag is >= 0, override the `--serverCount` flag in the proxy server's configuration to the provided number. Default: set `--serverCount` to equal the number of KCP nodes. |
| 20 | - `--sideload-images`: Use `kind load ...` to sideload custom proxy server and agent images with the names set by `--server-image` and `--agent-image` into the kind cluster. Default: do not sideload. |
| 21 | - Use this if you don't want to publish your custom KNP images to a public registry. |
| 22 | - NOTE: You MUST specify an image tag (i.e. `my-image-name:my-image-tag` and not just `my-image-name`) and the image tag MUST NOT be `:latest` for this to work! See [`kind` docs](https://kind.sigs.k8s.io/docs/user/quick-start/#loading-an-image-into-your-cluster) for why this is necessary. |
| 23 | |
| 24 | ## Example usage to deploy custom local KNP images |
| 25 | In the repo root, build KNP and its docker images with the following: |
| 26 | ```shell |
| 27 | make clean |
| 28 | make certs |
| 29 | make gen |
| 30 | make build |
| 31 | make docker-build |
| 32 | ``` |
| 33 | |
| 34 | Verify that the new images are available in the local docker registry with `docker images`. Then, bring up the cluster: |
| 35 | |
| 36 | ```shell |
| 37 | cd examples/kind-multinode |
| 38 | |
| 39 | # These are the default values of the registry, image name, and tag used by the Makefile. |
| 40 | # Edit them if necessary. |
| 41 | REGISTRY=gcr.io/$(gcloud config get-value project) |
| 42 | TAG=$(git rev-parse HEAD) |
| 43 | TARGET_ARCH="amd64" |
| 44 | SERVER_IMAGE="$REGISTRY/proxy-server-$TARGET_ARCH:$TAG" |
| 45 | AGENT_IMAGE="$REGISTRY/proxy-agent-$TARGET_ARCH:$TAG" |
| 46 | |
| 47 | # Bring up the cluster! |
| 48 | ./quickstart-kind.sh --cluster-name custom-knp-test --server-image "$SERVER_IMAGE" --agent-image "$AGENT_IMAGE" \ |
| 49 | --num-kcp-nodes 3 --num-worker-nodes 2 --sideload-images |
| 50 | ``` |
| 51 | |
| 52 | ## Making sure the script worked |
| 53 | |
| 54 | Check that the `konnectivity` pods are up and running: |
| 55 | ```shell |
| 56 | kubectl --namespace kube-system get pods | grep konnectivity |
| 57 | # Output: |
| 58 | # konnectivity-agent-4db5j 1/1 Running 0 34m |
| 59 | # konnectivity-agent-c7gj5 1/1 Running 0 34m |
| 60 | # konnectivity-agent-h86l9 1/1 Running 0 34m |
| 61 | # konnectivity-server-9bl45 1/1 Running 0 34m |
| 62 | # konnectivity-server-dcfz8 1/1 Running 0 34m |
| 63 | # konnectivity-server-klww5 1/1 Running 0 34m |
| 64 | # konnectivity-server-nrfz8 1/1 Running 0 34m |
| 65 | ``` |
| 66 | |
| 67 | Then create a test pod on a worker node and verify you can get logs from it: |
| 68 | ```shell |
| 69 | kubectl run test --image httpd:2 |
| 70 | # Output: |
| 71 | # pod/test created |
| 72 | kubectl get pods |
| 73 | # Output: |
| 74 | # NAME READY STATUS RESTARTS AGE |
| 75 | # test 1/1 Running 0 34s |
| 76 | kubectl logs test |
| 77 | # Output: |
| 78 | # AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.244.5.3. Set the 'ServerName' directive globally to suppress this message |
| 79 | # AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.244.5.3. Set the 'ServerName' directive globally to suppress this message |
| 80 | # [Wed Jun 12 20:42:06.471169 2024] [mpm_event:notice] [pid 1:tid 139903660291968] AH00489: Apache/2.4.59 (Unix) configured -- resuming normal operations |
| 81 | # [Wed Jun 12 20:42:06.471651 2024] [core:notice] [pid 1:tid 139903660291968] AH00094: Command line: 'httpd -D FOREGROUND' |
| 82 | ``` |