How to create Kubernetes DNS service without reinitializing the k8s cluster?
I have accidentally deleted the K8S DNS service and now name resolution is not working between pods and services.
Pods are not able to reach other pods through service.
So is there a way to recreate the K8S DNS service without reinitializing the K8S cluster?
I tried the below spec but it's throwing some errors.
---
apiVersion: v1
kind: Service
metadata:
name: kube-dns
namespace: kube-system
annotations:
prometheus.io/port: "9153"
prometheus.io/scrape: "true"
labels:
k8s-app: kube-dns
kubernetes.io/cluster-service: "true"
addonmanager.kubernetes.io/mode: Reconcile
kubernetes.io/name: "CoreDNS"
spec:
selector:
k8s-app: kube-dns
clusterIP: {{.ClusterDNSServer}}
ports:
- name: dns
port: 53
protocol: UDP
- name: dns-tcp
port: 53
protocol: TCP
- name: metrics
port: 9153
protocol: TCP
Error message when I tried to deploy this spec
error: error parsing coredns-svc.yaml: error converting YAML to JSON: yaml: invalid map key: map[interface {}]interface {}{".ClusterDNSServer":interface {}(nil)}
So is this spec the right way to recreate the K8S DNS service and if yes what's wrong with the spec?