How to set external IP for nginx-ingress controller in private cloud kubernetes cluster

5/7/2019

I am setting up a kubernetes cluster to run hyperledger fabric apps. My cluster is on a private cloud hence I don't have a load balancer. How do I set an IP address for my nginx-ingress-controller(pending) to expose my services? I think it is interfering with my creation of pods since when I run kubectl get pods, I see very many evicted pods. I am using certmanager which I think also needs IPs.

CA_POD=$(kubectl get pods -n cas -l "app=hlf-ca,release=ca" -o jsonpath="{.items[0].metadata.name}")

This does not create any pods.

nginx-ingress-controller-5bb5cd56fb-lckmm      1/1     Running

nginx-ingress-default-backend-dc47d79c-8kqbp   1/1     Running 

The rest take the form

nginx-ingress-controller-5bb5cd56fb-d48sj      0/1     Evicted 

ca-hlf-ca-5c5854bd66-nkcst  0/1    Pending  0         0s
ca-postgresql-0             0/1    Pending  0         0s

I would like to create pods from which I can run exec commands like

kubectl exec -n cas $CA_POD -- cat /var/hyperledger/fabric-ca/msp/signcertscert.pem
-- Brigetta
controller
kubernetes-ingress
nginx

1 Answer

5/7/2019

You are not exposing nginx-controller IP address, but nginx's service via node port. For example:

piVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-controller
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30080
      name: http
  selector:
    app: nginx

In this case you'd be able to reach your service like

curl -v <NODE_EXTERNAL_IP>:30080

To the question, why your pods are in pending state, pls describe misbehaving pods:

kubectl describe pod nginx-ingress-controller-5bb5cd56fb-d48sj

Best approach is to use helm

helm install stable/nginx-ingress
-- A_Suh
Source: StackOverflow