我想设置一个Ingress,将流量路由到我的基础服务。不幸的是,部署我的ingress-controller-deployment.yaml时出现错误,我不知道为什么...带有ingress-controller的容器立即崩溃,并显示错误消息“CrashLoopBackOff”。

据我了解,必须将Ingress-Control部署在Pod中,并且可以通过ingress-svc访问此pod。 Ingress-svc似乎有效,但Pod崩溃了。入口 Controller 工作后,我需要一个附加文件来定义路由和所有内容。但是我看不出继续使用可工作且可部署的入口 Controller 的意义。

Pod description:

    Name:           ingress-controller-7749c785f-x94ll
    Namespace:      ingress
    Node:           gke-cluster-1-default-pool-8484e77d-r4wp/10.128.0.2
    Start Time:     Thu, 26 Apr 2018 14:25:04 +0200
    Labels:         k8s-app=nginx-ingress-lb
                    pod-template-hash=330573419
    Annotations:    kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"ingress","name":"ingress-controller-7749c785f","uid":"d8ff0a6d-494c-11e8-a840
    -420...
    Status:         Running
    IP:             10.8.0.14
    Created By:     ReplicaSet/ingress-controller-7749c785f
    Controlled By:  ReplicaSet/ingress-controller-7749c785f
    Containers:
      nginx-ingress-controller:
        Container ID:  docker://5654c7dffc44510132cba303d66ee570280f2cec235e4d4fa6ef8ad543e0c91d
        Image:         quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0
        Image ID:      docker-pullable://quay.io/kubernetes-ingress-controller/nginx-ingress-controller@sha256:39cc6ce23e5bcdf8aa78bc28bbcfe0999e449bf99fe2e8d60984b417facc5cd4
        Ports:         80/TCP, 443/TCP
        Args:
          /nginx-ingress-controller
          --admin-backend-svc=$(POD_NAMESPACE)/admin-backend
        State:          Waiting
          Reason:       CrashLoopBackOff
        Last State:     Terminated
          Reason:       Error
          Exit Code:    2
          Started:      Thu, 26 Apr 2018 14:26:57 +0200
          Finished:     Thu, 26 Apr 2018 14:26:57 +0200
        Ready:          False
        Restart Count:  4
        Liveness:       http-get http://:10254/healthz delay=10s timeout=5s period=10s #success=1 #failure=3
        Environment:
          POD_NAME:       ingress-controller-7749c785f-x94ll (v1:metadata.name)
          POD_NAMESPACE:  ingress (v1:metadata.namespace)
        Mounts:
          /var/run/secrets/kubernetes.io/serviceaccount from default-token-plbss (ro)
    Conditions:
      Type           Status
      Initialized    True
      Ready          False
      PodScheduled   True
    Volumes:
      default-token-plbss:
        Type:        Secret (a volume populated by a Secret)
        SecretName:  default-token-plbss
        Optional:    false
    QoS Class:       BestEffort
    Node-Selectors:  <none>
    Tolerations: node.alpha.kubernetes.io/notReady:NoExecute for 300s
node.alpha.kubernetes.io/unreachable:NoExecute for 300s
Ingress-controller-deployment.yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ingress-controller
spec:
  replicas: 1
  revisionHistoryLimit: 3
  template:
    metadata:
      labels:
        k8s-app: nginx-ingress-lb
    spec:
      containers:
        - args:
            - /nginx-ingress-controller
            - "--admin-backend-svc=$(POD_NAMESPACE)/admin-backend"
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          image: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.9.0"
          imagePullPolicy: Always
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            timeoutSeconds: 5
          name: nginx-ingress-controller
          ports:
            - containerPort: 80
              name: http
              protocol: TCP
            - containerPort: 443
              name: https
              protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-svc
spec:
  type: LoadBalancer
  ports:
  - name: http
    port: 80
    targetPort: http
  - name: https
    port: 443
    targetPort: https
  selector:
    k8s-app: nginx-ingress-lb

最佳答案

问题是参数。我的一个的args是

      args:
        - /nginx-ingress-controller
        - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
        - --configmap=$(POD_NAMESPACE)/nginx-configuration
        - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
        - --udp-services-configmap=$(POD_NAMESPACE)/udp-services
        - --publish-service=$(POD_NAMESPACE)/ingress-nginx
        - --annotations-prefix=nginx.ingress.kubernetes.io

我还创建了用于配置,tcp和udp的配置映射。

关于nginx - 设置入口(Kubernetes),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50043399/

10-12 22:30