Skip to content

Commit 74e45bd

Browse files
committed
Adopt upstream CoreDNS v1.12.2 and remove custom build
Multicluster is now part of the Kubernetes plugin, so clusterset.local works with only Corefile and RBAC Signed-off-by: kahirokunn <okinakahiro@gmail.com>
1 parent 79efdd3 commit 74e45bd

File tree

4 files changed

+19
-33
lines changed

4 files changed

+19
-33
lines changed

demo/demo.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ trap cleanup EXIT
4444
tmux send -t "$c1_pane" "${k1} logs -f mcs-api-controller" Enter
4545

4646
desc "Create our service in each cluster"
47-
run "${k1} apply -f ${script_dir}/yaml/dep1.yaml -f ${script_dir}/yaml/svc.yaml"
48-
run "${k2} apply -f ${script_dir}/yaml/dep2.yaml -f ${script_dir}/yaml/svc.yaml"
47+
run "${k1} apply -f ${demo_dir}/yaml/dep1.yaml -f ${demo_dir}/yaml/svc.yaml"
48+
run "${k2} apply -f ${demo_dir}/yaml/dep2.yaml -f ${demo_dir}/yaml/svc.yaml"
4949
run "${k1} get endpointslice -n demo"
5050

5151
desc "Lets look at some requests to the service in cluster 1"
@@ -55,12 +55,12 @@ desc "Ok, looks normal. Let's import the service from our other cluster"
5555
ep_1=$(${k1} get endpointslice -n demo -l 'kubernetes.io/service-name=serve' --template="{{(index .items 0).metadata.name}}")
5656
ep_2=$(${k2} get endpointslice -n demo -l 'kubernetes.io/service-name=serve' --template="{{(index .items 0).metadata.name}}")
5757

58-
run "${k1} get endpointslice -n demo ${ep_1} -o yaml | ${script_dir}/edit-meta --metadata '{name: imported-${ep_1}, namespace: demo, labels: {multicluster.kubernetes.io/service-name: serve}}' > ${script_dir}/yaml/slice-1.tmp"
59-
run "${k2} get endpointslice -n demo ${ep_2} -o yaml | ${script_dir}/edit-meta --metadata '{name: imported-${ep_2}, namespace: demo, labels: {multicluster.kubernetes.io/service-name: serve}}' > ${script_dir}/yaml/slice-2.tmp"
60-
run "${k1} apply -f ${script_dir}/yaml/serviceimport.yaml -f ${script_dir}/yaml/slice-1.tmp -f ${script_dir}/yaml/slice-2.tmp"
61-
run "${k2} apply -f ${script_dir}/yaml/serviceimport.yaml -f ${script_dir}/yaml/slice-1.tmp -f ${script_dir}/yaml/slice-2.tmp"
62-
run "${k1} apply -f ${script_dir}/yaml/serviceimport-with-vip.yaml -f ${script_dir}/yaml/slice-1.tmp -f ${script_dir}/yaml/slice-2.tmp"
63-
run "${k2} apply -f ${script_dir}/yaml/serviceimport-with-vip.yaml -f ${script_dir}/yaml/slice-1.tmp -f ${script_dir}/yaml/slice-2.tmp"
58+
run "${k1} get endpointslice -n demo ${ep_1} -o yaml | ${demo_dir}/edit-meta --metadata '{name: imported-${ep_1}, namespace: demo, labels: {multicluster.kubernetes.io/service-name: serve}}' > ${demo_dir}/yaml/slice-1.tmp"
59+
run "${k2} get endpointslice -n demo ${ep_2} -o yaml | ${demo_dir}/edit-meta --metadata '{name: imported-${ep_2}, namespace: demo, labels: {multicluster.kubernetes.io/service-name: serve}}' > ${demo_dir}/yaml/slice-2.tmp"
60+
run "${k1} apply -f ${demo_dir}/yaml/serviceimport.yaml -f ${demo_dir}/yaml/slice-1.tmp -f ${demo_dir}/yaml/slice-2.tmp"
61+
run "${k2} apply -f ${demo_dir}/yaml/serviceimport.yaml -f ${demo_dir}/yaml/slice-1.tmp -f ${demo_dir}/yaml/slice-2.tmp"
62+
run "${k1} apply -f ${demo_dir}/yaml/serviceimport-with-vip.yaml -f ${demo_dir}/yaml/slice-1.tmp -f ${demo_dir}/yaml/slice-2.tmp"
63+
run "${k2} apply -f ${demo_dir}/yaml/serviceimport-with-vip.yaml -f ${demo_dir}/yaml/slice-1.tmp -f ${demo_dir}/yaml/slice-2.tmp"
6464

