apisix-ingress-controller icon indicating copy to clipboard operation
apisix-ingress-controller copied to clipboard

help request: K8S 使用 helm 部署 apisix 2.3.1 启用 hostNetwork 参数,无法配置80和443端口

Open klvchen opened this issue 2 years ago • 2 comments

Description

我使用下面配置

cat my-values.yaml

hostNetwork: true
service:
  http:
    containerPort: 80
apisix:
  ssl:
    containerPort: 443
    enabled: true
nodeSelector:
  kubernetes.io/hostname: k8s-node-2
timezone: "Asia/Shanghai"
etcd:
  global:
    storageClass: "nfs-client"
  persistence:
    size: 6Gi
dashboard:
  enabled: true
ingress-controller:
  enabled: true
  config:
    apisix:
      serviceNamespace: apisix

helm -n apisix install apisix -f my-values.yaml ./apisix

运行报错

Defaulted container "apisix" out of: apisix, wait-etcd (init)
/usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua init

WARNING: using fixed Admin API token has security risk.
Please modify "admin_key" in conf/config.yaml .


/usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua init_etcd
2023/11/16 15:21:12 [warn] 1#1: low address bits of 127.0.0.1/24 are meaningless in /usr/local/apisix/conf/nginx.conf:223
nginx: [warn] low address bits of 127.0.0.1/24 are meaningless in /usr/local/apisix/conf/nginx.conf:223
2023/11/16 15:21:12 [emerg] 1#1: bind() to 0.0.0.0:80 failed (13: Permission denied)
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)

但是如果我把端口改成其他,容器能正常起来,例如

service:
  http:
    containerPort: 8080
apisix:
  ssl:
    containerPort: 7443
    enabled: true

我该如何配置,才能使用 80 和 443 端口?谢谢~

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

我部署的环境是 K8S v1.24.1 with containerd://1.6.8

[root@k8s-master-1 apisix]# helm version version.BuildInfo{Version:"v3.10.0", GitCommit:"ce66412a723e4d89555dc67217607c6579ffcb21", GitTreeState:"clean", GoVersion:"go1.18.6"}

helm chart 版本是 apisix/apisix 2.3.1

klvchen avatar Nov 16 '23 07:11 klvchen

hi @klvchen, It may be that normal users don't have privileges, and ports within 1024 may require a root user

luoluoyuyu avatar Nov 16 '23 07:11 luoluoyuyu

hi @klvchen, It may be that normal users don't have privileges, and ports within 1024 may require a root user

在我的环境中,我测试过

cat deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      nodeName: k8s-node-2
      containers:
      - name: nginx
        image: nginx:1.7.9

kubectl apply -f deployment.yaml

[root@k8s-master-1 nginx]# kubectl get pod -o wide
NAME                                     READY   STATUS    RESTARTS        AGE     IP              NODE         NOMINATED NODE   READINESS 
nginx-776469cf65-r2dg6                   1/1     Running   0               2m10s   172.16.16.110   k8s-node-2   <none>           <none>

这个 nginx pod 可以在 k8s-node-2 正常使用80端口,不知道为什么 apisix 不行~ 谢谢

klvchen avatar Nov 16 '23 08:11 klvchen

This issue has been marked as stale due to 90 days of inactivity. It will be closed in 30 days if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.

github-actions[bot] avatar Mar 12 '24 01:03 github-actions[bot]

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

github-actions[bot] avatar Apr 11 '24 01:04 github-actions[bot]