0

I'm using this nginx ingress controller on Hetzner server. After installation of ingress controller, I'm able to access the worker node by its IP, but not able to access the app running on pod inside the cluster. am I missing something? Are Ingress and Traefik are different, a bit confused in the terminologies.

service file -

apiVersion: v1
kind: Service
metadata:
  name: service-name-xxx
spec:
  selector:
    app: app-name
  ports:
    - protocol: 'TCP'
      port: 80
      targetPort: 4200
  type: LoadBalancer

deployment file -

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-name
  labels:
    app: app-name
spec:
  replicas: 1
  selector:
    matchLabels:
      app: app-name
  template:
    metadata:
      labels:
        app: app-name
    spec:
      imagePullSecrets:
      - name: my-registry-key
      containers:
      - name: container-name
        image: my-private-docker-img
        imagePullPolicy: Always
        ports:
        - containerPort: 4200

ingress file -

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-name
spec:
  rules:
  - host:
    http:
      paths:
      - pathType: Prefix
        path: "/app"
        backend:
          service:
            name: service-name-xxx
            port:
              number: 4200
neekheel
  • 98
  • 2
  • 18
  • Have you exposed your app? Could you share any configuration files? Answering your last question Traefik is an Ingress controller, such as nginx and the other ones as per the official documentation. – Jakub Siemaszko Jul 15 '21 at 11:35
  • @JakubSiemaszko I added file above & also tried command `kubectl expose deployment deployment-name --type=LoadBalancer --name=service-name-xxx` which is saying `Error from server (AlreadyExists): services "service-name-xxx" already exists` – neekheel Jul 16 '21 at 04:29

2 Answers2

0

You have set port to 80 and targetPort to 4200 in your service. Should mention port 80 in your ingress yaml.

backend:
    service:
      name: service-name-xxx
      port: 80
      targetPort: 4200
therealak12
  • 1,178
  • 2
  • 12
  • 26
Izaz
  • 1
  • 1
0

I think you have to add the kubernetes.io/ingress.class: "nginx" to your Ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-name
    spec:
      name: hsts-ingress-backend1-minion
      annotations:
        kubernetes.io/ingress.class: "nginx"
Jan
  • 12,992
  • 9
  • 53
  • 89