GCP cloud build integration and chart lint and install test
parent
25d6b67936
commit
4e7d30b376
|
@ -19,3 +19,53 @@ jobs:
|
||||||
# specify any bash command here prefixed with `run: `
|
# specify any bash command here prefixed with `run: `
|
||||||
- run: make build
|
- run: make build
|
||||||
- run: make test
|
- run: make test
|
||||||
|
lint-scripts:
|
||||||
|
docker:
|
||||||
|
- image: koalaman/shellcheck-alpine
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: lint
|
||||||
|
command: |
|
||||||
|
shellcheck -x .scripts/gen_packages.sh
|
||||||
|
shellcheck -x .scripts/index_repo.sh
|
||||||
|
shellcheck -x .test/e2e-kind.sh
|
||||||
|
lint-charts:
|
||||||
|
docker:
|
||||||
|
- image: quay.io/helmpack/chart-testing:v2.0.1
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: lint
|
||||||
|
command: |
|
||||||
|
git remote add k8s https://github.com/keel-hq/keel
|
||||||
|
git fetch k8s master
|
||||||
|
ct lint --config .test/ct.yaml
|
||||||
|
install-charts:
|
||||||
|
machine: true
|
||||||
|
environment:
|
||||||
|
CHART_TESTING_IMAGE: quay.io/helmpack/chart-testing
|
||||||
|
CHART_TESTING_TAG: v2.0.1
|
||||||
|
CHARTS_REPO: https://github.com/keel-hq/keel
|
||||||
|
K8S_VERSION: v1.11.3
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: install
|
||||||
|
command: |
|
||||||
|
.test/e2e-kind.sh
|
||||||
|
no_output_timeout: 3600
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build_lint_and_install:
|
||||||
|
jobs:
|
||||||
|
- build
|
||||||
|
- lint-scripts:
|
||||||
|
requires:
|
||||||
|
- build
|
||||||
|
- lint-charts:
|
||||||
|
requires:
|
||||||
|
- lint-scripts
|
||||||
|
- install-charts:
|
||||||
|
requires:
|
||||||
|
- lint-charts
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
steps:
|
||||||
|
|
||||||
|
# Generate Helm packages
|
||||||
|
- name: 'ubuntu'
|
||||||
|
args: ['bash', './.scripts/gen_packages.sh']
|
||||||
|
id: 'gen_packages'
|
||||||
|
|
||||||
|
# Fetch charts and index.yaml from GCS bucket
|
||||||
|
- name: 'gcr.io/cloud-builders/gsutil'
|
||||||
|
args: ['rsync', 'gs://charts.keel.sh', 'temp/']
|
||||||
|
id: 'fetch_charts_index'
|
||||||
|
|
||||||
|
# Index repository
|
||||||
|
- name: 'ubuntu'
|
||||||
|
env:
|
||||||
|
- 'REPO_URL=https://charts.keel.sh'
|
||||||
|
args: ['bash', './.scripts/index_repo.sh']
|
||||||
|
|
||||||
|
# Upload charts to GCS bucket
|
||||||
|
- name: gcr.io/cloud-builders/gsutil
|
||||||
|
args: ['rsync', 'temp/', 'gs://charts.keel.sh']
|
||||||
|
id: 'upload_charts'
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Installing curl"
|
||||||
|
apt update
|
||||||
|
apt install curl -y
|
||||||
|
|
||||||
|
echo "Installing helm"
|
||||||
|
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
|
||||||
|
helm init -c
|
||||||
|
|
||||||
|
echo "Packaging charts from source code"
|
||||||
|
mkdir -p temp
|
||||||
|
for d in stable/*
|
||||||
|
do
|
||||||
|
# shellcheck disable=SC2039
|
||||||
|
if [[ -d $d ]]
|
||||||
|
then
|
||||||
|
# Will generate a helm package per chart in a folder
|
||||||
|
echo "$d"
|
||||||
|
helm package "$d"
|
||||||
|
# shellcheck disable=SC2035
|
||||||
|
mv *.tgz temp/
|
||||||
|
fi
|
||||||
|
done
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Installing curl"
|
||||||
|
apt update
|
||||||
|
apt install curl -y
|
||||||
|
|
||||||
|
echo "Installing helm"
|
||||||
|
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash
|
||||||
|
helm init -c
|
||||||
|
|
||||||
|
echo "Indexing repository"
|
||||||
|
if [ -f index.yaml ]; then
|
||||||
|
helm repo index --url "${REPO_URL}" --merge index.yaml ./temp
|
||||||
|
else
|
||||||
|
helm repo index --url "${REPO_URL}" ./temp
|
||||||
|
fi
|
|
@ -0,0 +1,7 @@
|
||||||
|
remote: k8s
|
||||||
|
target-branch: master
|
||||||
|
chart-dirs:
|
||||||
|
- chart
|
||||||
|
excluded-charts:
|
||||||
|
- common
|
||||||
|
helm-extra-args: --timeout 800
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o nounset
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
readonly REPO_ROOT="${REPO_ROOT:-$(git rev-parse --show-toplevel)}"
|
||||||
|
|
||||||
|
run_kind() {
|
||||||
|
|
||||||
|
echo "Get kind binary..."
|
||||||
|
# docker run --rm -it -v "$(pwd)":/go/bin golang go get sigs.k8s.io/kind && chmod +x kind && sudo mv kind /usr/local/bin/
|
||||||
|
curl -Lo kind https://storage.googleapis.com/rimusz-ci-artifacts/kind && chmod +x kind && sudo mv kind /usr/local/bin/
|
||||||
|
|
||||||
|
|
||||||
|
echo "Download kubectl..."
|
||||||
|
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/"${K8S_VERSION}"/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Create Kubernetes cluster with kind..."
|
||||||
|
kind create cluster --image=kindest/node:"$K8S_VERSION"
|
||||||
|
|
||||||
|
echo "Export kubeconfig..."
|
||||||
|
# shellcheck disable=SC2155
|
||||||
|
export KUBECONFIG="$(kind get kubeconfig-path)"
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Ensure the apiserver is responding..."
|
||||||
|
kubectl cluster-info
|
||||||
|
echo
|
||||||
|
|
||||||
|
echo "Wait for Kubernetes to be up and ready..."
|
||||||
|
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
|
||||||
|
echo "Starting kind ..."
|
||||||
|
echo
|
||||||
|
run_kind
|
||||||
|
|
||||||
|
local config_container_id
|
||||||
|
config_container_id=$(docker run -it -d -v "$REPO_ROOT:/workdir" --workdir /workdir "$CHART_TESTING_IMAGE:$CHART_TESTING_TAG" cat)
|
||||||
|
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "docker rm -f $config_container_id > /dev/null" EXIT
|
||||||
|
|
||||||
|
# Get kind container IP
|
||||||
|
kind_container_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kind-1-control-plane)
|
||||||
|
# Copy kubeconfig file
|
||||||
|
docker exec "$config_container_id" mkdir /root/.kube
|
||||||
|
docker cp "$KUBECONFIG" "$config_container_id:/root/.kube/config"
|
||||||
|
# Update in kubeconfig localhost to kind container IP
|
||||||
|
docker exec "$config_container_id" sed -i "s/localhost/$kind_container_ip/g" /root/.kube/config
|
||||||
|
|
||||||
|
echo "Add git remote k8s ${CHARTS_REPO}"
|
||||||
|
git remote add k8s "${CHARTS_REPO}" &> /dev/null || true
|
||||||
|
git fetch k8s master
|
||||||
|
echo
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
docker exec "$config_container_id" ct install --config /workdir/.test/ct.yaml
|
||||||
|
|
||||||
|
echo "Done Testing!"
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
Loading…
Reference in New Issue