Skip to content

Commit

Permalink
SONAR-23305 Test the helm charts with a local cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
carminevassallo committed Nov 5, 2024
1 parent 4951d66 commit 2eeb9a0
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 21 deletions.
11 changes: 0 additions & 11 deletions .cirrus/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ ARG CHART_TESTING_VERSION=3.11.0
ARG CHART_TESTING_HASHSUM="38914f285ce309f86a876522640a27b57840a435d3480195f0878e104f1e8044"
ARG YAMLLINT_VERSION=1.35.1
ARG YAMALE_VERSION=5.2.1
ARG AH_VERSION=1.19.0
ARG AH_CHECKSUM="0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5"
ARG YQ_VERSION=4.44.3
ARG YQ_CHECKSUM="a2c097180dd884a8d50c956ee16a9cec070f30a7947cf4ebf87d5f36213e9ed7"
ARG KUBECONFORM_VERSION=0.6.7
Expand Down Expand Up @@ -79,15 +77,6 @@ RUN set -eux; \
mv ./ct /usr/bin/ct ; \
rm chart-testing_${CHART_TESTING_VERSION}_linux_amd64.tar.gz

RUN set -eux; \
curl -LO https://github.com/artifacthub/hub/releases/download/v${AH_VERSION}/ah_${AH_VERSION}_linux_amd64.tar.gz ; \
echo "${AH_CHECKSUM} ah_${AH_VERSION}_linux_amd64.tar.gz" | sha256sum -c ; \
tar -xf ah_${AH_VERSION}_linux_amd64.tar.gz ; \
chmod +x ./ah ; \
mv ./ah /usr/bin/ah ; \
rm LICENSE; \
rm -rf ah_${AH_VERSION}_linux_amd64.tar.gz

RUN set -eux; \
curl -LO https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_amd64 ; \
echo "${YQ_CHECKSUM} yq_linux_amd64" | sha256sum -c ; \
Expand Down
75 changes: 75 additions & 0 deletions .cirrus/setup_kind_vm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/bin/bash

set -euo pipefail

export DEBIAN_FRONTEND=noninteractive

apt-get update -y

# Install docker
apt-get install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker

# Install chart-testing
YAMLLINT_VERSION=1.35.1
YAMALE_VERSION=5.2.1
CHART_TESTING_VERSION=3.11.0
CHART_TESTING_HASHSUM="38914f285ce309f86a876522640a27b57840a435d3480195f0878e104f1e8044"
curl -LO https://github.com/helm/chart-testing/releases/download/v${CHART_TESTING_VERSION}/chart-testing_${CHART_TESTING_VERSION}_linux_amd64.tar.gz
echo "${CHART_TESTING_HASHSUM} chart-testing_${CHART_TESTING_VERSION}_linux_amd64.tar.gz" | sha256sum -c
tar -xf chart-testing_${CHART_TESTING_VERSION}_linux_amd64.tar.gz
chmod +x ./ct
mkdir -p /etc/ct
mv etc/chart_schema.yaml /etc/ct/chart_schema.yaml
mv etc/lintconf.yaml /etc/ct/lintconf.yaml
mv ./ct /usr/bin/ct
rm chart-testing_${CHART_TESTING_VERSION}_linux_amd64.tar.gz
pip install "yamllint==${YAMLLINT_VERSION}"
pip install "yamale==${YAMALE_VERSION}"

# Install kubectl
KUBECTL_VERSION=1.31.0
curl -LO https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl
curl -LO https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256
printf %s " kubectl" >> kubectl.sha256
sha256sum -c kubectl.sha256
chmod +x ./kubectl
mv ./kubectl /usr/bin/kubectl
rm kubectl.sha256

# Install helm
HELM_VERSION=3.16.1
HELM_CHECKSUM="e57e826410269d72be3113333dbfaac0d8dfdd1b0cc4e9cb08bdf97722731ca9"
curl -LO https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz
echo "${HELM_CHECKSUM} helm-v${HELM_VERSION}-linux-amd64.tar.gz" | sha256sum -c
tar -xf helm-v${HELM_VERSION}-linux-amd64.tar.gz
chmod +x ./linux-amd64/helm
mv ./linux-amd64/helm /usr/bin/helm
rm -rf ./linux-amd64
rm helm-v${HELM_VERSION}-linux-amd64.tar.gz

# Install kind
KIND_VERSION=0.24.0
KIND_CHECKSUM="b89aada5a39d620da3fcd16435b7f28d858927dd53f92cbac77686b0588b600d"
curl -LO https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-amd64
echo "${KIND_CHECKSUM} kind-linux-amd64" | sha256sum -c
chmod +x ./kind-linux-amd64
mv ./kind-linux-amd64 /usr/local/bin/kind

# Install artifacthub lint
AH_VERSION=1.19.0
AH_CHECKSUM="0e430493521ce387ca04d79b26646a86f92886dbcceb44985bb71082a9530ca5"
curl -LO https://github.com/artifacthub/hub/releases/download/v${AH_VERSION}/ah_${AH_VERSION}_linux_amd64.tar.gz
echo "${AH_CHECKSUM} ah_${AH_VERSION}_linux_amd64.tar.gz" | sha256sum -c
tar -xf ah_${AH_VERSION}_linux_amd64.tar.gz
chmod +x ./ah
mv ./ah /usr/bin/ah
rm LICENSE
rm -rf ah_${AH_VERSION}_linux_amd64.tar.gz

docker --version
ct version
kubectl version --client
helm version
kind version
21 changes: 11 additions & 10 deletions .cirrus/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ docker_build_container_template: &CONTAINER_TEMPLATE
cluster_name: ${CIRRUS_CLUSTER_NAME}
builder_role: cirrus-builder
builder_image: docker-builder-v*
builder_instance_type: t2.small
builder_instance_type: t2.large
region: eu-central-1
namespace: default
cpu: 1
Expand All @@ -46,8 +46,10 @@ container_template: &STD_CONTAINER_TEMPLATE

vm_instance_template: &VM_TEMPLATE
image: docker-builder-v*
type: t2.small
type: t2.xlarge
region: eu-central-1
cpu: 4
memory: 16Gb

clone_script_template: &CLONE_SCRIPT_TEMPLATE
clone_script: |
Expand Down Expand Up @@ -164,22 +166,21 @@ chart_fixture_test_task:
chart_testing_on_eks_task:
<<: *ONLY_ON_NON_RELEASE_DRAFT_TEMPLATE
timeout_in: 30m
eks_container:
<<: *CONTAINER_TEMPLATE
cpu: 2
memory: 4Gb
ec2_instance:
<<: *VM_TEMPLATE
<<: *CLONE_SCRIPT_TEMPLATE
authenticate_to_eks_script:
- ./.cirrus/eks.sh
- kubectl get nodes
setup_script:
- ./.cirrus/setup_kind_vm.sh
- kind create cluster
- kubectl cluster-info --context kind-kind
- kubectl get nodes
- kubectl create namespace test --dry-run=client -o yaml | kubectl apply -f -
- kubectl create secret docker-registry pullsecret --namespace test --docker-username=${DOCKER_USERNAME} --docker-password=${DOCKER_PASSWORD} --dry-run=client -o yaml | kubectl apply -f -
script:
- ct lint --config test.yaml --all
- ct install --namespace test --config test.yaml --all --debug
teardown_script:
- kubectl delete namespace test
- kind delete cluster
artifacthub_lint_script:
- ah lint
depends_on:
Expand Down

0 comments on commit 2eeb9a0

Please sign in to comment.