Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help on configuring Nginx ingress controller for hcloud-cloud-controller-manager

I'm trying to follow this suggestion to use Hetzner load balancer as a Nginx ingress controller.

helm install ingress-nginx with these configurations:

controller:
  config:
    use-proxy-protocol: "true"
  replicaCount: 3
  service:
    type: LoadBalancer
    annotations:
      load-balancer.hetzner.cloud/name: nginx-controller-new
      load-balancer.hetzner.cloud/location: hel1
      load-balancer.hetzner.cloud/use-private-ip: true
      load-balancer.hetzner.cloud/algorithm-type: least_connections
      load-balancer.hetzner.cloud/uses-proxyprotocol: true
      load-balancer.hetzner.cloud/hostname: somehost.com

Deployments:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: echo1
spec:
  selector:
    matchLabels:
      app: echo1
  replicas: 3
  template:
    metadata:
      labels:
        app: echo1
    spec:
      containers:
        - name: echo1
          image: hashicorp/http-echo
          args:
            - "-text=echo1"
          ports:
            - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  name: echo-service
spec:
  selector:
    app: echo1
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 5678
  ipFamilyPolicy: PreferDualStack

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx
spec:
  ingressClassName: nginx
  rules:
    - http:
        paths:
          - pathType: Prefix
            path: "/"
            backend:
              service:
                name: echo-service
                port:
                  number: 80
      host: somehost.com

After installation, a Hetzner load balancer is successfully provisioned, however, it isn't able to detect the services:

enter image description here

I'm at a loss here. How can I connect the echo1 app to the ingress-nginx-controller service? I check out all of the available helm values but I cannot find something like service.selector to target echo1's service and make it publicly available. Can someone help me? Are there any alternatives?

like image 926
RedGiant Avatar asked Feb 26 '26 21:02

RedGiant


1 Answers

I am not the Kubernetes master (more a noob) but I got it working with a L4-loadbalancer.

An annotation has to be set to your Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: nginx

And to use it without nginx-ingress, that worked for me (not tested with your labels)

apiVersion: "apps/v1"
kind: "Deployment"
metadata:
  name: "nginx-hello-world"
  labels:
    app: "hello-world"
spec:
  selector:
    matchLabels:
      app: "hello-world"
  strategy:
    type: "Recreate"
  template:
    metadata:
      labels:
        app: "hello-world"
    spec:
      containers:
        - image: "rancher/hello-world"
          name: "nginx-hello-world"
          imagePullPolicy: "Always"
          ports:
            - containerPort: 80
              name: "http"

Service for HTTP (to test your deployment)

---
apiVersion: "v1"
kind: Service
metadata:
  name: "nginx-hello-world"
  labels:
    app: "hello-world"
  annotations:
    load-balancer.hetzner.cloud/name: lb-development
    load-balancer.hetzner.cloud/hostname: somehost.com
    load-balancer.hetzner.cloud/protocol:   http
    load-balancer.hetzner.cloud/health-check-port: 10254
spec:
  type: LoadBalancer
  selector:
    app: "hello-world"
  ports:
    - name: "http"
      port: 80
      targetPort: 80

for SSL

apiVersion: v1
kind: Service
metadata:
  name: nginx-hello-world
  labels:
    app: hello-world
  annotations:
    load-balancer.hetzner.cloud/hostname: somehost.com
    load-balancer.hetzner.cloud/http-certificates: managed-certificate-1-wildcard-somehost.com
    load-balancer.hetzner.cloud/name: lb-development
    load-balancer.hetzner.cloud/protocol: https
spec: 
  ports:
  - name: https
    nodePort: 32725
    port: 443
    protocol: TCP
    targetPort: 80
  selector:
    app: hello-world
  type: LoadBalancer

like image 177
Jan Avatar answered Mar 03 '26 11:03

Jan