From 05a0cfa8f52b64d49cb7cc64f8a2adffeb371ee0 Mon Sep 17 00:00:00 2001 From: Avi Zimmerman Date: Sun, 15 Oct 2023 21:31:09 +0300 Subject: [PATCH] docs: start building out multi-cluster example --- deploy/bundle.yaml | 2 +- deploy/config/configmap.yaml | 2 +- examples/multi-cluster/.gitignore | 1 + examples/multi-cluster/cluster-one.yaml | 6 +---- examples/multi-cluster/cluster-two.yaml | 6 +---- examples/multi-cluster/setup.sh | 33 +++++++++++++++++++++++++ examples/multi-cluster/teardown.sh | 9 +++++++ 7 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 examples/multi-cluster/.gitignore create mode 100755 examples/multi-cluster/setup.sh create mode 100755 examples/multi-cluster/teardown.sh diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index b6ea640..9476de7 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -1224,7 +1224,7 @@ data: cluster-domain: "cluster.local" # TODO: Currently IPv6 address space is computed at bootstrap, # But we should allow this to be configured with the IPv4 address space. - pod-cidr: "10.42.0.0/16,fd00:10:24::/48" + pod-cidr: "10.42.0.0/16,fd00:10:42::/48" service-cidr: "10.96.0.0/12,fd00:10:96::/112" # The network config to install on each node. # You can enable/disable IPv4/IPv6 on dual-stack nodes by adjusting the diff --git a/deploy/config/configmap.yaml b/deploy/config/configmap.yaml index ac255c6..69abf9e 100644 --- a/deploy/config/configmap.yaml +++ b/deploy/config/configmap.yaml @@ -12,7 +12,7 @@ data: cluster-domain: "cluster.local" # TODO: Currently IPv6 address space is computed at bootstrap, # But we should allow this to be configured with the IPv4 address space. - pod-cidr: "10.42.0.0/16,fd00:10:24::/48" + pod-cidr: "10.42.0.0/16,fd00:10:42::/48" service-cidr: "10.96.0.0/12,fd00:10:96::/112" # The network config to install on each node. # You can enable/disable IPv4/IPv6 on dual-stack nodes by adjusting the diff --git a/examples/multi-cluster/.gitignore b/examples/multi-cluster/.gitignore new file mode 100644 index 0000000..7cc402c --- /dev/null +++ b/examples/multi-cluster/.gitignore @@ -0,0 +1 @@ +*.kubeconfig diff --git a/examples/multi-cluster/cluster-one.yaml b/examples/multi-cluster/cluster-one.yaml index b9b374e..e55415c 100644 --- a/examples/multi-cluster/cluster-one.yaml +++ b/examples/multi-cluster/cluster-one.yaml @@ -1,6 +1,6 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 -name: webmesh-cni +name: multi-cluster-one networking: ipFamily: dual disableDefaultCNI: true @@ -12,7 +12,3 @@ nodes: extraMounts: - hostPath: /dev/net/tun containerPath: /dev/net/tun -- role: worker - extraMounts: - - hostPath: /dev/net/tun - containerPath: /dev/net/tun diff --git a/examples/multi-cluster/cluster-two.yaml b/examples/multi-cluster/cluster-two.yaml index 02bab3d..82aa4fc 100644 --- a/examples/multi-cluster/cluster-two.yaml +++ b/examples/multi-cluster/cluster-two.yaml @@ -1,6 +1,6 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 -name: webmesh-cni +name: multi-cluster-two networking: ipFamily: dual disableDefaultCNI: true @@ -12,7 +12,3 @@ nodes: extraMounts: - hostPath: /dev/net/tun containerPath: /dev/net/tun -- role: worker - extraMounts: - - hostPath: /dev/net/tun - containerPath: /dev/net/tun diff --git a/examples/multi-cluster/setup.sh b/examples/multi-cluster/setup.sh new file mode 100755 index 0000000..22c4500 --- /dev/null +++ b/examples/multi-cluster/setup.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +CLUSTER_NAME_PREFIX=${CLUSTER_NAME_PREFIX:-multi-cluster} + +set -ex + +# Create the clusters + +kind create cluster \ + --name ${CLUSTER_NAME_PREFIX}-one \ + --config ./cluster-one.yaml \ + --kubeconfig ./cluster-one.kubeconfig +kubectl --kubeconfig ./cluster-one.kubeconfig \ + config set-context --current --namespace kube-system + +kind create cluster \ + --name ${CLUSTER_NAME_PREFIX}-two \ + --config ./cluster-two.yaml \ + --kubeconfig ./cluster-two.kubeconfig +kubectl --kubeconfig ./cluster-two.kubeconfig \ + config set-context --current --namespace kube-system + +# Install the kubernetes configurations to each cluster + +kubectl --kubeconfig ./cluster-one.kubeconfig \ + --namespace kube-system \ + create secret generic cluster-two-credentials \ + --from-file=kubeconfig=./cluster-two.kubeconfig + +kubectl --kubeconfig ./cluster-two.kubeconfig \ + --namespace kube-system \ + create secret generic cluster-one-credentials \ + --from-file=kubeconfig=./cluster-one.kubeconfig diff --git a/examples/multi-cluster/teardown.sh b/examples/multi-cluster/teardown.sh new file mode 100755 index 0000000..23691e1 --- /dev/null +++ b/examples/multi-cluster/teardown.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +CLUSTER_NAME_PREFIX=${CLUSTER_NAME_PREFIX:-multi-cluster} + +set -ex + +kind delete cluster --name ${CLUSTER_NAME_PREFIX}-one +kind delete cluster --name ${CLUSTER_NAME_PREFIX}-two +rm -f cluster-one.kubeconfig cluster-two.kubeconfig