add automatic dns updates
This commit is contained in:
54
infrastructure/ddns/cronjob.yaml
Normal file
54
infrastructure/ddns/cronjob.yaml
Normal file
@@ -0,0 +1,54 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: ddns-cronjob
|
||||
spec:
|
||||
schedule: "0 6,18 * * *"
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: hello
|
||||
image: curl
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
args:
|
||||
- >-
|
||||
CURRENT_IP = $(curl -4 ifconfig.me)
|
||||
&&
|
||||
echo "Current IP: $CURRENT_IP"
|
||||
&&
|
||||
curl
|
||||
--request PUT
|
||||
--url https://api.cloudflare.com/client/v4/zones/$(CLOUDFLARE_ZONE_ID)/dns_records/$(CLOUDFLARE_DNS_RECORD_ID)
|
||||
--header "Authorization: Bearer $(CLOUDFLARE_API_KEY)"
|
||||
--header "Content-Type: application/json"
|
||||
--data '{"content": "$(CURRENT_IP)", "name": "$(KLUSTER_DOMAIN)", "proxied": false, "type": "A"}'
|
||||
|
||||
env:
|
||||
- name: CLOUDFLARE_ZONE_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-keys
|
||||
key: CLOUDFLARE_ZONE_ID
|
||||
- name: CLOUDFLARE_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-keys
|
||||
key: CLOUDFLARE_API_KEY
|
||||
- name: CLOUDFLARE_DNS_RECORD_ID
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-keys
|
||||
key: CLOUDFLARE_DNS_RECORD_ID
|
||||
- name: KLUSTER_DOMAIN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-keys
|
||||
key: KLUSTER_DOMAIN
|
||||
- name: CURRENT_IP
|
||||
value: ???
|
||||
|
||||
restartPolicy: OnFailure
|
||||
Reference in New Issue
Block a user