mirror of
https://github.com/gomods/athens
synced 2026-02-03 11:00:32 +00:00
* use circleci for chart testing * update ct flags * trigger ci * restore circleci config
100 lines
2.4 KiB
Bash
Executable File
100 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
readonly CLUSTER_NAME=chart-testing
|
|
|
|
run_ct_container() {
|
|
echo 'Running ct container...'
|
|
docker run --rm --interactive --detach --network host --name ct \
|
|
--volume "$(pwd):/workdir" \
|
|
--workdir /workdir \
|
|
"$CHART_TESTING_IMAGE:$CHART_TESTING_TAG" \
|
|
cat
|
|
echo
|
|
}
|
|
|
|
cleanup() {
|
|
echo 'Removing ct container...'
|
|
docker kill ct > /dev/null 2>&1
|
|
|
|
echo 'Done!'
|
|
}
|
|
|
|
docker_exec() {
|
|
docker exec --interactive -e HELM_HOST=127.0.0.1:44134 -e HELM_TILLER_SILENT=true ct "$@"
|
|
}
|
|
|
|
create_kind_cluster() {
|
|
echo 'Installing kind...'
|
|
|
|
curl -sSLo kind "https://github.com/kubernetes-sigs/kind/releases/download/$KIND_VERSION/kind-linux-amd64"
|
|
chmod +x kind
|
|
sudo mv kind /usr/local/bin/kind
|
|
|
|
kind create cluster --name "$CLUSTER_NAME" --image "kindest/node:$K8S_VERSION"
|
|
|
|
docker_exec mkdir -p /root/.kube
|
|
|
|
echo 'Copying kubeconfig to container...'
|
|
local kubeconfig
|
|
kubeconfig="$(kind get kubeconfig-path --name "$CLUSTER_NAME")"
|
|
docker cp "$kubeconfig" ct:/root/.kube/config
|
|
|
|
docker_exec kubectl cluster-info
|
|
echo
|
|
|
|
echo -n 'Waiting for cluster to be ready...'
|
|
until ! grep --quiet 'NotReady' <(docker_exec kubectl get nodes --no-headers); do
|
|
printf '.'
|
|
sleep 1
|
|
done
|
|
|
|
echo '✔︎'
|
|
echo
|
|
|
|
docker_exec kubectl get nodes
|
|
echo
|
|
|
|
echo 'Cluster ready!'
|
|
echo
|
|
}
|
|
|
|
install_local-path-provisioner() {
|
|
# Remove default storage class. It will be recreated by local-path-provisioner
|
|
docker_exec kubectl delete storageclass standard
|
|
|
|
echo 'Installing local-path-provisioner...'
|
|
docker_exec kubectl apply -f test/local-path-provisioner.yaml
|
|
echo
|
|
}
|
|
|
|
install_tiller() {
|
|
docker_exec apk add bash
|
|
echo "Install Tillerless Helm plugin..."
|
|
docker_exec helm init --client-only
|
|
docker_exec helm plugin install https://github.com/rimusz/helm-tiller
|
|
docker_exec bash -c 'echo "Starting Tiller..."; helm tiller start-ci >/dev/null 2>&1 &'
|
|
docker_exec bash -c 'echo "Waiting Tiller to launch on 44134..."; while ! nc -z localhost 44134; do sleep 1; done; echo "Tiller launched..."'
|
|
echo
|
|
}
|
|
|
|
install_charts() {
|
|
docker_exec ct lint-and-install --config /workdir/test/ct.yaml
|
|
echo
|
|
}
|
|
|
|
main() {
|
|
run_ct_container
|
|
trap cleanup EXIT
|
|
|
|
create_kind_cluster
|
|
install_local-path-provisioner
|
|
install_tiller
|
|
install_charts
|
|
}
|
|
|
|
main
|