Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NGINX Ingress Controller creates Load Balancer but no targets are added #12106

Closed
wanGiB opened this issue Oct 5, 2024 · 2 comments
Closed
Labels
needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@wanGiB
Copy link

wanGiB commented Oct 5, 2024

I have set up the NGINX Ingress Controller on my Kubernetes cluster using the following configuration:

kubectl apply -f https://raw.githubusercontent.com/nginxinc/kubernetes-ingress/v3.7.0/deploy/crds.yaml
...
helm install nginx-ingress-controller oci://ghcr.io/nginxinc/charts/nginx-ingress \
    --namespace gateway-system \
    --version "$GATEWAY_CONTROLLER_VERSION" \
    --set controller.service.type=LoadBalancer \
    --set controller.service.externalTrafficPolicy=Local \
    --set controller.config.use-proxy-protocol=true \
    --set controller.service.annotations."load-balancer\.hetzner\.cloud/type"="External" \
    --set controller.service.annotations."load-balancer\.hetzner\.cloud/name"="$HETZNER_LOAD_BALANCER_NAME" \
    --set controller.service.annotations."load-balancer\.hetzner\.cloud/location"="$HETZNER_LOAD_BALANCER_LOCATION" \
    --set controller.gatewayClassName=nginx-gateway-class \
    --set controller.metrics.enabled=true

While the Load Balancer is created successfully, there are no targets (worker nodes) being added to it. Even though there are worker nodes in the cluster, no traffic can reach them through the load balancer.

I have manually added the targets myself, but as soon as I reinitialize the NGINX Ingress Controller, it removes the targets again.

This behavior is confusing, and I do not understand how the services are supposed to be exposed if the targets are consistently removed. Could you please provide clarification or guidance on why the NGINX Ingress Controller isn't properly associating targets with the load balancer?

I intend to use the Gateway API to expose my services and have created the following resources accordingly:

# Apply GatewayClass for NGINX Gateway
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: nginx-gateway-class
spec:
  controllerName: k8s.nginx.org/gateway-controller
EOF

# Verify the Gateway Controller service
kubectl get services -n gateway-system || exit_on_error "Error: Failed to retrieve services in gateway-system namespace."

# Create the Gateway resource
kubectl apply -f - <<EOF
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: example-gateway
  namespace: gateway-system
spec:
  gatewayClassName: nginx-gateway-class
  listeners:
    - name: http
      protocol: HTTP
      port: 80
      allowedRoutes:
        namespaces:
          from: All
EOF

And right below I also attempted to create a custom service that I expect to be a target for the LoadBalancer service:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example
  namespace: socials
spec:
  replicas: 1
  selector:
    matchLabels:
      app: example
  template:
    metadata:
      labels:
        app: example
      annotations:
        kubernetes.io/change-cause: "Updated deployment at $(date)"
    spec:
      containers:
        - name: example
          image: yourusername/placeholder:example
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
          readinessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 10
          resources:
            requests:
              cpu: "100m"
              memory: "1Gi"
            limits:
              cpu: "800m"
              memory: "2Gi"
      imagePullSecrets:
        - name: docker-registry-secret

---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: example
  namespace: socials
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: example
  minReplicas: 1
  maxReplicas: 3
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 80
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 80
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: example-route
  namespace: socials
  labels:
    app: example
spec:
  parentRefs:
    - name: example-gateway
      namespace: gateway-system
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: "/"
      backendRefs:
        - name: example-service
          port: 80
---
apiVersion: v1
kind: Service
metadata:
  name: example-service
  namespace: socials
  labels:
    app: example
spec:
  selector:
    app: example
  ports:
    - port: 80
      targetPort: 8080
  type: ClusterIP

Request for Assistance:
Could you please provide clarification or guidance on the following?

  1. Why isn’t the NGINX Ingress Controller properly associating targets with the LoadBalancer?
  2. What steps can I take to ensure my services are correctly exposed using the Gateway API?

Thank you

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Oct 5, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority labels Oct 5, 2024
@Gacko
Copy link
Member

Gacko commented Oct 5, 2024

Hello @wanGiB,

this is the Open Source Community edition of the Ingress NGINX controller, but you are referring to the F5 maintained version. Please open an issue in their GitHub project for support.

Regards
Marco

@Gacko Gacko closed this as completed Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

3 participants