Skip to content

use hostnetwork mode can't connect to control plane #4351

@wcollin

Description

@wcollin

nginx-gateway-fabric: 2.2.1
kubernetes: v1.32.5

i want to use hostnetwork mode to run gateway,when i create gateway, agent can't get pod name。it has error:

{"level":"info","ts":"2025-11-28T02:43:41Z","logger":"nginxUpdater.commandService","msg":"Creating connection for nginx pod: rke2-server-01"}
{"level":"error","ts":"2025-11-28T02:43:41Z","logger":"nginxUpdater.commandService","msg":"error getting pod owner","error":"no pods found with name "rke2-server-01"","stacktrace":"github.com/nginx/nginx-gateway-fabric/v2/internal/controller/nginx/agent.(*commandService).CreateConnection\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/internal/controller/nginx/agent/command.go:98\ngithub.com/nginx/agent/v3/api/grpc/mpi/v1._CommandService_CreateConnection_Handler.func1\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/.gocache/github.com/nginx/agent/v3@v3.5.0/api/grpc/mpi/v1/command_grpc.pb.go:191\ngithub.com/nginx/nginx-gateway-fabric/v2/internal/controller/nginx/agent/grpc/interceptor.(*ContextSetter).Unary.ContextSetter.Unary.func1\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/internal/controller/nginx/agent/grpc/interceptor/interceptor.go:83\ngithub.com/nginx/agent/v3/api/grpc/mpi/v1._CommandService_CreateConnection_Handler\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/.gocache/github.com/nginx/agent/v3@v3.5.0/api/grpc/mpi/v1/command_grpc.pb.go:193\ngoogle.golang.org/grpc.(*Server).processUnaryRPC\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/.gocache/google.golang.org/grpc@v1.76.0/server.go:1431\ngoogle.golang.org/grpc.(*Server).handleStream\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/.gocache/google.golang.org/grpc@v1.76.0/server.go:1842\ngoogle.golang.org/grpc.(*Server).serveStreams.func2.1\n\t/opt/actions-runner/_work/nginx-gateway-fabric/nginx-gateway-fabric/.gocache/google.golang.org/grpc@v1.76.0/server.go:1061"}

nginxGateway:
kind: deployment
replicas: 1
image:
repository: ghcr.io/nginx/nginx-gateway-fabric
tag: 2.2.1

nginx:
kind: daemonSet
replicas: 1
image:
repository: ghcr.io/nginx/nginx-gateway-fabric/nginx
tag: 2.2.1
gateways:
- http-gateway
service:
type: ClusterIP
patches:

  • type: StrategicMerge
    value:
    spec:
    template:
    spec:
    hostNetwork: true
    dnsPolicy: ClusterFirstWithHostNet
  • type: JSONPatch
    value:
    • op: remove
      path: /spec/template/spec/securityContext/sysctls/0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions