diff --git a/.github/workflows/helm.yaml b/.github/workflows/helm.yaml index dcdc18491e..dda7876da3 100644 --- a/.github/workflows/helm.yaml +++ b/.github/workflows/helm.yaml @@ -49,8 +49,7 @@ jobs: # Need a multi node cluster so descheduler runs until evictions - name: Create multi node Kind cluster - run: | - kind create cluster --name kind --config ./hack/kind_config.yaml --wait 2m + run: make kind-multi-node # helm-extra-set-args only available after ct 3.6.0 - name: Run chart-testing (install) diff --git a/Makefile b/Makefile index 5e8d202a25..f667d23b46 100644 --- a/Makefile +++ b/Makefile @@ -153,3 +153,6 @@ test-helm: ensure-helm-install kind-multi-node: kind create cluster --name kind --config ./hack/kind_config.yaml --wait 2m + +ct-helm: + ./hack/verify-chart.sh diff --git a/charts/descheduler/templates/tests/test-descheduler-pod.yaml b/charts/descheduler/templates/tests/test-descheduler-pod.yaml deleted file mode 100644 index cf646e4622..0000000000 --- a/charts/descheduler/templates/tests/test-descheduler-pod.yaml +++ /dev/null @@ -1,30 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: descheduler-test-pod - namespace: {{ .Release.Namespace }} - annotations: - "helm.sh/hook": test -spec: - restartPolicy: Never - serviceAccountName: descheduler-ci - containers: - - name: descheduler-test-container - image: alpine:latest - imagePullPolicy: IfNotPresent - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - All - privileged: false - runAsNonRoot: false - command: ["/bin/ash"] - args: - - -c - - >- - apk --no-cache add curl && - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && - chmod +x ./kubectl && - mv ./kubectl /usr/local/bin/kubectl && - /usr/local/bin/kubectl get pods --namespace {{ .Release.Namespace }} --token "$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" | grep "descheduler" | grep "Completed" diff --git a/docs/contributor-guide.md b/docs/contributor-guide.md index ef3fe54f19..39ed70b981 100644 --- a/docs/contributor-guide.md +++ b/docs/contributor-guide.md @@ -39,18 +39,6 @@ make test-unit make test-e2e ``` -## Run Helm Tests -Run the helm test for a particular descheduler release by setting below variables, -``` -HELM_IMAGE_REPO="descheduler" -HELM_IMAGE_TAG="helm-test" -HELM_CHART_LOCATION="./charts/descheduler" -``` -The helm tests runs as part of descheduler CI. But, to run it manually from the descheduler root, - -``` -make test-helm -``` ## Build Helm Package locally @@ -68,5 +56,15 @@ To check linting of your changes in the helm chart locally you can run: make lint-helm ``` +## Test helm changes locally with kind and ct + +You will need kind and docker (or equivalent) installed. We can use ct public image to avoid installing ct and all its dependencies. + + +``` +make kind-multi-node +make ct-helm +``` + ### Miscellaneous See the [hack directory](https://github.com/kubernetes-sigs/descheduler/tree/master/hack) for additional tools and scripts used for developing the descheduler. diff --git a/test/run-helm-tests.sh b/test/run-helm-tests.sh deleted file mode 100755 index 18e77b30ab..0000000000 --- a/test/run-helm-tests.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2021 The Kubernetes Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -set -o errexit -set -o nounset -set -o pipefail - -K8S_VERSION=${KUBERNETES_VERSION:-v1.24.0} -IMAGE_REPO=${HELM_IMAGE_REPO:-descheduler} -IMAGE_TAG=${HELM_IMAGE_TAG:-helm-test} -CHART_LOCATION=${HELM_CHART_LOCATION:-./charts/descheduler} -VERSION=helm-test make image -wget https://github.com/kubernetes-sigs/kind/releases/download/v0.13.0/kind-linux-amd64 -chmod +x kind-linux-amd64 -mv kind-linux-amd64 kind -export PATH=$PATH:$PWD -kind create cluster --image kindest/node:"${K8S_VERSION}" --config=./hack/kind_config.yaml -kind load docker-image descheduler:helm-test -helm install descheduler-ci --set image.repository="${IMAGE_REPO}",image.tag="${IMAGE_TAG}",schedule="* * * * *" --namespace kube-system "${CHART_LOCATION}" -sleep 61 # sleep until Job is triggered -helm test descheduler-ci --namespace kube-system - -# Delete kind cluster once test is finished -kind delete cluster