81 lines
3.7 KiB
YAML
81 lines
3.7 KiB
YAML
name: Validate and deploy Kubernetes Dashboard
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
env:
|
|
DASHBOARD_CHART_VERSION: 7.14.0
|
|
DASHBOARD_CHART_SHA256: 37be462a39258fda57a2a5e5d81082d8d28a8083c7977f4f4632fa374b1a616d
|
|
HELM_VERSION: v4.2.2
|
|
HELM_SHA256: 9adafecab4d406853bba163a70e9f104f47dbbf65ce24b7653bae7e36150bcb6
|
|
KUBECTL_VERSION: v1.36.3
|
|
KUBERNETES_API: https://host.containers.internal:6443
|
|
KUBERNETES_TLS_SERVER_NAME: 192.168.0.2
|
|
NAMESPACE: kubernetes-dashboard
|
|
|
|
jobs:
|
|
validate:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pinned Helm
|
|
run: |
|
|
curl -fsSL -o "${RUNNER_TEMP}/helm.tgz" "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
|
printf '%s %s\n' "${HELM_SHA256}" "${RUNNER_TEMP}/helm.tgz" | sha256sum --check
|
|
tar -xzf "${RUNNER_TEMP}/helm.tgz" -C "${RUNNER_TEMP}" --strip-components=1 linux-amd64/helm
|
|
echo "${RUNNER_TEMP}" >> "${GITHUB_PATH}"
|
|
- run: bash test.sh
|
|
|
|
deploy:
|
|
if: gitea.ref == 'refs/heads/main'
|
|
needs: validate
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Install pinned tools
|
|
run: |
|
|
curl -fsSL -o "${RUNNER_TEMP}/helm.tgz" "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz"
|
|
printf '%s %s\n' "${HELM_SHA256}" "${RUNNER_TEMP}/helm.tgz" | sha256sum --check
|
|
tar -xzf "${RUNNER_TEMP}/helm.tgz" -C "${RUNNER_TEMP}" --strip-components=1 linux-amd64/helm
|
|
curl -fsSL -o "${RUNNER_TEMP}/kubectl" "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
|
|
curl -fsSL -o "${RUNNER_TEMP}/kubectl.sha256" "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
|
|
printf '%s %s\n' "$(cat "${RUNNER_TEMP}/kubectl.sha256")" "${RUNNER_TEMP}/kubectl" | sha256sum --check
|
|
chmod 0700 "${RUNNER_TEMP}/helm" "${RUNNER_TEMP}/kubectl"
|
|
echo "${RUNNER_TEMP}" >> "${GITHUB_PATH}"
|
|
- name: Configure Kubernetes access
|
|
env:
|
|
KUBE_CONFIG_BASE64: ${{ secrets.KUBE_CONFIG_BASE64 }}
|
|
run: |
|
|
test -n "${KUBE_CONFIG_BASE64}"
|
|
printf '%s' "${KUBE_CONFIG_BASE64}" | base64 --decode > "${RUNNER_TEMP}/kubeconfig"
|
|
chmod 0600 "${RUNNER_TEMP}/kubeconfig"
|
|
export KUBECONFIG="${RUNNER_TEMP}/kubeconfig"
|
|
kubectl config set-cluster cluster --server="${KUBERNETES_API}" --tls-server-name="${KUBERNETES_TLS_SERVER_NAME}"
|
|
- name: Apply public desired state and verify
|
|
run: |
|
|
export KUBECONFIG="${RUNNER_TEMP}/kubeconfig"
|
|
./render.sh "${RUNNER_TEMP}/dashboard.yaml"
|
|
kubectl apply --server-side --force-conflicts --dry-run=server --validate=false \
|
|
--filename "${RUNNER_TEMP}/dashboard.yaml" \
|
|
--filename auth-proxy.yaml \
|
|
--filename kubernetes-dashboard-ingressroute.yaml
|
|
kubectl apply --server-side --force-conflicts --validate=false \
|
|
--filename "${RUNNER_TEMP}/dashboard.yaml" \
|
|
--filename auth-proxy.yaml \
|
|
--filename kubernetes-dashboard-ingressroute.yaml
|
|
|
|
bash ./wait-for-deployments.sh \
|
|
kubernetes-dashboard-api \
|
|
kubernetes-dashboard-auth \
|
|
kubernetes-dashboard-web \
|
|
kubernetes-dashboard-metrics-scraper \
|
|
kubernetes-dashboard-kong \
|
|
kubernetes-dashboard-auth-proxy
|
|
|
|
status=$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' --max-time 15 https://kubernetes.brunner.ninja/)
|
|
case "${status}" in
|
|
302|303|307) ;;
|
|
*) echo "Expected Authentik redirect, received HTTP ${status}" >&2; exit 1 ;;
|
|
esac
|