ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Ingress-Nginx高可用

2020-03-02 22:54:09  阅读:78  来源: 互联网

标签:Ingress name nginx 可用 ingress Nginx controller master true



以最新版的nginx-ingress-controller:0.30.0为例 

高可用Ingress 架构如下:

1、修改Deployment为DaemonSet,并注释掉副本数

2、启用hostNetwork网络,并指定运行节点

hostNetwork暴露ingress-nginx controller的相关业务端口到主机,这样node节点主机所在网络的其他主机,都可以通过该端口访问到此应用程序。

nodeSelector指定之前添加ingress-controller=true标签的node

3、修改镜像地址

4、增加master节点容忍

tolerations: #增加容忍,可分配到master节点
      - key: "node-role.kubernetes.io/master"
        operator: "Exists"
        effect: "NoSchedule"

 

修改 https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml 中的nginx-ingress-controller部分

apiVersion: apps/v1
#kind: Deployment
kind: DaemonSet
metadata:
  name: nginx-ingress-controller
  namespace: ingress-nginx
  labels:
    k8s-app: ingress-controller
spec:
  #replicas: 1
  selector:
    matchLabels:
      k8s-app: ingress-controller
  template:
    metadata:
      labels:
        k8s-app: ingress-controller
      annotations:
        prometheus.io/port: "10254"
        prometheus.io/scrape: "true"
    spec:
      # wait up to five minutes for the drain of connections
      terminationGracePeriodSeconds: 300
      serviceAccountName: nginx-ingress-serviceaccount
      hostNetwork: true
      nodeSelector:
        ingress-controller: "true"

        tolerations: #增加容忍,可分配到master节点
          - key: "node-role.kubernetes.io/master"
            operator: "Exists"
            effect: "NoSchedule"

       containers:
        - name: nginx-ingress-controller
          image: registry-vpc.cn-beijing.aliyuncs.com/base/nginx-ingress-controller:0.30.0
          args:
            - /nginx-ingress-controller
            - --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
          securityContext:
            allowPrivilegeEscalation: true
            capabilities:
              drop:
                - ALL
              add:
                - NET_BIND_SERVICE
            # www-data -> 101
            runAsUser: 101
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
            - name: https
              containerPort: 443
              protocol: TCP
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 10
          lifecycle:
            preStop:
              exec:
                command:
                  - /wait-shutdown

 

节点打标签:

# kubectl label node master-92 ingress-controller="true"

 



标签:Ingress,name,nginx,可用,ingress,Nginx,controller,master,true
来源: https://www.cnblogs.com/wjoyxt/p/12398661.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有