add metallb
All checks were successful
Validate Kubernetes Manifests / kubeconform (pull_request) Successful in 1m2s
All checks were successful
Validate Kubernetes Manifests / kubeconform (pull_request) Successful in 1m2s
This commit is contained in:
41
clusters/ipv6/external-dns/cf-cron.yml
Normal file
41
clusters/ipv6/external-dns/cf-cron.yml
Normal file
@@ -0,0 +1,41 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: ipv6-dns-updater
|
||||
namespace: external-dns
|
||||
spec:
|
||||
schedule: "*/60 * * * *"
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: OnFailure
|
||||
nodeSelector:
|
||||
traefik: "true"
|
||||
containers:
|
||||
- name: updater
|
||||
image: alpine:3.20
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
apk add --no-cache curl jq &&
|
||||
sh /mnt/update-ipv6.sh
|
||||
env:
|
||||
- name: CF_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-global-key
|
||||
key: CF_API_KEY
|
||||
- name: CF_EMAIL
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: cloudflare-global-key
|
||||
key: CF_EMAIL
|
||||
volumeMounts:
|
||||
- name: script
|
||||
mountPath: /mnt
|
||||
volumes:
|
||||
- name: script
|
||||
configMap:
|
||||
name: ipv6-updater-script
|
||||
59
clusters/ipv6/external-dns/cf-script.yml
Normal file
59
clusters/ipv6/external-dns/cf-script.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: ipv6-updater-script
|
||||
namespace: external-dns
|
||||
data:
|
||||
update-ipv6.sh: |
|
||||
#!/bin/sh
|
||||
|
||||
ZONE_ID="fe797c7b55d4e23fcd7929173c72a021"
|
||||
RECORD="*.akshun-lab.cc"
|
||||
|
||||
IPV6=$(curl -s https://api64.ipify.org)
|
||||
|
||||
if [ -z "$IPV6" ]; then
|
||||
echo "No IPv6 detected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Get Record ID
|
||||
RECORD_ID=$(curl -s \
|
||||
-H "X-Auth-Email: $CF_EMAIL" \
|
||||
-H "X-Auth-Key: $CF_API_KEY" \
|
||||
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records?type=AAAA&name=$RECORD" \
|
||||
| jq -r '.result[0].id')
|
||||
|
||||
if [ "$RECORD_ID" = "null" ]; then
|
||||
echo "Record does not exist, creating..."
|
||||
|
||||
curl -s -X POST \
|
||||
-H "X-Auth-Email: $CF_EMAIL" \
|
||||
-H "X-Auth-Key: $CF_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records" \
|
||||
--data "{
|
||||
\"type\": \"AAAA\",
|
||||
\"name\": \"$RECORD\",
|
||||
\"content\": \"$IPV6\",
|
||||
\"ttl\": 120,
|
||||
\"proxied\": true
|
||||
}"
|
||||
|
||||
else
|
||||
echo "Updating existing record..."
|
||||
|
||||
curl -s -X PUT \
|
||||
-H "X-Auth-Email: $CF_EMAIL" \
|
||||
-H "X-Auth-Key: $CF_API_KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/dns_records/$RECORD_ID" \
|
||||
--data "{
|
||||
\"type\": \"AAAA\",
|
||||
\"name\": \"$RECORD\",
|
||||
\"content\": \"$IPV6\",
|
||||
\"ttl\": 120,
|
||||
\"proxied\": true
|
||||
}"
|
||||
fi
|
||||
Reference in New Issue
Block a user