Kubernetes Ingress not accessible (localhost)
Asked Answered
H

1

6

I am setting up a minimal Kubernetes cluster on localhost on a Linux machine (starting with hack/local-up-cluster from the checked out repo). In my deployment file I defined an ingress, which should make the services, which are deployed in the cluster, accessible from the outside. Deployment.yml:

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: foo-service-deployment
spec:
  replicas: 2
  template:
    metadata:
      labels:
        app: foo-service
    spec:
      containers:
        - name: foo-service
          image: images/fooservice
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 7778
---
apiVersion: v1
kind: Service
metadata:
  name: foo-service-service
spec:
  ports:
    - port: 7778
  selector:
    app: foo-service
  type: NodePort
---    
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: api-gateway-ingress
spec:
  rules:
  - host:
    http:
      paths:
      - path: /foo
        backend:
          serviceName: foo-service-service
          servicePort: 7779
      - path: /bar
        backend:
          serviceName: bar-service-service
          servicePort: 7776

I can not access the services. kubectl describe shows the following for my ingress:

Name:           api-gateway-ingress
Namespace:      default
Address:        
Default backend:    default-http-backend:80 (<none>)
Rules:
  Host  Path    Backends
  ----  ----    --------
  * 
        /foo    foo-service-service:7779 (<none>)
        /bar    bar-service-service:7776 (<none>)
Annotations:
Events: <none>

Is it because there is not address set for my ingress, that it is not visible to outside world yet?

Hexose answered 20/7, 2017 at 12:58 Comment(0)
C
13

An Ingress resource is just a definition for your cluster how to handle ingress traffic. It needs an Ingress Controller to actually process these definitions; creating an Ingress resource without having deployed an Ingress controller will not have any effect.

From the documentation:

In order for the Ingress resource to work, the cluster must have an Ingress controller running. This is unlike other types of controllers, which typically run as part of the kube-controller-manager binary, and which are typically started automatically as part of cluster creation. You need to choose the ingress controller implementation that is the best fit for your cluster, or implement one.

There are several Ingress controllers available that you can deploy by yourself (typically, via a Deployment resource), like for example the NGINX ingress controller (which is part of the Kubernetes project) or third-party ingress controllers like Traefik, Envoy or Voyager.

Chickasaw answered 20/7, 2017 at 17:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.