Skip to content

Commit 41b8b4e

Browse files
committed
ci: update workflows
Signed-off-by: Ilya Drey <ilya.drey@flant.com>
1 parent 4ad8e47 commit 41b8b4e

3 files changed

Lines changed: 35 additions & 95 deletions

File tree

.github/workflows/build_dev.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,20 @@ jobs:
216216
- name: Install ginkgo
217217
run: task --yes -p e2e:deps:install:ginkgo
218218

219-
- name: Install kubectl
220-
run: task --yes -p e2e:deps:install:kubectl
221-
222219
- name: Setup kind with module operator-helm enabled
223220
run: task --yes -p e2e:kind:ci:setup
224221
env:
225-
KIND_CLUSTER_NAME: d8-operator-helm
222+
KIND_CLUSTER_NAME: d8-operator-helm-${{ github.run_number }}
226223
MODULE_TAG_NAME: ${{ needs.build_dev.outputs.modules_module_tag }}
227224
DEV_REGISTRY_DOCKER_CONFIG: ${{ secrets.DEV_REGISTRY_DOCKER_CONFIG }}
228225

229226
- name: Run e2e tests
230227
run: task --yes -p e2e:tests
231228
env:
232-
E2E_CLUSTERTRANSPORT_KUBECONFIG: "~/.kind-d8-operator-helm/kubeconfig"
229+
KIND_CLUSTER_NAME: d8-operator-helm-${{ github.run_number }}
233230

234231
- name: Delete kind cluster
235232
run: task --yes -p e2e:kind:ci:cleanup
233+
env:
234+
KIND_CLUSTER_NAME: d8-operator-helm-${{ github.run_number }}
236235
if: always()

tests/e2e/Taskfile.dist.yaml

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: '3'
33
vars:
44
TIMEOUT: '{{.TIMEOUT | default "30m"}}'
55
KIND_CLUSTER_NAME: '{{.KIND_CLUSTER_NAME | default "d8-operator-helm"}}'
6-
KIND_BIN_PATH: '{{.KIND_BIN_PATH | default "~/.kind-d8-operator-helm/kind"}}'
76

87
tasks:
98
deps:install:ginkgo:
@@ -14,24 +13,6 @@ tasks:
1413
version="$(go list -m -f '{{ printf `{{ .Version }}` }}' github.com/onsi/ginkgo/v2)"
1514
go install {{.CLI_ARGS}} github.com/onsi/ginkgo/v2/ginkgo@${version}
1615
17-
deps:install:kubectl:
18-
desc: "Install kubectl binary for the current OS/Arch"
19-
cmds:
20-
- |
21-
curl -LO "https://dl.k8s.io/release/{{.K8S_VERSION}}/bin/{{.OS}}/{{.ARCH}}/kubectl"
22-
chmod +x ./kubectl
23-
mkdir -p {{.GOPATH}}/bin
24-
mv ./kubectl {{.GOPATH}}/bin/kubectl
25-
status:
26-
- which kubectl
27-
vars:
28-
OS: '{{OS}}'
29-
ARCH: '{{ARCH}}'
30-
K8S_VERSION:
31-
sh: curl -L -s https://dl.k8s.io/release/stable.txt
32-
GOPATH:
33-
sh: go env GOPATH
34-
3516
kind:ci:setup:
3617
desc: Setup kind in CI
3718
cmds:
@@ -45,7 +26,7 @@ tasks:
4526
kind:ci:cleanup:
4627
desc: Delete kind cluster in CI
4728
cmds:
48-
- '{{.KIND_BIN_PATH}} delete cluster --name {{.KIND_CLUSTER_NAME}} || exit 0'
29+
- './kind/bin/kind delete cluster --name {{.KIND_CLUSTER_NAME}} || exit 0'
4930

5031
tests:
5132
desc: Run e2e tests
@@ -54,4 +35,4 @@ tasks:
5435
args="-v --race --timeout={{.TIMEOUT}}"
5536
go tool ginkgo $args ./...
5637
env:
57-
E2E_CLUSTERTRANSPORT_KUBECONFIG: ./kube.config
38+
E2E_CLUSTERTRANSPORT_KUBECONFIG: './kind/{{.KIND_CLUSTER_NAME}}/kubeconfig-external'