6565
desc "See what we've created..."
6666
run "${k1} get -n demo serviceimports"

scripts/c1.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ nodes:
99
- |
1010
kind: ClusterConfiguration
1111
dns:
12-
imageRepository: multicluster
13-
imageTag: latest
12+
# TODO: Remove this after Kubernetes 1.35.
13+
# Reference: https://github.com/kubernetes/kubernetes/pull/132288
14+
imageTag: v1.12.2

scripts/c2.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ nodes:
99
- |
1010
kind: ClusterConfiguration
1111
dns:
12-
imageRepository: multicluster
13-
imageTag: latest
12+
# TODO: Remove this after Kubernetes 1.35.
13+
# Reference: https://github.com/kubernetes/kubernetes/pull/132288
14+
imageTag: v1.12.2

scripts/up.sh

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,38 +39,22 @@ if [ ! -z "${BUILD_CONTROLLER}" ] || [ -z "$(docker images mcs-api-controller -q
3939
popd
4040
fi
4141

42-
coredns_version="1.11.4"
43-
coredns_image="multicluster/coredns:latest"
44-
coredns_path="/tmp/coredns-${coredns_version}"
45-
if [ ! -d "${coredns_path}" ]; then
46-
pushd /tmp
47-
git clone --depth 1 https://github.com/coredns/coredns.git --branch v${coredns_version} --single-branch "${coredns_path}"
48-
popd
49-
fi
50-
pushd "${coredns_path}"
51-
if ! grep -q -F 'multicluster:github.com/coredns/multicluster' "plugin.cfg"; then
52-
sed -i -e 's/^kubernetes:kubernetes$/&\nmulticluster:github.com\/coredns\/multicluster/' "plugin.cfg"
53-
fi
54-
docker run --rm \
55-
-v $PWD:/go/src/github.com/coredns/coredns -w /go/src/github.com/coredns/coredns \
56-
golang:1.23 make gen coredns GOFLAGS=-buildvcs=false
57-
docker build -t "${coredns_image}" .
58-
popd
59-
6042
kind create cluster --name "${c1}" --config "$PWD/${c1}.yaml"
6143
kind create cluster --name "${c2}" --config "$PWD/${c2}.yaml"
6244

6345
kind get kubeconfig --name "${c1}" > "${kubeconfig1}"
6446
kind get kubeconfig --name "${c2}" > "${kubeconfig2}"
6547

66-
kind load docker-image "${controller_image}" "${coredns_image}" --name "${c1}"
67-
kind load docker-image "${controller_image}" "${coredns_image}" --name "${c2}"
48+
kind load docker-image "${controller_image}" --name "${c1}"
49+
kind load docker-image "${controller_image}" --name "${c2}"
6850

6951
echo "Configuring CoreDNS"
7052
function update_coredns() {
7153
kubectl --kubeconfig ${1} patch clusterrole system:coredns --type json --patch-file coredns-rbac.json
54+
# Patching Corefile based on Cilium documentation: https://docs.cilium.io/en/latest/network/clustermesh/mcsapi/#prerequisites
7255
kubectl --kubeconfig ${1} get configmap -n kube-system coredns -o yaml | \
73-
sed -E -e 's/^(\s*)kubernetes.*cluster\.local.*$/\1multicluster clusterset.local\n&/' | \
56+
sed -e 's/cluster\.local/cluster.local clusterset.local/g' | \
57+
sed -E 's/^(.*)kubernetes(.*)\{/\1kubernetes\2{\n\1 multicluster clusterset.local/' | \
7458
kubectl --kubeconfig ${1} replace -f-
7559
kubectl --kubeconfig ${1} rollout restart deploy -n kube-system coredns
7660
}

0 commit comments

Comments
 (0)