apiVersion: apps/v1
kind: Deployment
metadata:
  name: apisix-ingress-controller
  namespace: apisix
  labels:
    app: ingress-controller
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-controller
  template:
    metadata:
      labels:
        app: ingress-controller
    spec:
      serviceAccountName: apisix-ingress-controller
      volumes:
        - name: configuration
          configMap:
            name: apisix-ingress-conf
            items:
              - key: config.yaml
                path: config.yaml
      initContainers:
        - name: wait-apisix-admin
          image: busybox:1.28
          command:
            - sh
            - '-c'
            - >-
              until nc -z apisix-admin.apisix.svc.cluster.local 9180; do echo waiting for apisix-admin `date`; sleep 2; done;
      containers:
        - name: ingress-controller
          command:
            - /ingress-apisix/apisix-ingress-controller
            - ingress
            - --config-path
            - /ingress-apisix/conf/config.yaml
          image: apache/apisix-ingress-controller:1.8.2
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /healthz
              port: 8080
          readinessProbe:
            httpGet:
              path: /healthz
              port: 8080
          volumeMounts:
            - mountPath: /ingress-apisix/conf
              name: configuration
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: apisix-ingress-conf
  namespace: apisix
  labels:
    app: ingress-controller
data:
  config.yaml: |
    # log options
    log_level: "warn"
    log_output: "stderr"
    http_listen: ":8080"
    https_listen: ":8443"
    enable_profiling: true
    apisix_resource_sync_interval: "1h"
    
    kubernetes:
      kubeconfig: ""
      resync_interval: "30s"
      namespace_selector: [""]
      ingress_class: "apisix"
      ingress_version: "networking/v1"
      apisix_route_version: "apisix.apache.org/v2"
    
    apisix:
      admin_api_version: v3
      default_cluster_base_url: "http://apisix-admin.apisix.svc.cluster.local:9180/apisix/admin"
      default_cluster_admin_key: "wJk3P6dFqRl+El5CQL+66H1xEapmM6M496aJk4xjgQo"
---
apiVersion: v1
kind: Service
metadata:
  name: apisix-admin
  namespace: apisix
  labels:
    app: apisix
spec:
  ports:
    - name: apisix-admin
      protocol: TCP
      port: 9180
      targetPort: 9180
  selector:
    app: apisix
  type: ClusterIP
