从使用Nginx控制器部署的应用程序中随机注销

时间:2019-06-07 09:49:49

标签: nginx

我想就以下问题向您寻求帮助:我的应用程序已部署在Microsoft AKS上。负载均衡是使用nginx控制器配置的。我无缘无故地从应用程序中注销,而使用Azure Load Balancer作为服务时没有问题。我从nginx检查了日志,根本没有错误...

有Nginx控制器的配置:

---
# Source: nginx-ingress/templates/controller-poddisruptionbudget.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "controller"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-controller
spec:
  selector:
    matchLabels:
      app: nginx-ingress
      release: vm-nginx
      component: "controller"
  minAvailable: 1
---
# Source: nginx-ingress/templates/default-backend-poddisruptionbudget.yaml
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "default-backend"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-default-backend
spec:
  selector:
    matchLabels:
      app: nginx-ingress
      release: vm-nginx
      component: "default-backend"
  minAvailable: 1
---
# Source: nginx-ingress/templates/controller-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "controller"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-controller
data:
  enable-vts-status: "false"
  http-redirect-code: "301"
  proxy-hide-headers: "Server"
  server-tokens: "false"
---
# Source: nginx-ingress/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress
---
# Source: nginx-ingress/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress
rules:
  - apiGroups:
      - ""
    resources:
      - configmaps
      - endpoints
      - nodes
      - pods
      - secrets
    verbs:
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - nodes
    verbs:
      - get
  - apiGroups:
      - ""
    resources:
      - services
    verbs:
      - get
      - list
      - update
      - watch
  - apiGroups:
      - extensions
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - events
    verbs:
      - create
      - patch
  - apiGroups:
      - extensions
    resources:
      - ingresses/status
    verbs:
      - update
---
# Source: nginx-ingress/templates/clusterrolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: vm-nginx-nginx-ingress
subjects:
  - kind: ServiceAccount
    name: vm-nginx-nginx-ingress
    namespace: kube-system
---
# Source: nginx-ingress/templates/role.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress
rules:
  - apiGroups:
      - ""
    resources:
      - namespaces
    verbs:
      - get
  - apiGroups:
      - ""
    resources:
      - configmaps
      - pods
      - secrets
      - endpoints
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - services
    verbs:
      - get
      - list
      - update
      - watch
  - apiGroups:
      - extensions
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - extensions
    resources:
      - ingresses/status
    verbs:
      - update
  - apiGroups:
      - ""
    resources:
      - configmaps
    resourceNames:
      - ingress-controller-leader-nginx
    verbs:
      - get
      - update
  - apiGroups:
      - ""
    resources:
      - configmaps
    verbs:
      - create
  - apiGroups:
      - ""
    resources:
      - endpoints
    verbs:
      - create
      - get
      - update
  - apiGroups:
      - ""
    resources:
      - events
    verbs:
      - create
      - patch
---
# Source: nginx-ingress/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: vm-nginx-nginx-ingress
subjects:
  - kind: ServiceAccount
    name: vm-nginx-nginx-ingress
    namespace: kube-system
---
# Source: nginx-ingress/templates/controller-service.yaml
apiVersion: v1
kind: Service
metadata:
  annotations:
    service.beta.kubernetes.io/azure-load-balancer-resource-group: vm-qa-performance-rg

  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "controller"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-controller
spec:
  clusterIP: ""
  loadBalancerIP: "<my_ip>"
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 80
    - name: https
      port: 443
      protocol: TCP
      targetPort: 443
  selector:
    app: nginx-ingress
    component: "controller"
    release: vm-nginx
  type: "LoadBalancer"
---
# Source: nginx-ingress/templates/default-backend-service.yaml
apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "default-backend"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-default-backend
spec:
  clusterIP: ""
  ports:
    - port: 80
      targetPort: 8080
  selector:
    app: nginx-ingress
    component: "default-backend"
    release: vm-nginx
  type: "ClusterIP"
---
# Source: nginx-ingress/templates/controller-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "controller"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-controller
spec:
  replicas: 2
  revisionHistoryLimit: 10
  strategy:
    {}

  minReadySeconds: 0
  template:
    metadata:
      labels:
        app: nginx-ingress
        component: "controller"
        release: vm-nginx
    spec:
      dnsPolicy: ClusterFirst
      containers:
        - name: nginx-ingress-controller
          image: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.13.0"
          imagePullPolicy: "IfNotPresent"
          args:
            - /nginx-ingress-controller
            - --default-backend-service=kube-system/vm-nginx-nginx-ingress-default-backend
            - --election-id=ingress-controller-leader
            - --ingress-class=nginx
            - --configmap=kube-system/vm-nginx-nginx-ingress-controller
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          livenessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 3
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
            - name: https
              containerPort: 443
              protocol: TCP
          readinessProbe:
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            timeoutSeconds: 1
            successThreshold: 1
            failureThreshold: 3
          resources:
            {}

      hostNetwork: false
      serviceAccountName: vm-nginx-nginx-ingress
      terminationGracePeriodSeconds: 60
---
# Source: nginx-ingress/templates/default-backend-deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: nginx-ingress
    chart: nginx-ingress-0.17.1
    component: "default-backend"
    heritage: Tiller
    release: vm-nginx
  name: vm-nginx-nginx-ingress-default-backend
spec:
  replicas: 1
  revisionHistoryLimit: 10
  template:
    metadata:
      labels:
        app: nginx-ingress
        component: "default-backend"
        release: vm-nginx
    spec:
      containers:
        - name: nginx-ingress-default-backend
          image: "k8s.gcr.io/defaultbackend:1.3"
          imagePullPolicy: "IfNotPresent"
          args:
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
              scheme: HTTP
            initialDelaySeconds: 30
            timeoutSeconds: 5
          ports:
            - containerPort: 8080
              protocol: TCP
          resources:
            {}

      terminationGracePeriodSeconds: 60

有用于入口的配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name: ingress-vm-qa-performance
    annotations:
      kubernetes.io/ingress.class: "nginx"
      nginx.ingress.kubernetes.io/affinity: cookie
      nginx.ingress.kubernetes.io/ssl-redirect: "false"
      nginx.ingress.kubernetes.io/proxy-body-size: "0"

spec:
    rules:
    - http:
        paths:
        - path: /
          backend:
            serviceName: vm-qa-performance
            servicePort: 8080

并且有该服务的配置:

apiVersion: v1
kind: Service
metadata:
    name: vm-qa-performance
spec:
    ports:
    - port: 8080
      name: http
    - port: 8443
      name: https
    selector:
        app: vm-qa-performance

但是,当我不使用nginx时,但服务如下所示,一切正常...

apiVersion: v1
kind: Service
metadata:
    annotations:
        service.beta.kubernetes.io/azure-load-balancer-resource-group: vm-qa-performance-rg
    name: vm-qa-performance
spec:
    loadBalancerIP: <my_ip>
    type: LoadBalancer
    sessionAffinity: ClientIP
    ports:
    - port: 8080
      name: http
    - port: 8443
      name: https
    selector:
        app: vm-qa-performance

您是否有任何想法可能是原因或在哪里寻找问题?预先谢谢你!

0 个答案:

没有答案