Skip to content

Commit 07157e6

Browse files
authored
Merge pull request #5909 from chaosi-zju/chart-install
Test helm chart with the latest code
2 parents f72a312 + 16e7a0e commit 07157e6

File tree

4 files changed

+191
-24
lines changed

4 files changed

+191
-24
lines changed

.github/workflows/lint-chart.yaml renamed to .github/workflows/installation-chart.yaml

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
# validate any chart changes under charts directory
2-
name: Chart Lint
3-
2+
name: Chart
43
env:
54
HELM_VERSION: v3.11.2
65
KUSTOMIZE_VERSION: 5.4.3
7-
KIND_VERSION: v0.22.0
8-
KIND_NODE_IMAGE: kindest/node:v1.29.0
9-
K8S_VERSION: v1.29.0
10-
116
on:
127
push:
138
# Exclude branches created by Dependabot to avoid triggering current workflow
149
# for PRs initiated by Dependabot.
1510
branches-ignore:
1611
- 'dependabot/**'
1712
pull_request:
18-
paths:
19-
- "charts/**"
20-
13+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
16+
cancel-in-progress: true
2117
permissions:
2218
contents: read
23-
2419
jobs:
25-
chart-lint-test:
20+
test-on-kubernetes-matrix:
21+
name: Test on Kubernetes
2622
runs-on: ubuntu-22.04
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
# Here support the latest three minor releases of Kubernetes, this can be considered to be roughly
27+
# the same as the End of Life of the Kubernetes release: https://kubernetes.io/releases/
28+
# Please remember to update the CI Schedule Workflow when we add a new version.
29+
k8s: [ v1.29.0, v1.30.0, v1.31.0 ]
2730
steps:
2831
- name: Checkout
2932
uses: actions/checkout@v4
@@ -99,15 +102,11 @@ jobs:
99102
if: steps.list-changed.outputs.changed == 'true'
100103
run: ct lint --debug --check-version-increment=false
101104

102-
- name: Create kind cluster
103-
uses: helm/[email protected]
104-
if: steps.list-changed.outputs.changed == 'true'
105-
with:
106-
wait: 120s
107-
version: ${{ env.KIND_VERSION }}
108-
node_image: ${{ env.KIND_NODE_IMAGE }}
109-
kubectl_version: ${{ env.K8S_VERSION }}
110-
111105
- name: Run chart-testing (install)
112-
if: steps.list-changed.outputs.changed == 'true'
113-
run: ct install --debug --helm-extra-args "--timeout 800s"
106+
run: |
107+
export CLUSTER_VERSION=kindest/node:${{ matrix.k8s }}
108+
hack/setup-dev-base.sh
109+
export KUBECONFIG=~/.kube/karmada.config
110+
111+
ct install --charts charts/karmada --debug --helm-extra-set-args '--set components={search,metricsAdapter,descheduler},apiServer.hostNetwork=true' --helm-extra-args "--timeout 800s" --skip-clean-up
112+
kubectl get pods -A

.github/workflows/cli.yaml renamed to .github/workflows/installation-cli.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ concurrency:
1515
permissions:
1616
contents: read # Required to check out the code
1717
jobs:
18-
init:
19-
name: init
18+
test-on-kubernetes-matrix:
19+
name: Test on Kubernetes
2020
runs-on: ubuntu-22.04
2121
strategy:
2222
fail-fast: false

