fleetboard-io / fleetboard

Fleetboard establishes an independent and unified parallel network, facilitating cross-cluster service discovery even in cases of IP overlap.
https://fleetboard-io.github.io
Apache License 2.0
24 stars 3 forks source link

Add a job to patch CoreDNS configmap in helm operation. #100

Open lmxia opened 2 months ago

lmxia commented 2 months ago

Add crossdns entry in coredns configmap.

Ref: https://medium.com/@ByteBosss/patching-with-helm-and-kustomize-4b0586d87fd9

lmxia commented 1 month ago

@dixudx cc

dixudx commented 1 month ago

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.

lmxia commented 1 month ago

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.

As analyzed, it seems like wo have to use kubectl update as job command, but no need to restart coredns pods.