tests/e2e/scripts/kind-d8-ci.sh

Lines changed: 29 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ if uname -s | grep -q "Darwin"; then
3535
fi
3636
fi
3737

38-
CONFIG_DIR=~/.kind-d8-operator-helm
38+
PARENT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." &> /dev/null && pwd)
39+
40+
KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-d8-operator-helm}
41+
KIND_CONFIG_DIR=${KIND_CONFIG_DIR:-$PARENT_DIR/kind}/$KIND_CLUSTER_NAME
3942
KIND_IMAGE=kindest/node:v1.31.6@sha256:28b7cbb993dfe093c76641a0c95807637213c9109b761f1d422c2400e22b8e87
4043
D8_RELEASE_CHANNEL_TAG=stable
4144
D8_RELEASE_CHANNEL_NAME=Stable
4245
D8_REGISTRY_ADDRESS=registry.deckhouse.io
4346
D8_REGISTRY_PATH=${D8_REGISTRY_ADDRESS}/deckhouse/ce
4447
D8_LICENSE_KEY=
4548

46-
KIND_INSTALL_DIRECTORY=$CONFIG_DIR
49+
KIND_INSTALL_DIRECTORY=$PARENT_DIR/kind/bin
4750
KIND_PATH=kind
48-
KIND_CLUSTER_NAME=d8-operator-helm
4951
KIND_VERSION=v0.27.0
5052

51-
KUBECTL_INSTALL_DIRECTORY=$CONFIG_DIR
53+
KUBECTL_INSTALL_DIRECTORY=$PARENT_DIR/kind/bin
5254
KUBECTL_PATH=kubectl
5355
KUBECTL_VERSION=v1.31.6
5456