hack/setup-dev-base.sh

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2024 The Karmada Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
# This script sets up a development environment for installing Karmada locally.
21+
# It creates multiple Kind clusters, including a host cluster pre-loaded with
22+
# Karmada component images built from the latest code. The remaining clusters
23+
# will serve as member clusters and will be registered to the Karmada control
24+
# plane using the installation tool.
25+
# Note: This script works for both Linux and MacOS.
26+
27+
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
28+
source "${REPO_ROOT}"/hack/util.sh
29+
30+
# variable define
31+
KUBECONFIG_PATH=${KUBECONFIG_PATH:-"${HOME}/.kube"}
32+
MAIN_KUBECONFIG=${MAIN_KUBECONFIG:-"${KUBECONFIG_PATH}/karmada.config"}
33+
HOST_CLUSTER_NAME=${HOST_CLUSTER_NAME:-"karmada-host"}
34+
MEMBER_CLUSTER_KUBECONFIG=${MEMBER_CLUSTER_KUBECONFIG:-"${KUBECONFIG_PATH}/members.config"}
35+
MEMBER_CLUSTER_1_NAME=${MEMBER_CLUSTER_1_NAME:-"member1"}
36+
MEMBER_CLUSTER_2_NAME=${MEMBER_CLUSTER_2_NAME:-"member2"}
37+
PULL_MODE_CLUSTER_NAME=${PULL_MODE_CLUSTER_NAME:-"member3"}
38+
MEMBER_TMP_CONFIG_PREFIX="member-tmp"
39+
MEMBER_CLUSTER_1_TMP_CONFIG="${KUBECONFIG_PATH}/${MEMBER_TMP_CONFIG_PREFIX}-${MEMBER_CLUSTER_1_NAME}.config"
40+
MEMBER_CLUSTER_2_TMP_CONFIG="${KUBECONFIG_PATH}/${MEMBER_TMP_CONFIG_PREFIX}-${MEMBER_CLUSTER_2_NAME}.config"
41+
PULL_MODE_CLUSTER_TMP_CONFIG="${KUBECONFIG_PATH}/${MEMBER_TMP_CONFIG_PREFIX}-${PULL_MODE_CLUSTER_NAME}.config"
42+
HOST_IPADDRESS=${HOST_IPADDRESS:-}
43+
BUILD_FROM_SOURCE=${BUILD_FROM_SOURCE:-"true"}
44+
EXTRA_IMAGES_LOAD_TO_HOST_CLUSTER=${EXTRA_IMAGES_LOAD_TO_HOST_CLUSTER:-""}
45+
46+
CLUSTER_VERSION=${CLUSTER_VERSION:-"${DEFAULT_CLUSTER_VERSION}"}
47+
KIND_LOG_FILE=${KIND_LOG_FILE:-"/tmp/karmada"}
48+
49+
#step0: prepare
50+
# proxy setting in China mainland
51+
if [[ -n ${CHINA_MAINLAND:-} ]]; then
52+
util::set_mirror_registry_for_china_mainland ${REPO_ROOT}
53+
fi
54+
55+
# make sure go exists and the go version is a viable version.
56+
util::cmd_must_exist "go"
57+
util::verify_go_version
58+
59+
# make sure docker exists
60+
util::cmd_must_exist "docker"
61+
62+
# install kind and kubectl
63+
kind_version=v0.25.0
64+
echo -n "Preparing: 'kind' existence check - "
65+
if util::cmd_exist kind; then
66+
echo "passed"
67+
else
68+
echo "not pass"
69+
util::install_tools "sigs.k8s.io/kind" $kind_version
70+
fi
71+
72+
# get arch name and os name in bootstrap
73+
BS_ARCH=$(go env GOARCH)
74+
BS_OS=$(go env GOOS)
75+
# check arch and os name before installing
76+
util::install_environment_check "${BS_ARCH}" "${BS_OS}"
77+
echo -n "Preparing: 'kubectl' existence check - "
78+
if util::cmd_exist kubectl; then
79+
echo "passed"
80+
else
81+
echo "not pass"
82+
util::install_kubectl "" "${BS_ARCH}" "${BS_OS}"
83+
fi
84+
85+
#step1. create host cluster and member clusters in parallel
86+
# host IP address: script parameter ahead of macOS IP
87+
if [[ -z "${HOST_IPADDRESS}" ]]; then
88+
util::get_macos_ipaddress # Adapt for macOS
89+
HOST_IPADDRESS=${MAC_NIC_IPADDRESS:-}
90+
fi
91+
#prepare for kindClusterConfig
92+
TEMP_PATH=$(mktemp -d)
93+
trap '{ rm -rf ${TEMP_PATH}; }' EXIT
94+
echo -e "Preparing kindClusterConfig in path: ${TEMP_PATH}"
95+
cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/member1.yaml "${TEMP_PATH}"/member1.yaml
96+
cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/member2.yaml "${TEMP_PATH}"/member2.yaml
97+
cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/member3.yaml "${TEMP_PATH}"/member3.yaml
98+
99+
util::delete_necessary_resources "${MAIN_KUBECONFIG},${MEMBER_CLUSTER_KUBECONFIG}" "${HOST_CLUSTER_NAME},${MEMBER_CLUSTER_1_NAME},${MEMBER_CLUSTER_2_NAME},${PULL_MODE_CLUSTER_NAME}" "${KIND_LOG_FILE}"
100+
101+
if [[ -n "${HOST_IPADDRESS}" ]]; then # If bind the port of clusters(karmada-host, member1 and member2) to the host IP
102+
util::verify_ip_address "${HOST_IPADDRESS}"
103+
cp -rf "${REPO_ROOT}"/artifacts/kindClusterConfig/karmada-host.yaml "${TEMP_PATH}"/karmada-host.yaml
104+
sed -i'' -e "s/{{host_ipaddress}}/${HOST_IPADDRESS}/g" "${TEMP_PATH}"/karmada-host.yaml
105+
sed -i'' -e 's/networking:/&\'$'\n'' apiServerAddress: "'${HOST_IPADDRESS}'"/' "${TEMP_PATH}"/member1.yaml
106+
sed -i'' -e 's/networking:/&\'$'\n'' apiServerAddress: "'${HOST_IPADDRESS}'"/' "${TEMP_PATH}"/member2.yaml
107+
sed -i'' -e 's/networking:/&\'$'\n'' apiServerAddress: "'${HOST_IPADDRESS}'"/' "${TEMP_PATH}"/member3.yaml
108+
util::create_cluster "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${CLUSTER_VERSION}" "${KIND_LOG_FILE}" "${TEMP_PATH}"/karmada-host.yaml
109+
else
110+
util::create_cluster "${HOST_CLUSTER_NAME}" "${MAIN_KUBECONFIG}" "${CLUSTER_VERSION}" "${KIND_LOG_FILE}"
111+
fi
112+
util::create_cluster "${MEMBER_CLUSTER_1_NAME}" "${MEMBER_CLUSTER_1_TMP_CONFIG}" "${CLUSTER_VERSION}" "${KIND_LOG_FILE}" "${TEMP_PATH}"/member1.yaml
113+
util::create_cluster "${MEMBER_CLUSTER_2_NAME}" "${MEMBER_CLUSTER_2_TMP_CONFIG}" "${CLUSTER_VERSION}" "${KIND_LOG_FILE}" "${TEMP_PATH}"/member2.yaml
114+
util::create_cluster "${PULL_MODE_CLUSTER_NAME}" "${PULL_MODE_CLUSTER_TMP_CONFIG}" "${CLUSTER_VERSION}" "${KIND_LOG_FILE}" "${TEMP_PATH}"/member3.yaml
115+
116+
#step2. make images and get karmadactl
117+
export VERSION="latest"
118+
export REGISTRY="docker.io/karmada"
119+
if [[ "${BUILD_FROM_SOURCE}" == "true" ]]; then
120+
export KARMADA_IMAGE_LABEL_VALUE="May_be_pruned_in_local_up_environment"
121+
export DOCKER_BUILD_ARGS="${DOCKER_BUILD_ARGS:-} --label=image.karmada.io=${KARMADA_IMAGE_LABEL_VALUE}"
122+
make images GOOS="linux" --directory="${REPO_ROOT}"
123+
#clean up dangling images
124+
docker image prune --force --filter "label=image.karmada.io=${KARMADA_IMAGE_LABEL_VALUE}"
125+
fi
126+
GO111MODULE=on go install "github.com/karmada-io/karmada/cmd/karmadactl"
127+
128+
#step3. wait until clusters ready
129+
echo "Waiting for the clusters to be ready..."
130+
util::check_clusters_ready "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}"
131+
util::check_clusters_ready "${MEMBER_CLUSTER_1_TMP_CONFIG}" "${MEMBER_CLUSTER_1_NAME}"
132+
util::check_clusters_ready "${MEMBER_CLUSTER_2_TMP_CONFIG}" "${MEMBER_CLUSTER_2_NAME}"
133+
util::check_clusters_ready "${PULL_MODE_CLUSTER_TMP_CONFIG}" "${PULL_MODE_CLUSTER_NAME}"
134+
135+
#step4. load components images to kind cluster
136+
if [[ "${BUILD_FROM_SOURCE}" == "true" ]]; then
137+
# host cluster
138+
kind load docker-image "${REGISTRY}/karmada-controller-manager:${VERSION}" --name="${HOST_CLUSTER_NAME}"
139+
kind load docker-image "${REGISTRY}/karmada-scheduler:${VERSION}" --name="${HOST_CLUSTER_NAME}"
140+
kind load docker-image "${REGISTRY}/karmada-descheduler:${VERSION}" --name="${HOST_CLUSTER_NAME}"
141+
kind load docker-image "${REGISTRY}/karmada-webhook:${VERSION}" --name="${HOST_CLUSTER_NAME}"
142+
kind load docker-image "${REGISTRY}/karmada-scheduler-estimator:${VERSION}" --name="${HOST_CLUSTER_NAME}"
143+
kind load docker-image "${REGISTRY}/karmada-aggregated-apiserver:${VERSION}" --name="${HOST_CLUSTER_NAME}"
144+
kind load docker-image "${REGISTRY}/karmada-search:${VERSION}" --name="${HOST_CLUSTER_NAME}"
145+
kind load docker-image "${REGISTRY}/karmada-metrics-adapter:${VERSION}" --name="${HOST_CLUSTER_NAME}"
146+
for img in ${EXTRA_IMAGES_LOAD_TO_HOST_CLUSTER//,/ }; do
147+
kind load docker-image "$img" --name="${HOST_CLUSTER_NAME}"
148+
done
149+
# pull mode member cluster
150+
kind load docker-image "${REGISTRY}/karmada-agent:${VERSION}" --name="${PULL_MODE_CLUSTER_NAME}"
151+
fi
152+
153+
#step5. connecting networks between karmada-host, member1 and member2 clusters
154+
echo "connecting cluster networks..."
155+
util::add_routes "${MEMBER_CLUSTER_1_NAME}" "${MEMBER_CLUSTER_2_TMP_CONFIG}" "${MEMBER_CLUSTER_2_NAME}"
156+
util::add_routes "${MEMBER_CLUSTER_2_NAME}" "${MEMBER_CLUSTER_1_TMP_CONFIG}" "${MEMBER_CLUSTER_1_NAME}"
157+
158+
util::add_routes "${HOST_CLUSTER_NAME}" "${MEMBER_CLUSTER_1_TMP_CONFIG}" "${MEMBER_CLUSTER_1_NAME}"
159+
util::add_routes "${MEMBER_CLUSTER_1_NAME}" "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}"
160+
161+
util::add_routes "${HOST_CLUSTER_NAME}" "${MEMBER_CLUSTER_2_TMP_CONFIG}" "${MEMBER_CLUSTER_2_NAME}"
162+
util::add_routes "${MEMBER_CLUSTER_2_NAME}" "${MAIN_KUBECONFIG}" "${HOST_CLUSTER_NAME}"
163+
echo "cluster networks connected"
164+
165+
#step6. merge temporary kubeconfig of member clusters by kubectl
166+
export KUBECONFIG=$(find ${KUBECONFIG_PATH} -maxdepth 1 -type f | grep ${MEMBER_TMP_CONFIG_PREFIX} | tr '\n' ':')
167+
kubectl config view --flatten > ${MEMBER_CLUSTER_KUBECONFIG}
168+
rm $(find ${KUBECONFIG_PATH} -maxdepth 1 -type f | grep ${MEMBER_TMP_CONFIG_PREFIX})

0 commit comments

Comments
 (0)