safetyduck
safetyduck

Reputation: 6874

No ExternalIP showing in kubernetes nodes?

I am running

kubectl get nodes -o yaml | grep ExternalIP -C 1

But am not finding any ExternalIP. There are various comments showing up about problems with non-cloud setups.

I am following this doc https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/

with microk8s on a desktop.

Upvotes: 1

Views: 1191

Answers (2)

Vit
Vit

Reputation: 8471

In short: From my answer Kubernetes Ingress nginx on Minikube fails.

By default all solutions like minikube does not provide you LoadBalancer. Cloud solutions like EKS, Google Cloud, Azure do it for you automatically by spinning in the background separate LB. Thats why you see Pending status.

In your case most probably right decision to look into MicroK8s Add ons. There is a Add on: MetalLB:

Thanks @Matt with his MetalLB external load balancer on docker-desktop community edition on Windows 10 single-node Kubernetes Infrastructure answer ans researched info.

MetalLB Loadbalancer is a network LB implementation that tries to “just work” on bare metal clusters.

When you enable this add on you will be asked for an IP address pool that MetalLB will hand out IPs from:

microk8s enable metallb

For load balancing in a MicroK8s cluster, MetalLB can make use of Ingress to properly balance across the cluster ( make sure you have also enabled ingress in MicroK8s first, with microk8s enable ingress). To do this, it requires a service. A suitable ingress service is defined here:

apiVersion: v1
kind: Service
metadata:
  name: ingress
  namespace: ingress
spec:
  selector:
    name: nginx-ingress-microk8s
  type: LoadBalancer
  # loadBalancerIP is optional. MetalLB will automatically allocate an IP 
  # from its pool if not specified. You can also specify one manually.
  # loadBalancerIP: x.y.z.a
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
    - name: https
      protocol: TCP
      port: 443
      targetPort: 443

You can save this file as ingress-service.yaml and then apply it with:

microk8s kubectl apply -f ingress-service.yaml

Now there is a load-balancer which listens on an arbitrary IP and directs traffic towards one of the listening ingress controllers.

Upvotes: 1

pmbibe
pmbibe

Reputation: 21

If you setup k8s cluster on Cloud, Kubernetes will auto detect ExternalIP for you. ExternalIP will be a Load Balance IP address. But if you setup it on premise or on your Desktop. You can set External IP address by deploy your Load Balance, such as MetaLB. You can get it here

Upvotes: 2

Related Questions