@@ -235,33 +237,10 @@ kubectl_check() {
235237
KUBECTL_PATH=${KUBECTL_INSTALL_DIRECTORY}/kubectl
236238
else
237239
echo "kubectl is not installed."
238-
while [[ "$should_install_kubectl" != "y" ]]; do
239-
read -rp "Install kubectl? y/[n]: " should_install_kubectl
240-
241-
if [[ ("$should_install_kubectl" == "n") || (-z "$should_install_kubectl") ]]; then
242-
printf "
243-
Please install kubectl.
244-
245-
You can find the installation instruction here: https://kubernetes.io/docs/tasks/tools/#kubectl
246-
"
247-
exit 1
248-
fi
249-
250-
if [[ "$should_install_kubectl" != "y" ]]; then
251-
echo "Please type 'y' to continue or 'n' to abort the installation."
252-
fi
253-
254-
done
255-
256-
read -rp "kubectl installation directory [$KUBECTL_INSTALL_DIRECTORY]: " kubectl_install_directory_answer
257-
if [[ -n "$kubectl_install_directory_answer" ]]; then
258-
KUBECTL_INSTALL_DIRECTORY=$kubectl_install_directory_answer
259-
fi
260-
261240
echo "Installing the latest stable kubectl version to ${KUBECTL_INSTALL_DIRECTORY}/kubectl ..."
262241

263242
mkdir -p $KUBECTL_INSTALL_DIRECTORY
264-
curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/${OS_NAME/mac/darwin}/${MACHINE_ARCH/x86_64/amd64}/kubectl"
243+
curl -sLO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/${OS_NAME/mac/darwin}/${MACHINE_ARCH/x86_64/amd64}/kubectl"
265244

266245
if [ "$?" -ne "0" ]; then
267246
echo "Unable to download kubectl."
@@ -294,18 +273,18 @@ kind_check() {
294273

295274
mkdir -p ${KIND_INSTALL_DIRECTORY}
296275

297-
curl -Lo ./kind "https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-${OS_NAME/mac/darwin}-${MACHINE_ARCH/x86_64/amd64}"
276+
curl -sLo ./kind-binary "https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-${OS_NAME/mac/darwin}-${MACHINE_ARCH/x86_64/amd64}"
298277

299278
if [ "$?" -ne "0" ]; then
300279
echo "Unable to download kind."
301280
exit 1
302281
fi
303282

304-
install -m 0755 kind "${KIND_INSTALL_DIRECTORY}"/kind
283+
install -m 0755 kind-binary "${KIND_INSTALL_DIRECTORY}"/kind
305284

306285
if [ "$?" -ne "0" ]; then
307286
echo "Insufficient permissions to install kind. Trying again with sudo..."
308-
sudo install -m 0755 kind "${KIND_INSTALL_DIRECTORY}"/kind
287+
sudo install -m 0755 kind-binary "${KIND_INSTALL_DIRECTORY}"/kind
309288
if [ "$?" -ne "0" ]; then
310289
echo "Unable to install kind. Check installation path and permissions."
311290
exit 1
@@ -338,10 +317,10 @@ preinstall_checks() {
338317
}
339318

340319
configs_create() {
341-
mkdir -p ${CONFIG_DIR}
320+
mkdir -p ${KIND_CONFIG_DIR}
342321

343-
echo "Creating kind config file (${CONFIG_DIR}/kind.cfg)..."
344-
cat <<EOF >${CONFIG_DIR}/kind.cfg
322+
echo "Creating kind config file (${KIND_CONFIG_DIR}/kind.cfg)..."
323+
cat <<EOF >${KIND_CONFIG_DIR}/kind.cfg
345324
apiVersion: kind.x-k8s.io/v1alpha4
346325
kind: Cluster
347326
featureGates:
@@ -361,8 +340,8 @@ nodes:
361340
protocol: TCP
362341
EOF
363342

364-
echo "Creating Deckhouse Kubernetes Platform installation config file (${CONFIG_DIR}/config.yml)..."
365-
cat <<EOF >${CONFIG_DIR}/config.yml
343+
echo "Creating Deckhouse Kubernetes Platform installation config file (${KIND_CONFIG_DIR}/config.yml)..."
344+
cat <<EOF >${KIND_CONFIG_DIR}/config.yml
366345
apiVersion: deckhouse.io/v1alpha1
367346
kind: ModuleConfig
368347
metadata:
@@ -457,7 +436,7 @@ EOF
457436

458437
if [[ -n "$D8_LICENSE_KEY" ]]; then
459438
generate_ee_access_string "$D8_LICENSE_KEY"
460-
cat <<EOF >>${CONFIG_DIR}/config.yml
439+
cat <<EOF >>${KIND_CONFIG_DIR}/config.yml
461440
---
462441
apiVersion: deckhouse.io/v1
463442
kind: InitConfiguration
@@ -467,8 +446,8 @@ deckhouse:
467446
EOF
468447
fi
469448

470-
echo "Creating Deckhouse Kubernetes Platform resource file (${CONFIG_DIR}/resources.yml)..."
471-
cat <<EOF >${CONFIG_DIR}/resources.yml
449+
echo "Creating Deckhouse Kubernetes Platform resource file (${KIND_CONFIG_DIR}/resources.yml)..."
450+
cat <<EOF >${KIND_CONFIG_DIR}/resources.yml
472451
apiVersion: deckhouse.io/v1
473452
kind: IngressNginxController
474453
metadata:
@@ -494,7 +473,7 @@ To delete created cluster use the following command:
494473

495474
cluster_create() {
496475

497-
${KIND_PATH} create cluster --name "${KIND_CLUSTER_NAME}" --image "${KIND_IMAGE}" --config "${CONFIG_DIR}/kind.cfg"
476+
${KIND_PATH} create cluster --name "${KIND_CLUSTER_NAME}" --image "${KIND_IMAGE}" --config "${KIND_CONFIG_DIR}/kind.cfg"
498477

499478
if [ "$?" -ne "0" ]; then
500479
printf "
@@ -508,7 +487,7 @@ E.g., you can find programs that use these ports using the following command:
508487
exit 1
509488
fi
510489

511-
${KIND_PATH} get kubeconfig --internal --name "${KIND_CLUSTER_NAME}" >${CONFIG_DIR}/kubeconfig
490+
${KIND_PATH} get kubeconfig --internal --name "${KIND_CLUSTER_NAME}" >${KIND_CONFIG_DIR}/kubeconfig
512491

513492
}
514493

@@ -517,9 +496,9 @@ deckhouse_install() {
517496

518497
# Use the --debug flag to see exactly why it's failing
519498
docker run --pull=always --rm --network kind \
520-
-v "${CONFIG_DIR}/config.yml:/config.yml" \
521-
-v "${CONFIG_DIR}/resources.yml:/resources.yml" \
522-
-v "${CONFIG_DIR}/kubeconfig:/kubeconfig" \
499+
-v "${KIND_CONFIG_DIR}/config.yml:/config.yml" \
500+
-v "${KIND_CONFIG_DIR}/resources.yml:/resources.yml" \
501+
-v "${KIND_CONFIG_DIR}/kubeconfig:/kubeconfig" \
523502
${D8_REGISTRY_PATH}/install:${D8_RELEASE_CHANNEL_TAG} \
524503
bash -c "dhctl bootstrap-phase install-deckhouse --kubeconfig=/kubeconfig --kubeconfig-context=kind-${KIND_CLUSTER_NAME} --config=/config.yml"
525504

@@ -528,7 +507,7 @@ deckhouse_install() {
528507
echo "First phase might have timed out. Waiting 30s for CRDs to settle..."
529508
sleep 30
530509
# Try the resource creation phase separately
531-
docker run --rm --network kind -v "${CONFIG_DIR}/resources.yml:/resources.yml" -v "${CONFIG_DIR}/kubeconfig:/kubeconfig" \
510+
docker run --rm --network kind -v "${KIND_CONFIG_DIR}/resources.yml:/resources.yml" -v "${KIND_CONFIG_DIR}/kubeconfig:/kubeconfig" \
532511
${D8_REGISTRY_PATH}/install:${D8_RELEASE_CHANNEL_TAG} \
533512
dhctl bootstrap-phase create-resources --kubeconfig=/kubeconfig --kubeconfig-context=kind-${KIND_CLUSTER_NAME} --resources=/resources.yml
534513
fi
@@ -596,30 +575,6 @@ generate_ee_access_string() {
596575
fi
597576
}
598577

599-
install_show_credentials() {
600-
601-
local prometheus_password
602-
prometheus_password=$(${KUBECTL_PATH} --context "kind-${KIND_CLUSTER_NAME}" -n d8-system exec deploy/deckhouse -c deckhouse -- sh -c "deckhouse-controller module values prometheus -o json | jq -r '.internal.auth.password'")
603-
if [ "$?" -ne "0" ] || [ -z "$prometheus_password" ]; then
604-
printf "
605-
Error getting Prometheus password.
606-
607-
Try to run the following command to get Prometheus password:
608-
609-
%s --context %s -n d8-system exec deploy/deckhouse -c deckhouse -- sh -c "deckhouse-controller module values prometheus -o json | jq -r '.internal.auth.password'"
610-
611-
" "${KUBECTL_PATH}" "kind-${KIND_CLUSTER_NAME}"
612-
else
613-
printf "
614-
Provide following credentials to access Grafana at http://grafana.127.0.0.1.sslip.io/ :
615-
616-
Username: admin
617-
Password: %s
618-
619-
" "${prometheus_password}"
620-
fi
621-
}
622-
623578
setup_operator_helm() {
624579
echo "Enabling operator-helm module..."
625580

@@ -655,6 +610,10 @@ spec:
655610
EOF
656611
}
657612

613+
extract_kubectl_context() {
614+
${KUBECTL_PATH} config view --context "kind-${KIND_CLUSTER_NAME}" --minify --flatten > "${KIND_CONFIG_DIR}/kubeconfig-external"
615+
}
616+
658617
main() {
659618
parse_args "$@"
660619

@@ -665,6 +624,7 @@ main() {
665624
deckhouse_install
666625
macos_force_qemu
667626
setup_operator_helm
627+
extract_kubectl_context
668628
}
669629

670630
main "$@"

0 commit comments

Comments
 (0)