0
votes

I have a kubernetes cluster on amazon ews on which I intend to run multiple applications.

I have multiple services which make up one such application and I want to expose them to the internet using an amazon load balancer (elb). I want to use the ELB because I don't want to use port 80 directly as many applications share this port and I want each one of them to define their ingress resource independent of others.

I read about kubernetes ingress resources and thought that is exactly what I'm looking for. However I didn't manage to expose it through a service with load balancer. Now when I read the documentation Services are meant to expose pods but an ingress is:

An API object that manages external access to the services in a cluster, typically HTTP.

Is what I'm trying to do possible or did I not grasp some concept and trying to do something impossible or wrong?


My code:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
  labels:
    id: ingress
spec:
  rules:
  - http:
      paths:
      - path: /api/devices
        backend:
          serviceName: device-management
          servicePort: 3001
      - path: /api/datasources
        backend:
          serviceName: data-acquisition
          servicePort: 3001
      - path: /auth,/account,/api/tenants,/api/users
        backend:
          serviceName: device-management
          servicePort: 3001
## TODO: Find out how to add subdomain entry for auth.domain and s3.domain 
---
apiVersion: v1
kind: Service
metadata:
  name: ingress
  labels:
    id: ingress
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: 80
  - name: https
    port: 443
    targetPort: 443
  selector:
    id: ingress 

Output from kubectl describe service ingress contains

Endpoints: none

1
I've applied successfully configuration you provided. No problems detected. It looks like an environment problem. What kind of installation it is? Is your cluster created with Kops using --cloud--providerer and --cloud-config?d0bry
Errata. Proper parameters: --cloud-provider and --cloud-configd0bry

1 Answers

0
votes

The problem is that I didn't install an ingress controller. The documentation states:

You need an Ingress controller to satisfy an Ingress, simply creating the resource will have no effect.

The ingress controller creates an nginx pod and a service (load balancer) which will then implement the rules described in all ingress resources. The installation guide gives further information on how to install it on different platforms.

The ingress controller replaces the service which I desribed above and implements all ingress resources desribed in the cluster.