magnum-capi-helm-charts/.github/workflows/test.yaml
2023-02-22 12:08:44 +00:00

279 lines
9.2 KiB
YAML

name: Test Helm Charts
on:
workflow_call:
jobs:
install:
runs-on: ubuntu-latest
strategy:
matrix:
version: [kube-1-23, kube-1-24, kube-1-25, kube-1-26]
capi: ["v1.3.2"]
capo: ["v0.7.0-stackhpc.3"]
addonprovider: ["0.1.0-dev.0.main.21"]
shouldNotRun:
- ${{ github.event.pull_request.draft }}
exclude:
- version: kube-1-23
shouldNotRun: true
- version: kube-1-24
shouldNotRun: true
- version: kube-1-25
shouldNotRun: true
max-parallel: 1
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install tools
run: sudo apt install -y zip unzip
- name: Install sonobuoy
run: >
wget https://github.com/vmware-tanzu/sonobuoy/releases/download/v0.56.12/sonobuoy_0.56.12_linux_amd64.tar.gz
&& tar -xf sonobuoy_0.56.12_linux_amd64.tar.gz
&& sudo mv -n sonobuoy /usr/bin/
- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.5.0
- name: Install cert-manager
run: |-
helm upgrade cert-manager cert-manager \
--repo https://charts.jetstack.io \
--version v1.10.1 \
--namespace cert-manager \
--create-namespace \
--install \
--set installCRDs=true \
--wait \
--timeout 10m
- name: Ensure Cluster API kustomization directory exists
run: mkdir -p clusterapi
# From here: https://github.com/stackhpc/ansible-collection-azimuth-ops/blob/main/roles/clusterapi/defaults/main.yml
- name: Write Cluster API kustomization file
uses: DamianReeves/write-file-action@master
with:
path: clusterapi/kustomization.yaml
write-mode: overwrite
contents: |
resources:
- https://github.com/kubernetes-sigs/cluster-api/releases/download/${{ matrix.capi }}/cluster-api-components.yaml
- https://github.com/stackhpc/cluster-api-provider-openstack/releases/download/${{ matrix.capo }}/infrastructure-components.yaml
patches:
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/args
value:
- --leader-elect
- --metrics-bind-addr=localhost:8080
target:
kind: Deployment
namespace: capi-system
name: capi-controller-manager
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/args
value:
- --leader-elect
- --metrics-bind-addr=localhost:8080
target:
kind: Deployment
namespace: capi-kubeadm-bootstrap-system
name: capi-kubeadm-bootstrap-controller-manager
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/args
value:
- --leader-elect
- --metrics-bind-addr=localhost:8080
target:
kind: Deployment
namespace: capi-kubeadm-control-plane-system
name: capi-kubeadm-control-plane-controller-manager
- name: Install Cluster API resources
run: kubectl apply -k clusterapi/
- name: Wait for Cluster API controllers to become ready
run: |-
kubectl rollout status deployment/capi-controller-manager \
--namespace capi-system \
--timeout 5m \
&& \
kubectl rollout status deployment/capi-kubeadm-bootstrap-controller-manager \
--namespace capi-kubeadm-bootstrap-system \
--timeout 5m \
&& \
kubectl rollout status deployment/capi-kubeadm-control-plane-controller-manager \
--namespace capi-kubeadm-control-plane-system \
--timeout 5m \
&& \
kubectl rollout status deployment/capo-controller-manager \
--namespace capo-system \
--timeout 10m
- name: Install Cluster API add-on provider
run: |-
helm upgrade cluster-api-addon-provider cluster-api-addon-provider \
--repo https://stackhpc.github.io/cluster-api-addon-provider \
--version ${{ matrix.addonprovider }} \
--namespace capi-addon-system \
--create-namespace \
--install \
--wait \
--timeout 10m
- name: Write cloud credential
run: 'echo "$CLOUD" > clouds.yml'
shell: bash
env:
CLOUD: ${{ secrets.CLOUD }}
- name: Create cluster
run: |-
helm upgrade ci-${GITHUB_SHA::7}-${{ matrix.version }} ./charts/openstack-cluster \
--install \
--dependency-update \
--values clouds.yml \
--values charts/openstack-cluster/ci/${{ matrix.version }}-ha-values.yaml
- name: Wait for cluster READY
run: |-
kubectl wait clusters.cluster.x-k8s.io/ci-${GITHUB_SHA::7}-${{ matrix.version }} \
--for=condition=Ready \
--timeout 30m
- name: Wait for addons to deploy
run: |-
kubectl wait manifests \
--all \
--for=jsonpath='{.status.phase}'=Deployed \
--timeout 20m \
&& \
kubectl wait helmreleases \
--all \
--for=jsonpath='{.status.phase}'=Deployed \
--timeout 20m
- name: Write kubeconfig
run: |-
kubectl get secret ci-${GITHUB_SHA::7}-${{ matrix.version }}-kubeconfig \
-o go-template='{{ .data.value | base64decode }}' \
> kubeconfig
- name: Wait for dns pods
run: |-
kubectl wait po \
--namespace kube-system \
--selector k8s-app=kube-dns \
--for=condition=ready \
--timeout 20m
env:
KUBECONFIG: ./kubeconfig
- name: Run sonobuoy [smoke]
timeout-minutes: 20
run: sonobuoy run --mode quick --wait
env:
KUBECONFIG: ./kubeconfig
if: github.event.pull_request.draft == false
- name: Clean sonobuoy
run: sonobuoy delete --wait --all
env:
KUBECONFIG: ./kubeconfig
if: github.event.pull_request.draft == false
- name: Upgrade cluster
run: |-
helm upgrade ci-${GITHUB_SHA::7}-${{ matrix.version }} ./charts/openstack-cluster \
--install \
--dependency-update \
--values clouds.yml \
--values charts/openstack-cluster/ci/${{ matrix.version }}-ha-values-upgrade.yaml
if: github.event.pull_request.draft == false
- name: Wait for cluster NOT READY
run: sleep 3m
if: github.event.pull_request.draft == false
- name: Wait for cluster READY
run: |-
kubectl wait clusters.cluster.x-k8s.io/ci-${GITHUB_SHA::7}-${{ matrix.version }} \
--for=condition=Ready \
--timeout 30m
if: github.event.pull_request.draft == false
- name: Wait for addons to deploy
run: |-
kubectl wait manifests \
--all \
--for=jsonpath='{.status.phase}'=Deployed \
--timeout 20m \
&& \
kubectl wait helmreleases \
--all \
--for=jsonpath='{.status.phase}'=Deployed \
--timeout 20m
if: github.event.pull_request.draft == false
- name: Run sonobuoy [smoke]
timeout-minutes: 20
run: sonobuoy run --mode quick --wait
env:
KUBECONFIG: ./kubeconfig
if: matrix.version != 'kube-1-26' || github.event.pull_request.draft == true
- name: Run sonobuoy full
timeout-minutes: 120
run: sonobuoy run --wait
env:
KUBECONFIG: ./kubeconfig
if: matrix.version == 'kube-1-26' && github.event.pull_request.draft == false
- name: Retrieve sonobuoy results
continue-on-error: true
env:
KUBECONFIG: ./kubeconfig
STATUS_INTERVAL_SEC: 20
run: ./scripts/sonobuoy-artifacts.sh
- name: Upload sonobuoy log artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: capo-controller
path: ./results.txt
- name: Delete release
if: ${{ always() }}
run: helm delete ci-${GITHUB_SHA::7}-${{ matrix.version }} --wait
- name: Output logs
if: ${{ always() }}
run: |-
kubectl -n capo-system logs \
deploy/capo-controller-manager \
> logs.txt
- name: Upload log artifacts
uses: actions/upload-artifact@v3
if: ${{ always() }}
with:
name: capo-controller
path: logs.txt