Skip to content

Commit

Permalink
setup coredns to route traffic internally for *.local.lco.earth
Browse files Browse the repository at this point in the history
This is needed for things like generating pre-signed URLs with Minio, where
they need to use the Ingress DNS name internally. But because *.local.lco.earth
always resolves to 127.0.0.1, Pods are not able to connect to services backed
by the Ingress. By using the coredns template plugin, we can short-ciruit the
resolved DNS to the ingress-controller.
  • Loading branch information
jashan-lco committed Feb 11, 2025
1 parent 33feadd commit a7a67be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
30 changes: 30 additions & 0 deletions local-cluster/configmap-coredns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
errors
health {
lameduck 5s
}
ready
template ANY ANY local.lco.earth {
answer "{{ .Name }} 60 {{ .Class }} CNAME ingress-nginx-controller.ingress-nginx.svc.cluster.local"
}
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
}
2 changes: 2 additions & 0 deletions local-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ in {
local-cluster-nginx-ingress-up.exec = ''
set -ex -o pipefail
kustomize build "${./ingress-nginx}" | kubectl apply -f -
kubectl apply -f "${./configmap-coredns.yaml}"
'';

local-cluster-nginx-ingress-down.exec = ''
set -ex -o pipefail
kustomize build "${./ingress-nginx}" | kubectl delete -f -
kubectl delete -f "${./configmap-coredns.yaml}"
'';

local-cluster-k8s-dashboard-up.exec = ''
Expand Down

0 comments on commit a7a67be

Please sign in to comment.