2026-02-22 21:30:25 +00:00
|
|
|
when:
|
|
|
|
|
event: cron
|
|
|
|
|
cron: renew-tls-certificate
|
|
|
|
|
|
2026-02-23 00:08:42 +00:00
|
|
|
clone:
|
|
|
|
|
git:
|
|
|
|
|
image: woodpeckerci/plugin-git
|
|
|
|
|
settings:
|
|
|
|
|
attempts: 5
|
|
|
|
|
backoff: 10s
|
|
|
|
|
|
2026-02-22 21:30:25 +00:00
|
|
|
steps:
|
|
|
|
|
- name: prepare
|
|
|
|
|
image: alpine
|
|
|
|
|
commands:
|
|
|
|
|
- "apk update && apk add jq curl git git-crypt"
|
|
|
|
|
- |
|
|
|
|
|
curl -k https://10.0.20.100:6443/api/v1/namespaces/woodpecker/configmaps/git-crypt-key -H "Authorization:Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" | jq -r .data.key | base64 -d > /tmp/key
|
2026-03-07 14:30:36 +00:00
|
|
|
- "git-crypt unlock /tmp/key && rm /tmp/key"
|
2026-02-22 21:30:25 +00:00
|
|
|
|
|
|
|
|
- name: renew-tls
|
|
|
|
|
image: alpine
|
|
|
|
|
environment:
|
|
|
|
|
TECHNITIUM_API_KEY:
|
|
|
|
|
from_secret: TECHNITIUM_API_KEY
|
|
|
|
|
CLOUDFLARE_TOKEN:
|
|
|
|
|
from_secret: CLOUDFLARE_TOKEN
|
|
|
|
|
CLOUDFLARE_ZONE_ID:
|
|
|
|
|
from_secret: CLOUDFLARE_ZONE_ID
|
|
|
|
|
commands:
|
|
|
|
|
- "apk update && apk add certbot curl jq"
|
|
|
|
|
- "./modules/kubernetes/setup_tls_secret/renew2.sh"
|
|
|
|
|
|
|
|
|
|
- name: commit-certs
|
|
|
|
|
image: alpine
|
|
|
|
|
commands:
|
|
|
|
|
- "apk update && apk add openssh-client git git-crypt"
|
2026-03-07 14:30:36 +00:00
|
|
|
- "mkdir -p ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts"
|
2026-02-22 21:30:25 +00:00
|
|
|
- "chmod 400 secrets/deploy_key"
|
2026-03-07 14:30:36 +00:00
|
|
|
# Only add specific paths — never git add .
|
|
|
|
|
- "git add secrets/ state/ || true"
|
2026-02-22 21:30:25 +00:00
|
|
|
- "git remote set-url origin git@github.com:ViktorBarzin/infra.git"
|
|
|
|
|
- "git commit -m 'Woodpecker CI Update TLS Certificates Commit' || echo 'No changes'"
|
|
|
|
|
- "GIT_SSH_COMMAND='ssh -i ./secrets/deploy_key -o IdentitiesOnly=yes' git pull --rebase origin master"
|
|
|
|
|
- "GIT_SSH_COMMAND='ssh -i ./secrets/deploy_key -o IdentitiesOnly=yes' git push origin master"
|
2026-03-23 22:19:34 +02:00
|
|
|
|
|
|
|
|
- name: verify-cert
|
|
|
|
|
image: alpine
|
|
|
|
|
commands:
|
|
|
|
|
- "apk update && apk add openssl"
|
|
|
|
|
- "openssl x509 -checkend 604800 -noout -in secrets/fullchain.pem"
|
|
|
|
|
- "echo 'Certificate is valid for at least 7 more days'"
|
|
|
|
|
|
|
|
|
|
- name: update-tls-source-secret
|
2026-03-23 22:28:37 +02:00
|
|
|
image: alpine
|
2026-03-23 22:19:34 +02:00
|
|
|
commands:
|
2026-03-23 22:28:37 +02:00
|
|
|
- "apk update && apk add curl"
|
|
|
|
|
- "curl -LO https://dl.k8s.io/release/v1.31.0/bin/linux/amd64/kubectl && chmod +x kubectl && mv kubectl /usr/local/bin/"
|
2026-03-23 22:19:34 +02:00
|
|
|
- |
|
|
|
|
|
kubectl create secret tls tls-secret \
|
|
|
|
|
--cert=secrets/fullchain.pem --key=secrets/privkey.pem \
|
|
|
|
|
--namespace=kyverno --dry-run=client -o yaml | kubectl apply -f -
|
|
|
|
|
- "echo 'Source TLS secret updated in kyverno namespace — Kyverno will sync to all namespaces'"
|
|
|
|
|
|
|
|
|
|
- name: slack
|
|
|
|
|
image: curlimages/curl
|
|
|
|
|
commands:
|
|
|
|
|
- |
|
|
|
|
|
curl -s -X POST -H 'Content-type: application/json' \
|
|
|
|
|
--data "{\"channel\":\"general\",\"text\":\"Woodpecker CI: TLS certificate renewal ${CI_PIPELINE_STATUS}\"}" \
|
|
|
|
|
"$SLACK_WEBHOOK" || true
|
|
|
|
|
environment:
|
|
|
|
|
SLACK_WEBHOOK:
|
|
|
|
|
from_secret: slack_webhook
|
|
|
|
|
when:
|
|
|
|
|
status: [success, failure]
|