question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nginx loadbalancer service EXTERNAL-IP is always in "pending" state

See original GitHub issue

Please run microk8s.inspect and attach the generated tarball to this issue. inspection-report-20181123_152413.tar.gz

We appreciate your feedback. Thank you for using microk8s. nginx config:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  nginx.config: |
    user nginx;
    worker_processes  3;
    error_log  /var/log/nginx/error.log;
    events {
      worker_connections  10240;
    }
    http {
      log_format  main
              'remote_addr:$remote_addr\t'
              'time_local:$time_local\t'
              'method:$request_method\t'
              'uri:$request_uri\t'
              'host:$host\t'
              'status:$status\t'
              'bytes_sent:$body_bytes_sent\t'
              'referer:$http_referer\t'
              'useragent:$http_user_agent\t'
              'forwardedfor:$http_x_forwarded_for\t'
              'request_time:$request_time';
      access_log        /var/log/nginx/access.log main;
      server {
          listen       80;
          server_name  _;
          location / {
              root   html;
              index  index.html index.htm;
          }
      }
      include /etc/nginx/virtualhost/virtualhost.conf;
    }
  virtualhost.config : |
    upstream app {
      server localhost:8080;
      keepalive 1024;
    }
    server {
      listen 80 default_server;
      root /usr/local/app;
      access_log /var/log/nginx/app.access_log main;
      error_log /var/log/nginx/app.error_log;
      location / {
        proxy_pass http://svc-web/;
        proxy_http_version 1.1;
      }
    }

nginx deployment and service:

apiVersion: v1
kind: Service
metadata:
  name: svc-frontend
spec:
  selector:
    app: nginx
    tier: frontend
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1 # Default is 1
  selector:
    matchLabels:
      app: nginx # Has to match .spec.template.metadata.labels
      tier: frontend
#      track: stable
  template:
    metadata:
      labels:
        app: nginx # Has to match .spec.selector.matchLabels
        tier: frontend
#        track: stable
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
#        image: k8s.gcr.io/nginx-slim:0.8
        image: nginx:latest
        lifecycle:
          preStop:
            exec:
              command: ["/usr/sbin/nginx","-s","quit"]
        ports:
        - containerPort: 80
        volumeMounts:
        - mountPath: /etc/nginx # mount nginx-config volume to /etc/nginx
          readOnly: true
          name: nginx-config-volume
        - mountPath: /var/log/nginx
          name: nginx-log-volume
      volumes:
      - name: nginx-config-volume
        configMap:
          name: nginx-config # place ConfigMap `nginx-conf` on /etc/nginx
          items:
            - key: nginx.config
              path: nginx.conf
            - key: virtualhost.config
              path: virtualhost/virtualhost.conf # dig directory
      - name: nginx-log-volume
        emptyDir: {}
$ k get all
NAME                                          READY   STATUS    RESTARTS   AGE
pod/blazegraph-0                              1/1     Running   0          2d1h
pod/default-http-backend-587b7d64b5-87kfk     1/1     Running   5          7d21h
pod/mysql-0                                   1/1     Running   0          2d1h
pod/nginx-595d6b7577-vmcng                    1/1     Running   0          5m45s
pod/nginx-ingress-microk8s-controller-slrtw   1/1     Running   408        7d21h
pod/web-0                                     1/1     Running   0          2d1h

NAME                           TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
service/default-http-backend   ClusterIP      10.152.183.78    <none>        80/TCP              7d21h
service/kubernetes             ClusterIP      10.152.183.1     <none>        443/TCP             8d
service/svc-db                 ClusterIP      None             <none>        3306/TCP,9999/TCP   2d1h
service/svc-frontend           LoadBalancer   10.152.183.176   <pending>     80:31219/TCP        5m45s
service/svc-web                ClusterIP      None             <none>        80/TCP              2d1h

NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           <none>          7d21h

NAME                                   DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/default-http-backend   1         1         1            1           7d21h
deployment.apps/nginx                  1         1         1            1           5m45s

NAME                                              DESIRED   CURRENT   READY   AGE
replicaset.apps/default-http-backend-587b7d64b5   1         1         1       7d21h
replicaset.apps/nginx-595d6b7577                  1         1         1       5m45s

NAME                          DESIRED   CURRENT   AGE
statefulset.apps/blazegraph   1         1         2d1h
statefulset.apps/mysql        1         1         2d1h
statefulset.apps/web          1         1         2d1h

NAME                                              REFERENCE                TARGETS         MINPODS   MAXPODS   REPLICAS   AGE
horizontalpodautoscaler.autoscaling/istio-pilot   Deployment/istio-pilot   <unknown>/55%   1         1         0          7d21h
$ k describe svc svc-frontend
Name:                     svc-frontend
Namespace:                default
Labels:                   <none>
Annotations:              kubectl.kubernetes.io/last-applied-configuration:
                            {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"svc-frontend","namespace":"default"},"spec":{"ports":[{"port":80,...
Selector:                 app=nginx,tier=frontend
Type:                     LoadBalancer
IP:                       10.152.183.176
Port:                     <unset>  80/TCP
TargetPort:               80/TCP
NodePort:                 <unset>  31219/TCP
Endpoints:                10.1.1.61:80
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
khteh@khteh-T580:/usr/src/kubernetes 2176 $ k get svc svc-frontend --watch
NAME           TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
svc-frontend   LoadBalancer   10.152.183.176   <pending>     80:31219/TCP   5m23s

I expect the EXTERNAL-IP to be allocated so that I could curl / interact with the system. Please advise. Thanks.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

15reactions
ktsakalozoscommented, Apr 23, 2019

It would be nice to have MetalLB as an addon we could enable with microk8s.enable metallb. This could be as easy as placing a metallb.yaml under https://github.com/ubuntu/microk8s/tree/master/microk8s-resources/actions

5reactions
dvdblkcommented, Apr 23, 2019

@joaquin386 , posting your example config would be much appreciated 😃.

EDIT: Nevermind. I got it working on a single (master) cluster. The externalIP is not <pending> anymore! Here is the config:

apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 10.64.140.43-10.64.140.49
Read more comments on GitHub >

github_iconTop Results From Across the Web

Kubernetes service external ip pending - nginx - Stack Overflow
It looks like you are using a custom Kubernetes Cluster (using minikube , kubeadm or the like). In this case, there is no...
Read more >
nginx loadbalancer service EXTERNAL-IP is always ... - GitHub
nginx loadbalancer service EXTERNAL-IP is always in "pending " state # ... 'host:$host\t' 'status:$status\t' 'bytes_sent:$body_bytes_sent\t' ...
Read more >
Load Balancer Services Always Show EXTERNAL-IP Pending
I am trying to get a load balancer service to show a non-pending EXTERNAL-IP. I've been working with the “kubia” services found in...
Read more >
Kubernetes LoadBalancer Service External IP pending
Kubernetes LoadBalancer Service External IP pending. ... At this time, if you deploy LoadBalancer , the External-IP will always be in pending state....
Read more >
EXTERNAL-IP <pending>, why? : r/kubernetes - Reddit
The load balancer is pointing to a Service and the Service is pointing to many (or a single) IP within the cluster, say...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found