Open lmxia opened 2 months ago
@dixudx cc
Below is a default configmap for coredns.
apiVersion: v1
data:
Corefile: |
.: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
}
kind: ConfigMap
metadata:
creationTimestamp: "2024-05-30T02:48:54Z"
name: coredns
namespace: kube-system
resourceVersion: "279"
uid: 567c6c7d-1a5a-47c8-90b2-4f61c6fd3c0e
From above, we can see coredns plugin reload
is enabled, which allows automatic reload of a changed Corefile. Thus we only need to modify this configmap without restarting coredns pods.
However, data.Corefile
is a key and its value (Corefile content) is of type: string
. It is treated by kube-apiserver as a string of bytes. We cannot patch part of a string with kubectl patch
or Kustomize.
Below is a default configmap for coredns.
apiVersion: v1 data: Corefile: | .: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 } kind: ConfigMap metadata: creationTimestamp: "2024-05-30T02:48:54Z" name: coredns namespace: kube-system resourceVersion: "279" uid: 567c6c7d-1a5a-47c8-90b2-4f61c6fd3c0e
From above, we can see coredns plugin
reload
is enabled, which allows automatic reload of a changed Corefile. Thus we only need to modify this configmap without restarting coredns pods.However,
data.Corefile
is a key and its value (Corefile content) is oftype: string
. It is treated by kube-apiserver as a string of bytes. We cannot patch part of a string withkubectl patch
or Kustomize.
As analyzed, it seems like wo have to use kubectl update
as job command, but no need to restart
coredns pods.
Add crossdns entry in coredns configmap.
Ref: https://medium.com/@ByteBosss/patching-with-helm-and-kustomize-4b0586d87fd9