eminaktas / kubedns-shepherd

KubeDNS Shepherd is a Kubernetes controller that manages the DNS configuration of workloads, ensuring efficient and reliable way to configure DNS within your Kubernetes cluster.
Apache License 2.0
37 stars 3 forks source link

Unable To Use Dynamic Configuration in DNSClass #31

Closed mlladb closed 1 month ago

mlladb commented 1 month ago

I'm having issues using Dynamic Configuration in DNSClass. I've been trying the configurations based on samples.. With any configuration I try to use I get the following error.

apiVersion: config.kubedns-shepherd.io/v1alpha1
kind: DNSClass
metadata:
  name: kubedns-shepherd-dnsclass
spec:
  allowedDNSPolicies:
  - ClusterFirst
  - ClusterFirstWithHostNet
  - None
  allowedNamespaces:
  - kubedns-shepherd
  disabledNamespaces:
  - kube-system
  dnsConfig:
    nameservers:
    - 172.20.0.10
    options:
    - name: ndots
      value: "3"
    - name: edns0
    searches:
    - svc.cluster.local
    - cluster.local
    - '{{ .podNamespace }}.svc.cluster.local'
  dnsPolicy: None
status:
  conditions:
  - lastTransitionTime: "2024-10-14T04:29:52Z"
    message: Ready
    reason: ReconcileCompleted
    status: "True"
    type: ready
  - lastTransitionTime: "2024-10-14T04:35:28Z"
    message: 'failed to discover template keys: nameservers, clusterDomain, clusterName,
      dnsDomain'
    reason: ReconcileError
    status: "True"
    type: error
  discoveredFields: {}
  state: error

The cluster domain key is configured in my kublet config as, "clusterDomain": "cluster.local", I don't mind hard coding this as it should be the same across all clusters and environments but I would like to make use of podNamespace.

I have tried the following configs.

clusterDomain and podNamespace.

 searches:
    - svc.{{ .clusterDomain }}
    - '{{ .podNamespace }}.svc.{{ .clusterDomain }}'

podNamespace

searches:
    - svc.cluster.local
    - '{{ .podNamespace }}.svc.cluster.local'

Kubernetes version

Server Version: v1.29.8-eks-a737599

Can you offer any advice on how to get this working?

eminaktas commented 1 month ago

@mlladb I wasn't aware of this problem since I didn't test this operator in GKE or EKS. Thank you for this information. I undertand that they are not providing the ConfigMaps that we are looking in the cluster. I will add a fix for this, so if the templating not applied, we won't discover the fields.

Later, I will look a solution if possible for GKE and AWS.