## nginx configuration
## Ref: https://github.com/kubernetes/ingress-nginx/blob/main/docs/user-guide/nginx-configuration/index.md
##
## Overrides for generated resource names
# See templates/_helpers.tpl
# nameOverride:
fullnameOverride: main-ingress-nginx
controller:
  resources:
    #limits:
    #  memory: {{ .Values.nginx.resources.controller.memory }}
    requests:
      cpu: {{ .Values.nginx.resources.controller.cpu }}
      memory: {{ .Values.nginx.resources.controller.memory }}

  {{if .Values.clusterConfig.ingress_hostnetwork }}
  config:
    worker-processes: 32
  {{end }}

  ingressClassResource:
    default: true

  tolerations:
   - key: unschedulable
     operator: Exists
     effect: NoSchedule
   - key: node-role.kubernetes.io/control-plane
     operator: Exists
     effect: NoSchedule

  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/hostname
            operator: In
            values: {{ .Values.clusterConfig.ingress_nodes }}

    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
          - key: app.kubernetes.io/instance
            operator: In
            values:
            - ingress-nginx
          - key: app.kubernetes.io/component
            operator: In
            values:
            - controller
        topologyKey: "kubernetes.io/hostname"

  podAnnotations:
    config.linkerd.io/skip-inbound-ports: 80,443

  replicaCount: {{ .Values.clusterConfig.ingress_replica_count }}

  minAvailable: {{ .Values.nginx.pdb.minAvailable }}

  service:
  {{- if .Values.clusterConfig.ingress_nodeport }}
    type: NodePort
    externalTrafficPolicy: Local
    nodePorts:
      http: 30080
      https: 30443
      tcp: {}
      udp: {}
  {{- else }}
    type: ClusterIP
  {{- end }}

  hostNetwork: {{ .Values.clusterConfig.ingress_hostnetwork }}

  hostPort:
    enabled: {{ .Values.clusterConfig.ingress_hostport }}
    ports:
      http: 80
      https: 443

  metrics:
    enabled: true

    service:
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "10254"

      servicePort: 9913
      type: ClusterIP

    serviceMonitor:
      enabled: true

  admissionWebhooks:
    enabled: false

## Default 404 backend
##
defaultBackend:
  enabled: true

  tolerations:
   - key: unschedulable
     operator: Exists
     effect: NoSchedule

