kubernetes ingress nginx controller

4/12/2018

In kubernetes kubeadm cluster i deployed my app with :

kubectl run gmt-dpl --image=192.168.56.33:5000/img:gmt --port 8181

Expose the app with:

kubectl expose deployment gmt-dpl --name=gmt-svc --type=NodePort --port=443 --target-port=8181

My gmt-svc:

Name:                     gmt-svc
Namespace:                default
Labels:                   run=gmt-dpl
Annotations:              <none>
Selector:                 run=gmt-dpl
Type:                     NodePort
IP:                       10.96.74.133
Port:                     <unset>  443/TCP
TargetPort:               8181/TCP
NodePort:                 <unset>  30723/TCP
Endpoints:                10.44.0.17:8181
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

I'm able to access my app on https://noedip:30723

Following github doc i manage to install nginx- controller:

NAMESPACE       NAME                                     READY     STATUS    RESTARTS   AGE
default         gmt-dpl-84fb9cfd8d-vz2bw                 1/1       Running   0          1h
ingress-nginx   default-http-backend-55c6c69b88-c4k6c    1/1       Running   5          2d
ingress-nginx   nginx-ingress-controller-9c7b694-szgjd   1/1       Running   8          2d
kube-system     etcd-k8s-master                          1/1       Running   5          2d
kube-system     kube-apiserver-k8s-master                1/1       Running   1          4h
kube-system     kube-controller-manager-k8s-master       1/1       Running   7          2d
kube-system     kube-dns-6f4fd4bdf-px5f8                 3/3       Running   12         2d
kube-system     kube-proxy-jswfx                         1/1       Running   8          2d
kube-system     kube-proxy-n2chh                         1/1       Running   4          2d
kube-system     kube-scheduler-k8s-master                1/1       Running   7          2d
kube-system     weave-net-4k8sp                          2/2       Running   10         1d
kube-system     weave-net-bqjzb                          2/2       Running   19         1d

I exposed the nginx-controller:

apiVersion: v1
kind: Service
metadata:
  name: nginx-ingress-controller-svc
  namespace: ingress-nginx
spec:
  type: NodePort
  ports:
    - port: 80
      nodePort: 30001
      name: http
    - port: 443
      nodePort: 30000
      name: https
    - port: 18080
      nodePort: 30002
      name: status
  selector:
    app: ingress-nginx

And i created an ingress ressource:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: "nginx"
  name: test-ingress
spec:
  tls:
  - hosts:
    - kube.gmt.dz
    secretName: foo-secret
  rules:
  - host: kube.gmt.dz
    http:
      paths:
      - path: /*
        backend:
          serviceName: gmt-svc
          servicePort: 443

Now while trying to access my app through the nginx-controller with https://ip_master:30000 i got default backend -404 and also with http://ip_master:30001 the same error knowing that my app is only accessible in https. In ingress ressource i tried servicePort: 8181 but i got the same error. Any ideas ?

-- BOUKANDOURA Mhamed
kubernetes
kubernetes-ingress

0 Answers