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

request help: hostNetwork #478

Closed
wjx8382 opened this issue May 21, 2021 · 7 comments
Closed

request help: hostNetwork #478

wjx8382 opened this issue May 21, 2021 · 7 comments

Comments

@wjx8382
Copy link

wjx8382 commented May 21, 2021

Issue description

I added hostNetwork: true in the configuration file,then restart apisix,etcd can't start,logs error nc: bad address 'apisix-etcd.tools.svc.cluster.local'

Environment

  • your apisix-ingress-controller version (0.5.0);
  • your Kubernetes cluster version (Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.7", GitCommit:"be3d344ed06bff7a4fc60656200a93c74f31f9a4", GitTreeState:"clean", BuildDate:"2020-02-11T19:34:02Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.7", GitCommit:"be3d344ed06bff7a4fc60656200a93c74f31f9a4", GitTreeState:"clean", BuildDate:"2020-02-11T19:24:46Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"linux/amd64"});
@tokers
Copy link
Contributor

tokers commented May 21, 2021

@wjx8382 Please check out flannel-io/flannel#1243, it should be related with networking route table settings, basically it should not be a problem caused by APISIX or apisix ingress controller.

@wjx8382
Copy link
Author

wjx8382 commented May 21, 2021

@wjx8382 Please check out flannel-io/flannel#1243, it should be related with networking route table settings, basically it should not be a problem caused by APISIX or apisix ingress controller.

But I added same config in apisix-ingress-controller,it is no problem.

@tokers
Copy link
Contributor

tokers commented May 21, 2021

@wjx8382 Please check out flannel-io/flannel#1243, it should be related with networking route table settings, basically it should not be a problem caused by APISIX or apisix ingress controller.

But I added same config in apisix-ingress-controller,it is no problem.

Which configs were added? Could you please paste the related context?

@wjx8382
Copy link
Author

wjx8382 commented May 21, 2021

@wjx8382 Please check out flannel-io/flannel#1243, it should be related with networking route table settings, basically it should not be a problem caused by APISIX or apisix ingress controller.

But I added same config in apisix-ingress-controller,it is no problem.

Which configs were added? Could you please paste the related context?

Both added hostNetwork: true

APISIX config:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: apisix
  namespace: tools
  labels:
    app.kubernetes.io/instance: apisix
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: apisix
    app.kubernetes.io/version: 2.5.0
    helm.sh/chart: apisix-0.3.2
  annotations:
    deployment.kubernetes.io/revision: '8'
    meta.helm.sh/release-name: apisix
    meta.helm.sh/release-namespace: tools
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: apisix
      app.kubernetes.io/name: apisix
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/instance: apisix
        app.kubernetes.io/name: apisix
      annotations:
        checksum/config: b735005fd62683de84283ace7361cb2ef7f0f12b6833d067a17d29fd1ddd5dee
        kubectl.kubernetes.io/restartedAt: '2021-05-18T17:03:12+08:00'
        kubesphere.io/restartedAt: '2021-05-18T09:06:10.668Z'
    spec:
      volumes:
        - name: apisix-config
          configMap:
            name: apisix
            defaultMode: 420
      initContainers:
        - name: wait-etcd
          image: 'busybox:1.28'
          command:
            - sh
            - '-c'
            - >-
              until nc -z apisix-etcd.tools.svc.cluster.local 2379; do
              echo waiting for etcd `date`; sleep 2; done;
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      containers:
        - name: apisix
          image: 'apache/apisix:2.5-alpine'
          ports:
            - name: http
              hostPort: 9080
              containerPort: 9080
              protocol: TCP
            - name: tls
              hostPort: 9443
              containerPort: 9443
              protocol: TCP
            - name: admin
              hostPort: 9180
              containerPort: 9180
              protocol: TCP
          resources:
            limits:
              cpu: '2'
            requests:
              cpu: 50m
          volumeMounts:
            - name: apisix-config
              mountPath: /usr/local/apisix/conf/config.yaml
              subPath: config.yaml
          readinessProbe:
            tcpSocket:
              port: 9080
            initialDelaySeconds: 10
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 6
          lifecycle:
            preStop:
              exec:
                command:
                  - /bin/sh
                  - '-c'
                  - sleep 30
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
          securityContext: {}
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      hostNetwork: true
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

apisix-ingress-controller config:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: apisix-ingress-controller
  namespace: tools
  labels:
    app.kubernetes.io/instance: apisix-ingress-controller
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: apisix-ingress-controller
    app.kubernetes.io/version: 0.5.0
    helm.sh/chart: apisix-ingress-controller-0.4.0
  annotations:
    deployment.kubernetes.io/revision: '3'
    meta.helm.sh/release-name: apisix-ingress-controller
    meta.helm.sh/release-namespace: tools
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/instance: apisix-ingress-controller
      app.kubernetes.io/name: apisix-ingress-controller
  template:
    metadata:
      creationTimestamp: null
      labels:
        app.kubernetes.io/instance: apisix-ingress-controller
        app.kubernetes.io/name: apisix-ingress-controller
      annotations:
        checksum/config: 5f56e67d79de559dec3934c5e39a4dec62bf0cea686f742e1821587a6961a67a
        kubesphere.io/restartedAt: '2021-05-18T09:14:00.574Z'
    spec:
      volumes:
        - name: configuration
          configMap:
            name: apisix-ingress-controller-configmap
            items:
              - key: config.yaml
                path: config.yaml
            defaultMode: 420
      containers:
        - name: apisix-ingress-controller
          image: 'apache/apisix-ingress-controller:0.5.0'
          command:
            - /ingress-apisix/apisix-ingress-controller
            - ingress
            - '--config-path'
            - /ingress-apisix/conf/config.yaml
          ports:
            - name: http
              hostPort: 8080
              containerPort: 8080
              protocol: TCP
          env:
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.namespace
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  apiVersion: v1
                  fieldPath: metadata.name
          resources: {}
          volumeMounts:
            - name: configuration
              mountPath: /ingress-apisix/conf
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
              scheme: HTTP
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
              scheme: HTTP
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: apisix-ingress-controller
      serviceAccount: apisix-ingress-controller
      hostNetwork: true
      securityContext: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

@tokers
Copy link
Contributor

tokers commented May 21, 2021

Not sure whether this is caused by the CNI plugin that you're using. @wjx8382 Could you show some details?

@tao12345666333 Are you familiar with this?

@tao12345666333
Copy link
Member

If you using hostNetwork: true , you should change the dnsPolicy to dnsPolicy: ClusterFirstWithHostNet

@wjx8382
Copy link
Author

wjx8382 commented May 24, 2021

If you using hostNetwork: true , you should change the dnsPolicy to dnsPolicy: ClusterFirstWithHostNet

It is resolved,thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants