0

When I run kubectl get svc -n kube-system it tells me:

NAME       TYPE        CLUSTER-IP   EXTERNAL-IP    PORT(S)        AGE
kube-dns   ClusterIP   xx.xx.xx.xx   <none>       53/UDP,53/TCP   13h

But when I try to kubectl edit svc/kube-dns -n kube-system:

error: services "kube-dns" is invalid

A copy of your changes has been stored to "/tmp/kubectl-edit-4p5gn.yaml"

error: Edit cancelled, no valid changes were saved.

I am unable to change it to a LoadBalancer...any ideas?

I also tried to create a new kube-dns also but I am unable to get an external-ip; it stays stuck in pending state.

kind: Service
metadata:
  name: kubedns-bkp
  namespace: kube-system
  labels:
    k8s-app: kube-dns
spec:
  type: LoadBalancer
  ports:
  - port: 53
    protocol: UDP
  selector:
    k8s-app: kube-dns

kubectl get svc -n kube-system reports:

NAME            TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
kubedns-bkp     LoadBalancer   xx.xx.xx.xx     <pending>     53:32115/UDP    5h

Note: I have created k8s cluster with ELB integration, for other services I successfully get external IPs.

David Maze
  • 130,717
  • 29
  • 175
  • 215

1 Answers1

3

So, two things here:

  1. As they advised you in the yaml validation errors that you chose not to share with us, one cannot change the type: of an existing Service; you have to create a new one, or delete the existing one and recreate it.
  2. However, I would strongly, strongly, strongly advise against deleting the kube-dns Service -- you are more than welcome to create a new Service of type: LoadBalancer and point it at the same selector: as kube-dns is using. That way anyone who wishes to use the load balanced service can, but the things in the cluster who depend on kube-dns being a ClusterIP with (likely) that existing xx.xx.xx.xx value can continue as before.
mdaniel
  • 31,240
  • 5
  • 55
  • 58
  • Hi Matthew, Thank you for response... I too tried to create a new service but external ip is not getting its in pending state. FYI: i have created a k8s cluster with ELB integration (AWS). kind: Service metadata: name: dns-ilb namespace: kube-system labels: k8s-app: kube-dns spec: type: LoadBalancer ports: - port: 53 protocol: UDP selector: k8s-app: kube-dns – Srinivasa Reddy Dec 19 '18 at 10:04
  • That sounds like a new question, but the short version is to check the apiserver and/or controller-manager logs to see if they are encountering an error while provisioning the ELB. I would guess it's the master Nodes not having the right IAM role, if I were guessing, but TBH there are almost infinite things that can go wrong with AWS and ELBs – mdaniel Dec 19 '18 at 17:06
  • Hi, found a reason for not creating loadbalacer in above scenario. currently AWS ELB not supporting UDP protocol, only supporting TCP. Is there any way to create loadblancer with UDP. – Srinivasa Reddy Dec 20 '18 at 12:37
  • Ah, in that case I think you're out of luck with the existing AWS products; you'll have to use your own Ingress controller running haproxy or nginx, in that case – mdaniel Dec 20 '18 at 17:10
  • Can you please suggest any haproxy containers for kubernetes. – Srinivasa Reddy Dec 21 '18 at 04:24