Loadbalancer IP and Ingress IP status is pending in kubernetes

1/15/2020

I have created the Kubernetes Cluster using two Azure Ubuntu VMs. I am able to deploy and access pods and deployments using the Nodeport service type. I have also checked the pod's status in Kube-system namespace. All of the pod's status showing as running. but, whenever I mention service type to Loadbalancer, it was not creating the LoadBalancer IP and it's status always showing as pending. I have also created an Ingress controller for the Nginx service. still, it is not creating an ingress Address. While initializing the Kubernetes master, I am using the following command.

kubeadm init

Below is deployment, svc and Ingress manifest files.

apiVersion: apps/v1 kind: Deployment metadata: name: nginx spec: selector: matchLabels: app: nginx replicas: 3 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80

apiVersion: v1 kind: Service metadata: name: nginx labels: app: nginx spec: ports: - name: http port: 80 protocol: TCP targetPort: 80 selector: app: nginx

kubectl describe svc nginx

Name: nginx Namespace: default Labels: app=nginx Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"nginx"},"name":"nginx","namespace":"default"},"spec":{"p... Selector: app=nginx Type: ClusterIP IP: 10.96.107.97 Port: http 80/TCP TargetPort: 80/TCP Endpoints: 10.44.0.4:80,10.44.0.5:80,10.44.0.6:80 Session Affinity: None Events: <none>

apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: name: test-ingress spec: backend: serviceName: nginx servicePort: 80

kubectl describe ingress nginx

Name: test-ingress

Namespace: default

Address:

Default backend: nginx:80 (10.44.0.4:80,10.44.0.5:80,10.44.0.6:80)

Rules:

Host Path Backends


* * nginx:80 (10.44.0.4:80,10.44.0.5:80,10.44.0.6:80)

Annotations: kubectl.kubernetes.io/last-applied-configuration: {"apiVersion":"networking.k8s.io/v1beta1","kind":"Ingress","metadata":{"annotations":{},"name":"test-ingress","namespace":"default"},"spec":{"backend":{"serviceName":"nginx","servicePort":80}}}

Events: <none>

Do we need to mention any IP ranges(private or public) of VMs while initializing the kubeadm init? or Do we need to change any network settings in Azure Ubuntu VMs?

-- gayathri
azure
kubeadm
kubernetes
ubuntu

1 Answer

1/16/2020

As you created your own Kubernetes cluster rather than AWS, Azure or GCP provided one, there is no load balancer integrated. Due to this reason, you are getting IP status pending.

But with the use of Ingress Controller or directly through NodePort you can circumvent this problem.

However, I also observed in your nginx service you are using an annotation service.beta.kubernetes.io/aws-load-balancer-type: nlb and you said you are using Azure and those are platform specific annotations for the service and that annotation is AWS specific.

However, you can give something like this a try, if you would like to experiment directly with public IPs, you can define your service by providing externalIPs in your service if you have a public ip allocated to your node and allows ingress traffic from somewhere.

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 9376
  externalIPs:
    - 80.11.12.10

But, a good approach to get this done is using an ingress controller if you are planning to build your own Kubernetes cluster.

Hope this helps.

-- BinaryMonster
Source: StackOverflow