2026-10-07 04:07:37 +00:00
|
|
|
# One-shot: restart the control-plane API servers so their OIDC authenticator initialises.
|
2026-10-07 03:59:22 +00:00
|
|
|
#
|
2026-10-07 04:07:37 +00:00
|
|
|
# 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.
|
2026-10-07 03:59:22 +00:00
|
|
|
---
|
|
|
|
|
apiVersion: batch/v1
|
|
|
|
|
kind: Job
|
|
|
|
|
metadata:
|
2026-10-07 04:07:37 +00:00
|
|
|
name: oidc-restart-apiserver-cp1-v2
|
2026-10-07 03:59:22 +00:00
|
|
|
namespace: cicd
|
|
|
|
|
spec:
|
2026-10-07 04:07:37 +00:00
|
|
|
backoffLimit: 0
|
2026-10-07 03:59:22 +00:00
|
|
|
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:
|
2026-10-07 04:07:37 +00:00
|
|
|
- name: kill
|
2026-10-07 03:59:22 +00:00
|
|
|
image: docker.io/library/busybox:1.36
|
|
|
|
|
securityContext:
|
|
|
|
|
privileged: true
|
|
|
|
|
command: ["/bin/sh", "-c"]
|
|
|
|
|
args:
|
|
|
|
|
- |
|
2026-10-07 04:07:37 +00:00
|
|
|
echo "sleeping 10s before restarting the API server on talos-cp-1"
|
2026-10-07 03:59:22 +00:00
|
|
|
sleep 10
|
2026-10-07 04:07:37 +00:00
|
|
|
self=$$
|
2026-10-07 03:59:22 +00:00
|
|
|
killed=0
|
2026-10-07 04:07:37 +00:00
|
|
|
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))
|
2026-10-07 03:59:22 +00:00
|
|
|
done
|
2026-10-07 04:07:37 +00:00
|
|
|
echo "signalled $killed API server process(es); kubelet recreates the static pod"
|
2026-10-07 03:59:22 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
apiVersion: batch/v1
|
|
|
|
|
kind: Job
|
|
|
|
|
metadata:
|
2026-10-07 04:07:37 +00:00
|
|
|
name: oidc-restart-apiserver-cp2-v2
|
2026-10-07 03:59:22 +00:00
|
|
|
namespace: cicd
|
|
|
|
|
spec:
|
2026-10-07 04:07:37 +00:00
|
|
|
backoffLimit: 0
|
2026-10-07 03:59:22 +00:00
|
|
|
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:
|
2026-10-07 04:07:37 +00:00
|
|
|
- name: kill
|
2026-10-07 03:59:22 +00:00
|
|
|
image: docker.io/library/busybox:1.36
|
|
|
|
|
securityContext:
|
|
|
|
|
privileged: true
|
|
|
|
|
command: ["/bin/sh", "-c"]
|
|
|
|
|
args:
|
|
|
|
|
- |
|
2026-10-07 04:07:37 +00:00
|
|
|
echo "sleeping 120s before restarting the API server on talos-cp-2"
|
|
|
|
|
sleep 120
|
|
|
|
|
self=$$
|
2026-10-07 03:59:22 +00:00
|
|
|
killed=0
|
2026-10-07 04:07:37 +00:00
|
|
|
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))
|
2026-10-07 03:59:22 +00:00
|
|
|
done
|
2026-10-07 04:07:37 +00:00
|
|
|
echo "signalled $killed API server process(es); kubelet recreates the static pod"
|
2026-10-07 03:59:22 +00:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
apiVersion: batch/v1
|
|
|
|
|
kind: Job
|
|
|
|
|
metadata:
|
2026-10-07 04:07:37 +00:00
|
|
|
name: oidc-restart-apiserver-cp3-v2
|
2026-10-07 03:59:22 +00:00
|
|
|
namespace: cicd
|
|
|
|
|
spec:
|
2026-10-07 04:07:37 +00:00
|
|
|
backoffLimit: 0
|
2026-10-07 03:59:22 +00:00
|
|
|
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:
|
2026-10-07 04:07:37 +00:00
|
|
|
- name: kill
|
2026-10-07 03:59:22 +00:00
|
|
|
image: docker.io/library/busybox:1.36
|
|
|
|
|
securityContext:
|
|
|
|
|
privileged: true
|
|
|
|
|
command: ["/bin/sh", "-c"]
|
|
|
|
|
args:
|
|
|
|
|
- |
|
2026-10-07 04:07:37 +00:00
|
|
|
echo "sleeping 240s before restarting the API server on talos-cp-3"
|
|
|
|
|
sleep 240
|
|
|
|
|
self=$$
|
2026-10-07 03:59:22 +00:00
|
|
|
killed=0
|
2026-10-07 04:07:37 +00:00
|
|
|
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))
|
2026-10-07 03:59:22 +00:00
|
|
|
done
|
2026-10-07 04:07:37 +00:00
|
|
|
echo "signalled $killed API server process(es); kubelet recreates the static pod"
|
2026-10-07 03:59:22 +00:00
|
|
|
|