summaryrefslogtreecommitdiff
path: root/tools/coredns-config-generator.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/coredns-config-generator.sh')
-rwxr-xr-xtools/coredns-config-generator.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/tools/coredns-config-generator.sh b/tools/coredns-config-generator.sh
new file mode 100755
index 0000000..d61d879
--- /dev/null
+++ b/tools/coredns-config-generator.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Generate CoreDNS Corefile configuration
+#
+
+set -euo pipefail
+
+CONFIG_DIR="${CONFIG_DIR:-/etc/cluster-config}"
+COREDNS_DIR="/etc/coredns"
+COREFILE="$COREDNS_DIR/Corefile"
+
+mkdir -p "$COREDNS_DIR"
+
+# Generate Corefile
+cat > "$COREFILE" <<'EOF'
+# CoreDNS Configuration for Kubernetes
+
+cluster.local:53 {
+ errors
+ health {
+ lameduck 5s
+ }
+ ready
+ kubernetes cluster.local in-addr.arpa ip6.arpa {
+ pods insecure
+ fallthrough in-addr.arpa ip6.arpa
+ ttl 30
+ }
+ prometheus :9153
+ forward . /etc/resolv.conf {
+ max_concurrent 1000
+ }
+ cache 30
+ loop
+ reload
+ loadbalance
+}
+
+.:53 {
+ errors
+ health
+ ready
+ forward . 8.8.8.8 8.8.4.4
+ cache 30
+ reload
+}
+EOF
+
+chown -R coredns:coredns "$COREDNS_DIR" 2>/dev/null || true
+
+echo "CoreDNS configuration generated at $COREFILE"