Skip to content

⚠️ Split Helm chart into operator and providers charts with optional dependency #12

⚠️ Split Helm chart into operator and providers charts with optional dependency

⚠️ Split Helm chart into operator and providers charts with optional dependency #12

Workflow file for this run

name: Smoke Test
on:
pull_request:
branches:
- main
- 'release-*'
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
smoke-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
- name: Install Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Build Docker image
run: |
# Build the operator image with a specific tag for smoke test
CONTROLLER_IMG=cluster-api-operator TAG=smoke-test make docker-build
echo "Built image: cluster-api-operator-amd64:smoke-test"
# Tag the image for easier reference
docker tag cluster-api-operator-amd64:smoke-test cluster-api-operator:smoke-test
- name: Build charts
run: |
make release-chart
# Extract HELM_CHART_TAG from Makefile
HELM_CHART_TAG=$(make -s -f Makefile -p | grep '^HELM_CHART_TAG :=' | cut -d' ' -f3)
echo "HELM_CHART_TAG=$HELM_CHART_TAG" >> $GITHUB_ENV
echo "Detected HELM_CHART_TAG: $HELM_CHART_TAG"
- name: Create kind cluster
run: |
chmod +x ./hack/ensure-kind.sh
./hack/ensure-kind.sh
kind create cluster --name capi-operator-smoke-test --wait 5m
kubectl cluster-info --context kind-capi-operator-smoke-test
- name: Load Docker image to kind
run: |
# Load the built image into kind cluster
kind load docker-image cluster-api-operator:smoke-test --name capi-operator-smoke-test
echo "Loaded image cluster-api-operator:smoke-test into kind cluster"
- name: Add Helm repositories
run: |
helm repo add jetstack https://charts.jetstack.io
helm repo update
- name: Install cert-manager
run: |
helm install cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--set installCRDs=true \
--wait \
--timeout 5m
- name: Install Cluster API Operator
run: |
# Use exact chart filename based on HELM_CHART_TAG
CHART_PACKAGE="out/package/cluster-api-operator-${HELM_CHART_TAG}.tgz"
echo "Using chart package: $CHART_PACKAGE"
# Verify the file exists
if [ ! -f "$CHART_PACKAGE" ]; then
echo "Error: Chart package not found: $CHART_PACKAGE"
ls -la out/package/
exit 1
fi
helm install capi-operator "$CHART_PACKAGE" \
--create-namespace \
-n capi-operator-system \
--set image.manager.repository=cluster-api-operator \
--set image.manager.tag=smoke-test \
--set image.manager.pullPolicy=IfNotPresent \
--wait \
--timeout 90s
- name: Wait for CAPI Operator to be ready
run: |
kubectl wait --for=condition=Available --timeout=300s -n capi-operator-system deployment/capi-operator-cluster-api-operator
- name: Deploy providers using cluster-api-operator-providers chart
run: |
# Create values file for providers
cat <<EOF > /tmp/providers-values.yaml
core:
cluster-api:
namespace: capi-system
infrastructure:
docker:
namespace: capd-system
configSecret:
name: credentials-secret
namespace: default
EOF
# Use exact providers chart filename based on HELM_CHART_TAG
PROVIDERS_CHART_PACKAGE="out/package/cluster-api-operator-providers-${HELM_CHART_TAG}.tgz"
echo "Using providers chart package: $PROVIDERS_CHART_PACKAGE"
# Verify the file exists
if [ ! -f "$PROVIDERS_CHART_PACKAGE" ]; then
echo "Error: Providers chart package not found: $PROVIDERS_CHART_PACKAGE"
ls -la out/package/
exit 1
fi
helm install capi-providers "$PROVIDERS_CHART_PACKAGE" \
-f /tmp/providers-values.yaml \
--wait
- name: Wait for providers to be ready
run: |
echo "Waiting for Core Provider to be ready..."
kubectl wait --for=condition=Ready --timeout=300s -n capi-system coreprovider/cluster-api || true
echo "Waiting for Infrastructure Provider to be ready..."
kubectl wait --for=condition=Ready --timeout=300s -n capd-system infrastructureprovider/docker || true
# Additional wait for deployments
kubectl wait --for=condition=Available --timeout=300s -n capi-system deployment/capi-controller-manager || true
kubectl wait --for=condition=Available --timeout=300s -n capd-system deployment/capd-controller-manager || true
- name: Verify installation
run: |
echo "=== Cluster API Operator Status ==="
kubectl get pods -n capi-operator-system
echo -e "\n=== Core Provider Status ==="
kubectl get coreprovider -A -o wide
kubectl describe coreprovider -n capi-system cluster-api || true
echo -e "\n=== Infrastructure Provider Status ==="
kubectl get infrastructureprovider -A -o wide
kubectl describe infrastructureprovider -n capd-system docker || true
echo -e "\n=== All Pods ==="
kubectl get pods -A | grep -E "(capi-|capd-)"
echo -e "\n=== CRDs ==="
kubectl get crds | grep -E "(cluster.x-k8s.io|operator.cluster.x-k8s.io)"
- name: Check provider health
run: |
# Check if core provider is ready
CORE_READY=$(kubectl get coreprovider -n capi-system cluster-api -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
if [ "$CORE_READY" != "True" ]; then
echo "Core provider is not ready"
kubectl get coreprovider -n capi-system cluster-api -o yaml
exit 1
fi
# Check if infrastructure provider is ready
INFRA_READY=$(kubectl get infrastructureprovider -n capd-system docker -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}')
if [ "$INFRA_READY" != "True" ]; then
echo "Infrastructure provider is not ready"
kubectl get infrastructureprovider -n capd-system docker -o yaml
exit 1
fi
echo "All providers are ready!"
- name: Collect debug information on failure
if: failure()
run: |
echo "=== Events ==="
kubectl get events -A --sort-by='.lastTimestamp' | tail -50
echo -e "\n=== CAPI Operator Logs ==="
kubectl logs -n capi-operator-system deployment/capi-operator-cluster-api-operator --tail=100 || true
echo -e "\n=== Core Provider Logs ==="
kubectl logs -n capi-system deployment/capi-controller-manager --tail=100 || true
echo -e "\n=== Infrastructure Provider Logs ==="
kubectl logs -n capd-system deployment/capd-controller-manager --tail=100 || true
echo -e "\n=== Describe Failed Pods ==="
kubectl get pods -A | grep -v Running | grep -v Completed | tail -n +2 | while read namespace name ready status restarts age; do
echo "Describing pod $name in namespace $namespace"
kubectl describe pod -n $namespace $name
echo "---"
done
- name: Clean up
if: always()
run: |
kind delete cluster --name capi-operator-smoke-test || true