Skip to content

Commit

Permalink
Push Helm Chart to Quay and update some pipeline steps (strimzi#88)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Scholz <[email protected]>
  • Loading branch information
scholzj authored Jun 26, 2023
1 parent f813768 commit 48e63c7
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 39 deletions.
17 changes: 16 additions & 1 deletion .azure/release-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ stages:
vmImage: 'Ubuntu-22.04'
# Pipeline steps
steps:
- template: 'templates/steps/setup_java.yaml'
- template: '../steps/prerequisites/install_java.yaml'
parameters:
JDK_VERSION: $(jdk_version)
- bash: ".azure/scripts/release-artifacts.sh"
Expand Down Expand Up @@ -91,3 +91,18 @@ stages:
artifactRunVersion: 'specific'
artifactRunId: '${{ parameters.sourceBuildId }}'
architectures: ['amd64', 'arm64', 's390x', 'ppc64le']
# Publishes the Helm Chart as an OCI artifact to Quay.io
- stage: helm_as_oci_publish
displayName: Publish Helm Chart as OCI artifact
dependsOn:
- prepare_release_artifacts
condition: and(succeeded(), startsWith(variables['build.sourceBranch'], 'refs/heads/release-'))
jobs:
- template: 'templates/jobs/push_helm_chart.yaml'
parameters:
releaseVersion: '${{ parameters.releaseVersion }}'
artifactSource: 'current'
artifactProject: 'strimzi'
artifactPipeline: ''
artifactRunVersion: ''
artifactRunId: ''
27 changes: 27 additions & 0 deletions .azure/scripts/setup-helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -x

TEST_HELM3_VERSION=${TEST_HELM3_VERSION:-'v3.12.0'}

function install_helm3 {
export HELM_INSTALL_DIR=/usr/bin
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
# we need to modify the script with a different path because on the Azure pipelines the HELM_INSTALL_DIR env var is not honoured
sed -i 's#/usr/local/bin#/usr/bin#g' get_helm.sh
chmod 700 get_helm.sh

echo "Installing helm 3..."
sudo ./get_helm.sh --version "${TEST_HELM3_VERSION}"

echo "Verifying the installation of helm binary..."
# run a proper helm command instead of, for example, "which helm", to verify that we can call the binary
helm --help
helmCommandOutput=$?

if [ $helmCommandOutput != 0 ]; then
echo "helm binary hasn't been installed properly - exiting..."
exit 1
fi
}

install_helm3
39 changes: 18 additions & 21 deletions .azure/scripts/setup-kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -xe
rm -rf ~/.kube

KUBE_VERSION=${KUBE_VERSION:-1.21.0}
MINIKUBE_REGISTRY_IMAGE=${REGISTRY_IMAGE:-"registry"}
COPY_DOCKER_LOGIN=${COPY_DOCKER_LOGIN:-"false"}

DEFAULT_MINIKUBE_MEMORY=$(free -m | grep "Mem" | awk '{print $2}')
Expand All @@ -15,23 +16,19 @@ MINIKUBE_CPU=${MINIKUBE_CPU:-$DEFAULT_MINIKUBE_CPU}
echo "[INFO] MINIKUBE_MEMORY: ${MINIKUBE_MEMORY}"
echo "[INFO] MINIKUBE_CPU: ${MINIKUBE_CPU}"

ARCH=$1
if [ -z "$ARCH" ]; then
ARCH="amd64"
fi

function install_kubectl {
if [ "${KUBECTL_VERSION:-latest}" = "latest" ]; then
KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
if [ "${TEST_KUBECTL_VERSION:-latest}" = "latest" ]; then
TEST_KUBECTL_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
fi
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl && chmod +x kubectl
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${TEST_KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl && chmod +x kubectl
sudo cp kubectl /usr/local/bin
}

function install_nsenter {
# Pre-req for helm
curl https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${NSENTER_VERSION}/util-linux-${NSENTER_VERSION}.tar.gz -k | tar -zxf-
cd util-linux-${NSENTER_VERSION}
./configure --without-ncurses
make nsenter
sudo cp nsenter /usr/bin
}

function label_node {
# It should work for all clusters
for nodeName in $(kubectl get nodes -o custom-columns=:.metadata.name --no-headers);
Expand All @@ -41,20 +38,20 @@ function label_node {
done
}

if [ "$KUBE_CLUSTER" = "minikube" ]; then
if [ "$TEST_CLUSTER" = "minikube" ]; then
install_kubectl
if [ "${MINIKUBE_VERSION:-latest}" = "latest" ]; then
MINIKUBE_URL=https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
if [ "${TEST_MINIKUBE_VERSION:-latest}" = "latest" ]; then
TEST_MINIKUBE_URL=https://storage.googleapis.com/minikube/releases/latest/minikube-linux-${ARCH}
else
MINIKUBE_URL=https://github.com/kubernetes/minikube/releases/download/${MINIKUBE_VERSION}/minikube-linux-amd64
TEST_MINIKUBE_URL=https://github.com/kubernetes/minikube/releases/download/${TEST_MINIKUBE_VERSION}/minikube-linux-${ARCH}
fi

if [ "$KUBE_VERSION" != "latest" ] && [ "$KUBE_VERSION" != "stable" ]; then
KUBE_VERSION="v${KUBE_VERSION}"
fi

curl -Lo minikube ${MINIKUBE_URL} && chmod +x minikube
sudo cp minikube /usr/bin
curl -Lo minikube ${TEST_MINIKUBE_URL} && chmod +x minikube
sudo cp minikube /usr/local/bin

export MINIKUBE_WANTUPDATENOTIFICATION=false
export MINIKUBE_WANTREPORTERRORPROMPT=false
Expand All @@ -64,15 +61,15 @@ if [ "$KUBE_CLUSTER" = "minikube" ]; then
mkdir $HOME/.kube || true
touch $HOME/.kube/config

docker run -d -p 5000:5000 registry
docker run -d -p 5000:5000 ${MINIKUBE_REGISTRY_IMAGE}

export KUBECONFIG=$HOME/.kube/config
# We can turn on network polices support by adding the following options --network-plugin=cni --cni=calico
# We have to allow trafic for ITS when NPs are turned on
# We can allow NP after Strimzi#4092 which should fix some issues on STs side
minikube start --vm-driver=docker --kubernetes-version=${KUBE_VERSION} \
--insecure-registry=localhost:5000 --extra-config=apiserver.authorization-mode=Node,RBAC \
--cpus=${MINIKUBE_CPU} --memory=${MINIKUBE_MEMORY}
--cpus=${MINIKUBE_CPU} --memory=${MINIKUBE_MEMORY} --force

if [ $? -ne 0 ]
then
Expand All @@ -97,7 +94,7 @@ if [ "$KUBE_CLUSTER" = "minikube" ]; then

kubectl create clusterrolebinding add-on-cluster-admin --clusterrole=cluster-admin --serviceaccount=kube-system:default
else
echo "Unsupported KUBE_CLUSTER '$KUBE_CLUSTER'"
echo "Unsupported TEST_CLUSTER '$TEST_CLUSTER'"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .azure/templates/jobs/build_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
vmImage: 'Ubuntu-22.04'
# Pipeline steps
steps:
- template: '../steps/setup_docker.yaml'
- template: "../steps/prerequisites/install_docker.yaml"
- task: DownloadPipelineArtifact@2
inputs:
source: '${{ parameters.artifactSource }}'
Expand Down
2 changes: 1 addition & 1 deletion .azure/templates/jobs/build_java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
# Get cached Maven repository
- template: "../steps/maven_cache.yaml"
- template: '../steps/setup_java.yaml'
- template: '../steps/prerequisites/install_java.yaml'
parameters:
JDK_VERSION: $(jdk_version)
- bash: ".azure/scripts/java-build.sh"
Expand Down
2 changes: 1 addition & 1 deletion .azure/templates/jobs/push_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
vmImage: 'Ubuntu-22.04'
# Pipeline steps
steps:
- template: '../steps/setup_docker.yaml'
- template: "../steps/prerequisites/install_docker.yaml"
- ${{ each arch in parameters.architectures }}:
- task: DownloadPipelineArtifact@2
inputs:
Expand Down
40 changes: 40 additions & 0 deletions .azure/templates/jobs/push_helm_chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
jobs:
- job: 'push_helm_chart_oci'
displayName: 'Push Helm Chart as OCI artifact'
# Set timeout for jobs
timeoutInMinutes: 60
# Base system
pool:
vmImage: 'Ubuntu-22.04'
# Pipeline steps
steps:
# Install Prerequisites
- template: "../steps/prerequisites/install_helm.yaml"

# Unpack the release artifacts
- task: DownloadPipelineArtifact@2
inputs:
source: '${{ parameters.artifactSource }}'
artifact: ReleaseArchives
path: $(System.DefaultWorkingDirectory)/
project: '${{ parameters.artifactProject }}'
pipeline: '${{ parameters.artifactPipeline }}'
runVersion: '${{ parameters.artifactRunVersion }}'
runId: '${{ parameters.artifactRunId }}'
- bash: tar -xvf release.tar
displayName: "Untar the release artifacts"

# Login Helm to the OCI Registry
- bash: "helm registry login -u $DOCKER_USER -p $DOCKER_PASS $DOCKER_REGISTRY"
displayName: "Login to OCI registry"
env:
DOCKER_USER: $(QUAY_HELM_USER)
DOCKER_PASS: $(QUAY_HELM_PASS)
DOCKER_REGISTRY: "quay.io"

# Push the Helm Chart to the OCI Registry
- bash: "helm push strimzi-drain-cleaner-helm-3-chart-${{ parameters.releaseVersion }}.tgz oci://$DOCKER_REGISTRY/$DOCKER_ORG"
displayName: "Push Helm Chart OCI artifact"
env:
DOCKER_REGISTRY: "quay.io"
DOCKER_ORG: "strimzi-helm"
6 changes: 3 additions & 3 deletions .azure/templates/jobs/run_systemtests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
vmImage: $(image)
timeoutInMinutes: 20
steps:
- template: '../steps/setup_java.yaml'
- template: '../steps/prerequisites/install_java.yaml'
parameters:
JDK_VERSION: $(jdk_version)
- template: '../steps/setup_docker.yaml'
- template: '../steps/setup_minikube.yaml'
- template: "../steps/prerequisites/install_docker.yaml"
- template: "../steps/prerequisites/install_minikube.yaml"
- task: DownloadPipelineArtifact@2
inputs:
source: current
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Steps needed for local Docker installation
steps:
- task: DockerInstaller@0
displayName: Docker Installer
displayName: Install Docker
inputs:
dockerVersion: 20.10.8
releaseType: stable
Expand Down
5 changes: 5 additions & 0 deletions .azure/templates/steps/prerequisites/install_helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- bash: ".azure/scripts/setup-helm.sh"
displayName: "Install Helm"
env:
TEST_HELM3_VERSION: 'v3.12.0'
File renamed without changes.
7 changes: 7 additions & 0 deletions .azure/templates/steps/prerequisites/install_minikube.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- bash: ".azure/scripts/setup-kubernetes.sh"
displayName: "Setup Minikube cluster"
env:
TEST_CLUSTER: minikube
TEST_KUBECTL_VERSION: latest
TEST_MINIKUBE_VERSION: latest
10 changes: 0 additions & 10 deletions .azure/templates/steps/setup_minikube.yaml

This file was deleted.

0 comments on commit 48e63c7

Please sign in to comment.