Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d9e3abee8 | ||
|
|
9fa8d9cf60 | ||
|
|
2e4fad3bf7 | ||
|
|
5d22691c3e | ||
|
|
4eee161e0f | ||
|
|
719fa77521 | ||
|
|
64cd1f2c4e |
@@ -48,7 +48,7 @@ spec:
|
|||||||
mountPath: /backup
|
mountPath: /backup
|
||||||
containers:
|
containers:
|
||||||
- name: mc-mirror
|
- name: mc-mirror
|
||||||
image: quay.io/minio/mc:latest
|
image: docker.io/bitnamilegacy/minio-client:2025.7.21-debian-12-r3@sha256:73bd39f7899a0cef12b8dd5df13aa93a3ed1aaa44236542442e9ac76819ac158
|
||||||
env:
|
env:
|
||||||
- name: ACCESS_KEY
|
- name: ACCESS_KEY
|
||||||
valueFrom:
|
valueFrom:
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
apiVersion: argoproj.io/v1alpha1
|
||||||
|
kind: Application
|
||||||
|
metadata:
|
||||||
|
name: oidc-bootstrap
|
||||||
|
namespace: argocd
|
||||||
|
annotations:
|
||||||
|
argocd.argoproj.io/sync-wave: "5"
|
||||||
|
spec:
|
||||||
|
project: homelab
|
||||||
|
source:
|
||||||
|
repoURL: https://forgejo.riotpiao.com/riotpiao-poimen/homelab.git
|
||||||
|
targetRevision: main
|
||||||
|
path: k8s/infra/oidc-bootstrap
|
||||||
|
destination:
|
||||||
|
server: https://kubernetes.default.svc
|
||||||
|
namespace: kube-system
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
prune: true
|
||||||
|
selfHeal: true
|
||||||
@@ -52,14 +52,14 @@ spec:
|
|||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
initContainers:
|
initContainers:
|
||||||
- name: kubectl-copy
|
- name: kubectl-copy
|
||||||
image: bitnami/kubectl:latest
|
image: bitnami/kubectl:latest@sha256:f7f9e4f64d9e114650c115a4ac6fd383394b3d494061a8f17b1a0f6c8d55bc25
|
||||||
command: ["sh", "-c", "cp $(which kubectl) /shared/kubectl"]
|
command: ["sh", "-c", "cp $(which kubectl) /shared/kubectl"]
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: shared
|
- name: shared
|
||||||
mountPath: /shared
|
mountPath: /shared
|
||||||
containers:
|
containers:
|
||||||
- name: provision
|
- name: provision
|
||||||
image: quay.io/minio/mc:latest
|
image: docker.io/bitnamilegacy/minio-client:2025.7.21-debian-12-r3@sha256:73bd39f7899a0cef12b8dd5df13aa93a3ed1aaa44236542442e9ac76819ac158
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: shared
|
- name: shared
|
||||||
mountPath: /shared
|
mountPath: /shared
|
||||||
|
|||||||
@@ -16,7 +16,10 @@ spec:
|
|||||||
# backend could not resolve minio-cluster-hl. Official images now need registry auth
|
# backend could not resolve minio-cluster-hl. Official images now need registry auth
|
||||||
# (quay.io/minio/minio returns 401), so this pins a public mirror of the same upstream
|
# (quay.io/minio/minio returns 401), so this pins a public mirror of the same upstream
|
||||||
# release; swap it for the official image once MinIO registry credentials exist.
|
# release; swap it for the official image once MinIO registry credentials exist.
|
||||||
image: coollabsio/minio:RELEASE.2025-10-15T17-29-55Z
|
# The digest freezes those bytes, so a retag or a deletion on the mirror cannot break
|
||||||
|
# the pull again. The same digest already sits in the containerd cache on talos-cp-1,
|
||||||
|
# so the first start needs no registry access.
|
||||||
|
image: docker.io/coollabsio/minio:RELEASE.2025-10-15T17-29-55Z@sha256:69b55a1c1c5dc285ce04db96689f5b2102317fc77a50680a1874ca6efd1c87f9
|
||||||
|
|
||||||
# Disable operator auto-TLS: MinIO serves plain HTTP internally on 9000.
|
# Disable operator auto-TLS: MinIO serves plain HTTP internally on 9000.
|
||||||
# External TLS is terminated at nginx ingress (wildcard riotpiao-com-tls cert).
|
# External TLS is terminated at nginx ingress (wildcard riotpiao-com-tls cert).
|
||||||
|
|||||||
@@ -27,6 +27,24 @@ spec:
|
|||||||
annotations:
|
annotations:
|
||||||
summary: "{{ $value }} pod(s) stuck in Pending state for >10m"
|
summary: "{{ $value }} pod(s) stuck in Pending state for >10m"
|
||||||
|
|
||||||
|
# ImagePullBackOff on a vendor-deleted image produced no alert for 13 days
|
||||||
|
- alert: PodImagePullFailure
|
||||||
|
expr: sum(kube_pod_container_status_waiting_reason{reason=~"ImagePullBackOff|ErrImagePull"}) by (namespace, pod) > 0
|
||||||
|
for: 10m
|
||||||
|
labels:
|
||||||
|
severity: critical
|
||||||
|
annotations:
|
||||||
|
summary: "{{ $labels.namespace }}/{{ $labels.pod }} cannot pull its image"
|
||||||
|
|
||||||
|
# Pod not ready
|
||||||
|
- alert: PodNotReady
|
||||||
|
expr: sum(kube_pod_status_ready{condition="false"}) by (namespace, pod) > 0
|
||||||
|
for: 15m
|
||||||
|
labels:
|
||||||
|
severity: warning
|
||||||
|
annotations:
|
||||||
|
summary: "{{ $labels.namespace }}/{{ $labels.pod }} is not ready"
|
||||||
|
|
||||||
# CrashLoopBackOff
|
# CrashLoopBackOff
|
||||||
- alert: PodCrashLooping
|
- alert: PodCrashLooping
|
||||||
expr: sum(kube_pod_container_status_waiting_reason{reason="CrashLoopBackOff"}) by (namespace, pod) > 0
|
expr: sum(kube_pod_container_status_waiting_reason{reason="CrashLoopBackOff"}) by (namespace, pod) > 0
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# One-shot bootstrap: restart the control-plane apiservers ONCE so they pick up the
|
||||||
|
# OIDC authenticator (they last started before the Authentik provider existed, so OIDC
|
||||||
|
# tokens were never accepted -> every login got 401). Delete this whole directory after.
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: oidc-bootstrap
|
||||||
|
namespace: kube-system
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: oidc-bootstrap
|
||||||
|
namespace: kube-system
|
||||||
|
rules:
|
||||||
|
- apiGroups: [""]
|
||||||
|
resources: ["pods"]
|
||||||
|
verbs: ["get", "list", "delete"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: oidc-bootstrap
|
||||||
|
namespace: kube-system
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: oidc-bootstrap
|
||||||
|
namespace: kube-system
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: oidc-bootstrap
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: oidc-bootstrap-restart-apiserver-v2
|
||||||
|
namespace: kube-system
|
||||||
|
spec:
|
||||||
|
backoffLimit: 4
|
||||||
|
ttlSecondsAfterFinished: 7200
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
serviceAccountName: oidc-bootstrap
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: restart
|
||||||
|
image: docker.io/curlimages/curl:8.22.0
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
set -u
|
||||||
|
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
|
||||||
|
CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
|
||||||
|
for pod in kube-apiserver-talos-cp-1 kube-apiserver-talos-cp-2 kube-apiserver-talos-cp-3; do
|
||||||
|
curl -sS --max-time 15 --cacert "$CA" -H "Authorization: Bearer $TOKEN" -X DELETE "https://kubernetes.default.svc/api/v1/namespaces/kube-system/pods/$pod?gracePeriodSeconds=0" -o /dev/null -w "$pod -> HTTP %{http_code}\n" || echo "$pod -> request failed"
|
||||||
|
done
|
||||||
|
echo "deletes requested; kubelet recreates each static pod in ~20-40s"
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
# One-shot: restart the control-plane API servers so their OIDC authenticator initialises.
|
||||||
|
#
|
||||||
|
# Two earlier mechanisms failed and are documented so nobody repeats them:
|
||||||
|
# 1. deleting the mirror pod does NOT restart a static pod (deletes returned 200, no restart);
|
||||||
|
# 2. matching /proc/*/cmdline for 'kube-apiserver' also matched this script's own cmdline,
|
||||||
|
# so every pod SIGTERMed itself (exit 143) before reaching the real process.
|
||||||
|
# This version matches /proc/<pid>/comm (the process name) and skips \$\$, so self-kill is
|
||||||
|
# impossible. hostPID + privileged are permitted in the 'cicd' namespace. Delays stagger the
|
||||||
|
# three control planes by 2 minutes each, so only one API server is down at a time.
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: oidc-restart-apiserver-cp1-v2
|
||||||
|
namespace: cicd
|
||||||
|
spec:
|
||||||
|
backoffLimit: 0
|
||||||
|
ttlSecondsAfterFinished: 3600
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
hostPID: true
|
||||||
|
restartPolicy: Never
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: talos-cp-1
|
||||||
|
tolerations:
|
||||||
|
- key: node-role.kubernetes.io/control-plane
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
- key: node-role.kubernetes.io/master
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
containers:
|
||||||
|
- name: kill
|
||||||
|
image: docker.io/library/busybox:1.36
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
echo "sleeping 10s before restarting the API server on talos-cp-1"
|
||||||
|
sleep 10
|
||||||
|
self=$$
|
||||||
|
killed=0
|
||||||
|
for d in /proc/[0-9]*; do
|
||||||
|
pid=${d#/proc/}
|
||||||
|
[ "$pid" = "$self" ] && continue
|
||||||
|
comm=$(cat "$d/comm" 2>/dev/null)
|
||||||
|
[ "$comm" = "kube-apiserver" ] || continue
|
||||||
|
echo "SIGTERM -> pid $pid"
|
||||||
|
kill -TERM "$pid" 2>/dev/null && killed=$((killed+1))
|
||||||
|
done
|
||||||
|
echo "signalled $killed API server process(es); kubelet recreates the static pod"
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: oidc-restart-apiserver-cp2-v2
|
||||||
|
namespace: cicd
|
||||||
|
spec:
|
||||||
|
backoffLimit: 0
|
||||||
|
ttlSecondsAfterFinished: 3600
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
hostPID: true
|
||||||
|
restartPolicy: Never
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: talos-cp-2
|
||||||
|
tolerations:
|
||||||
|
- key: node-role.kubernetes.io/control-plane
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
- key: node-role.kubernetes.io/master
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
containers:
|
||||||
|
- name: kill
|
||||||
|
image: docker.io/library/busybox:1.36
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
echo "sleeping 120s before restarting the API server on talos-cp-2"
|
||||||
|
sleep 120
|
||||||
|
self=$$
|
||||||
|
killed=0
|
||||||
|
for d in /proc/[0-9]*; do
|
||||||
|
pid=${d#/proc/}
|
||||||
|
[ "$pid" = "$self" ] && continue
|
||||||
|
comm=$(cat "$d/comm" 2>/dev/null)
|
||||||
|
[ "$comm" = "kube-apiserver" ] || continue
|
||||||
|
echo "SIGTERM -> pid $pid"
|
||||||
|
kill -TERM "$pid" 2>/dev/null && killed=$((killed+1))
|
||||||
|
done
|
||||||
|
echo "signalled $killed API server process(es); kubelet recreates the static pod"
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: oidc-restart-apiserver-cp3-v2
|
||||||
|
namespace: cicd
|
||||||
|
spec:
|
||||||
|
backoffLimit: 0
|
||||||
|
ttlSecondsAfterFinished: 3600
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
hostPID: true
|
||||||
|
restartPolicy: Never
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: talos-cp-3
|
||||||
|
tolerations:
|
||||||
|
- key: node-role.kubernetes.io/control-plane
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
- key: node-role.kubernetes.io/master
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
containers:
|
||||||
|
- name: kill
|
||||||
|
image: docker.io/library/busybox:1.36
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
command: ["/bin/sh", "-c"]
|
||||||
|
args:
|
||||||
|
- |
|
||||||
|
echo "sleeping 240s before restarting the API server on talos-cp-3"
|
||||||
|
sleep 240
|
||||||
|
self=$$
|
||||||
|
killed=0
|
||||||
|
for d in /proc/[0-9]*; do
|
||||||
|
pid=${d#/proc/}
|
||||||
|
[ "$pid" = "$self" ] && continue
|
||||||
|
comm=$(cat "$d/comm" 2>/dev/null)
|
||||||
|
[ "$comm" = "kube-apiserver" ] || continue
|
||||||
|
echo "SIGTERM -> pid $pid"
|
||||||
|
kill -TERM "$pid" 2>/dev/null && killed=$((killed+1))
|
||||||
|
done
|
||||||
|
echo "signalled $killed API server process(es); kubelet recreates the static pod"
|
||||||
|
|
||||||
Reference in New Issue
Block a user