89 lines
3.1 KiB
YAML
89 lines
3.1 KiB
YAML
on:
|
|
pull_request:
|
|
|
|
jobs:
|
|
validate:
|
|
runs-on: docker
|
|
defaults:
|
|
run:
|
|
shell: sh
|
|
env:
|
|
DOCKER_HOST: tcp://172.17.0.1:2375
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Validate manifests
|
|
run: |
|
|
kubeconform \
|
|
-strict \
|
|
-summary \
|
|
-ignore-missing-schemas \
|
|
-schema-location default \
|
|
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
|
|
./manifests/
|
|
|
|
- name: Create test cluster
|
|
run: k3d cluster create test --wait
|
|
|
|
- name: Install ArgoCD
|
|
run: |
|
|
kubectl create namespace argocd
|
|
kubectl apply -n argocd --server-side -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
|
|
kubectl apply -f https://github.com/bitnami-labs/sealed-secrets/releases/download/v0.27.0/controller.yaml
|
|
kubectl wait --for=condition=available --timeout=180s \
|
|
deployment/argocd-server \
|
|
deployment/argocd-repo-server \
|
|
deployment/argocd-applicationset-controller \
|
|
-n argocd
|
|
kubectl wait --for=condition=available --timeout=60s \
|
|
deployment/sealed-secrets-controller -n kube-system
|
|
|
|
- name: Import SealedSecrets key
|
|
env:
|
|
SEALED_SECRETS_KEY: ${{ secrets.SEALED_SECRETS_KEY }}
|
|
run: |
|
|
echo "$SEALED_SECRETS_KEY" | kubectl apply -f -
|
|
kubectl rollout restart deployment/sealed-secrets-controller -n kube-system
|
|
kubectl rollout status deployment/sealed-secrets-controller -n kube-system --timeout=60s
|
|
|
|
- name: Apply ArgoCD apps
|
|
run: |
|
|
for f in apps/*.yaml; do
|
|
case "$f" in
|
|
apps/longhorn.yaml) echo "Skipping $f" ;;
|
|
*) kubectl apply -f "$f" ;;
|
|
esac
|
|
done
|
|
|
|
- name: Wait for ArgoCD sync
|
|
run: |
|
|
kubectl wait applications \
|
|
--all \
|
|
--namespace argocd \
|
|
--for=jsonpath='{.status.health.status}'=Healthy \
|
|
--timeout=300s
|
|
|
|
- name: Debug on failure
|
|
if: failure()
|
|
run: |
|
|
echo "=== Applications ==="
|
|
kubectl get applications -n argocd
|
|
echo "=== Pods (all namespaces) ==="
|
|
kubectl get pods --all-namespaces
|
|
echo "=== Failed pods logs ==="
|
|
kubectl get pods --all-namespaces --field-selector=status.phase!=Running,status.phase!=Succeeded \
|
|
-o jsonpath='{range .items[*]}{.metadata.namespace}{" "}{.metadata.name}{"\n"}{end}' | \
|
|
while read ns pod; do
|
|
echo "--- $ns/$pod ---"
|
|
kubectl logs -n $ns $pod --all-containers --tail=50 2>/dev/null || true
|
|
done
|
|
echo "=== Events ==="
|
|
kubectl get events --all-namespaces --sort-by='.lastTimestamp' | tail -50
|
|
|
|
- name: Wait for all deployments
|
|
run: kubectl wait --for=condition=available --timeout=300s deployment --all --all-namespaces
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: k3d cluster delete test
|