How to create custom istio ingress gateway controller?

后端 未结 5 1509
醉酒成梦
醉酒成梦 2020-12-13 16:46

Our GKE cluster is shared to multiple teams in company. Each team can have different public domain (and hence want to have different CA cert setup and also different ingress

5条回答
  •  醉梦人生
    2020-12-13 17:02

    I tried this and worked:

    ---
    # Source: istio/charts/gateways/templates/serviceaccount.yaml
    
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: beta-ingressgateway-service-account
      namespace: beta
      labels:
        app: ingressgateway-beta
    ---
    
    ---
    # Source: istio/charts/gateways/templates/clusterrole.yaml
    
    apiVersion: rbac.authorization.k8s.io/v1beta1
    kind: ClusterRole
    metadata:
      labels:
        app: gateways
      name: ingressgateway-beta
    rules:
    - apiGroups: ["extensions"]
      resources: ["thirdpartyresources", "virtualservices", "destinationrules", "gateways"]
      verbs: ["get", "watch", "list", "update"]
    ---
    
    ---
    # Source: istio/charts/gateways/templates/clusterrolebindings.yaml
    
    apiVersion: rbac.authorization.k8s.io/v1beta1
    kind: ClusterRoleBinding
    metadata:
      name: ingressgateway-beta
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: ingressgateway-beta
    subjects:
      - kind: ServiceAccount
        name: beta-ingressgateway-service-account
        namespace: beta
    ---
    
    ---
    # Source: istio/charts/gateways/templates/service.yaml
    
    apiVersion: v1
    kind: Service
    metadata:
      name: ingressgateway-beta
      namespace: beta
      annotations:
      labels:
        istio: ingressgateway-beta
    spec:
      type: LoadBalancer
      selector:
        istio: ingressgateway-beta
      ports:
        -
          name: http
          port: 80
          targetPort: 80
        -
          name: https
          port: 443
          targetPort: 443
    ---
    
    ---
    # Source: istio/charts/gateways/templates/deployment.yaml
    
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: ingressgateway-beta
      namespace: beta
      labels:
        istio: ingressgateway-beta
    spec:
      replicas: 1
      template:
        metadata:
          labels:
            istio: ingressgateway-beta
          annotations:
            sidecar.istio.io/inject: "false"
            scheduler.alpha.kubernetes.io/critical-pod: ""
        spec:
          serviceAccountName: beta-ingressgateway-service-account
          tolerations:
          - key: "env"
            operator: "Equal"
            value: "beta"
            effect: "NoSchedule"
          nodeSelector:
            env: beta
          containers:
            - name: istio-proxy
              image: "ISTIO_PROXY_IMAGE"
              imagePullPolicy: IfNotPresent
              ports:
                - containerPort: 80
                - containerPort: 443
              args:
              - proxy
              - router
              - -v
              - "2"
              - --discoveryRefreshDelay
              - '1s' #discoveryRefreshDelay
              - --drainDuration
              - '45s' #drainDuration
              - --parentShutdownDuration
              - '1m0s' #parentShutdownDuration
              - --connectTimeout
              - '10s' #connectTimeout
              - --serviceCluster
              - ingressgateway-beta
              - --zipkinAddress
              - zipkin.istio-system:9411
              - --proxyAdminPort
              - "15000"
              - --controlPlaneAuthPolicy
              - NONE
              - --discoveryAddress
              - istio-pilot.istio-system:8080
              resources:
                requests:
                  cpu: 10m
              env:
              - name: POD_NAME
                valueFrom:
                  fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.name
              - name: POD_NAMESPACE
                valueFrom:
                  fieldRef:
                    apiVersion: v1
                    fieldPath: metadata.namespace
              - name: INSTANCE_IP
                valueFrom:
                  fieldRef:
                    apiVersion: v1
                    fieldPath: status.podIP
              - name: ISTIO_META_POD_NAME
                valueFrom:
                  fieldRef:
                    fieldPath: metadata.name
              volumeMounts:
              - name: istio-certs
                mountPath: /etc/certs
                readOnly: true
              - name: ingressgateway-beta-certs
                mountPath: "/etc/istio/ingressgateway-beta-certs"
                readOnly: true
              - name: ingressgateway-beta-ca-certs
                mountPath: "/etc/istio/ingressgateway-beta-ca-certs"
                readOnly: true
          volumes:
          - name: istio-certs
            secret:
              secretName: istio.beta-ingressgateway-service-account
              optional: true
          - name: ingressgateway-beta-certs
            secret:
              secretName: "istio-ingressgateway-beta-certs"
              optional: true
          - name: ingressgateway-beta-ca-certs
            secret:
              secretName: "istio-ingressgateway-beta-ca-certs"
              optional: true
          affinity:
            nodeAffinity:
              requiredDuringSchedulingIgnoredDuringExecution:
                nodeSelectorTerms:
                - matchExpressions:
                  - key: beta.kubernetes.io/arch
                    operator: In
                    values:
                    - amd64
                    - ppc64le
                    - s390x
              preferredDuringSchedulingIgnoredDuringExecution:
              - weight: 2
                preference:
                  matchExpressions:
                  - key: beta.kubernetes.io/arch
                    operator: In
                    values:
                    - amd64
              - weight: 2
                preference:
                  matchExpressions:
                  - key: beta.kubernetes.io/arch
                    operator: In
                    values:
                    - ppc64le
              - weight: 2
                preference:
                  matchExpressions:
                  - key: beta.kubernetes.io/arch
                    operator: In
                    values:
                    - s390x
    ---
    
    ---
    # Source: istio/charts/gateways/templates/autoscale.yaml
    # Source: istio/charts/gateways/templates/autoscale.yaml
    
    apiVersion: autoscaling/v2beta1
    kind: HorizontalPodAutoscaler
    metadata:
        name: ingressgateway-beta
        namespace: beta
    spec:
        maxReplicas: 5
        minReplicas: 1
        scaleTargetRef:
          apiVersion: apps/v1beta1
          kind: Deployment
          name: ingressgateway-beta
        metrics:
        - type: Resource
          resource:
            name: cpu
            targetAverageUtilization: 80
    ---
    

    remember to replace ISTIO_PROXY_IMAGE, nodeSelector and tolerations

提交回复
热议问题