Skip to content

Instantly share code, notes, and snippets.

@eminaktas
Created July 10, 2023 06:38
Show Gist options
  • Save eminaktas/ea71c8c5ba4fc836a37af6f11a29603c to your computer and use it in GitHub Desktop.
Save eminaktas/ea71c8c5ba4fc836a37af6f11a29603c to your computer and use it in GitHub Desktop.
NodeLocanDNS with CiliumLocalRedirectPolicy
apiVersion: "cilium.io/v2"
kind: CiliumLocalRedirectPolicy
metadata:
name: "nodelocaldns"
namespace: kube-system
spec:
redirectFrontend:
addressMatcher:
ip: "169.254.25.10"
toPorts:
- port: "53"
name: dns
protocol: UDP
- port: "53"
name: dns-tcp
protocol: TCP
- port: "9254"
name: health
protocol: TCP
redirectBackend:
localEndpointSelector:
matchLabels:
k8s-app: nodelocaldns
toPorts:
- port: "53"
name: dns
protocol: UDP
- port: "53"
name: dns-tcp
protocol: TCP
- port: "9254"
name: health
protocol: TCP
apiVersion: v1
data:
Corefile: |
cluster.local:53 {
errors
cache {
success 9984 30
denial 9984 5
}
reload
loop
bind 0.0.0.0
forward . __PILLAR__CLUSTER__DNS__ {
force_tcp
}
prometheus :9253
health 0.0.0.0:9254
}
in-addr.arpa:53 {
errors
cache 30
reload
loop
bind 0.0.0.0
forward . __PILLAR__CLUSTER__DNS__ {
force_tcp
}
prometheus :9253
}
ip6.arpa:53 {
errors
cache 30
reload
loop
bind 0.0.0.0
forward . __PILLAR__CLUSTER__DNS__ {
force_tcp
}
prometheus :9253
}
.:53 {
errors
cache 30
reload
loop
bind 0.0.0.0
forward . __PILLAR__UPSTREAM__SERVERS__
prometheus :9253
}
kind: ConfigMap
metadata:
labels:
addonmanager.kubernetes.io/mode: EnsureExists
name: nodelocaldns
namespace: kube-system
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: nodelocaldns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: Reconcile
k8s-app: nodelocaldns
spec:
updateStrategy:
rollingUpdate:
maxUnavailable: 10%
selector:
matchLabels:
k8s-app: nodelocaldns
template:
metadata:
labels:
k8s-app: nodelocaldns
annotations:
io.cilium.no-track-port: "53"
prometheus.io/port: "9253"
prometheus.io/scrape: "true"
policy.cilium.io/proxy-visibility: <Egress/53/UDP/DNS>,<Egress/53/TCP/DNS>
spec:
priorityClassName: system-node-critical
serviceAccountName: nodelocaldns
dnsPolicy: Default
hostNetwork: false
nodeSelector:
kubernetes.io/os: linux
tolerations:
- effect: "NoExecute"
operator: "Exists"
- effect: "NoSchedule"
operator: "Exists"
containers:
- name: node-cache
image: "k8s.gcr.io/dns/k8s-dns-node-cache:1.22.20"
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 70Mi
args: [ "-localip", "169.254.25.10,<kube-dns IP address>", "-conf", "/etc/Corefile", "-upstreamsvc", "coredns", "-skipteardown=true", "-setupinterface=false", "-setupiptables=false" ]
ports:
- containerPort: 53
name: dns
protocol: UDP
- containerPort: 53
name: dns-tcp
protocol: TCP
- containerPort: 9253
name: metrics
protocol: TCP
- containerPort: 9254
name: health
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 9254
initialDelaySeconds: 60
timeoutSeconds: 5
volumeMounts:
- name: config-volume
mountPath: /etc/coredns
- name: kube-dns-config
mountPath: /etc/kube-dns
volumes:
- name: kube-dns-config
configMap:
name: coredns
optional: true
- name: config-volume
configMap:
name: nodelocaldns
items:
- key: Corefile
path: Corefile.base
apiVersion: v1
kind: ServiceAccount
metadata:
name: nodelocaldns
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: Reconcile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment