kuberneteskong

Kong Ingress Controller - How to deploy Kong DB-backed with kong/ingress


TL;DR

How can I deploy Kong DB-backed with kong/ingress helm chart? Which configuration values I need to set?

Long Version

I want to try the Oauth2 plugin which, from the docs, is said to require a Database:

This plugin requires a database in order to work effectively. It does not work in DB-less or hybrid mode.

Reading the deployment part of the Kong Ingress Controller documentation, it's said one can use the kong/ingress helm chart to install Kong both DB-less and DB-backed:

Kong recommends using the kong/ingress Helm chart to deploy Kong Ingress Controller. This chart supports both DB-less and DB-backed deployments.

However, I cannot understand what config parameters I should use to deploy the database pod.

What I Tried

File values.yaml:

deployment:
  test:
    enabled: false

controller:
  proxy:
    nameOverride: "{{ .Release.Name }}-gateway-proxy"

  enabled: true

  deployment:
    kong:
      enabled: false

  ingressController:
    enabled: true

    gatewayDiscovery:
      enabled: false
      generateAdminApiService: false

  podAnnotations:
    kuma.io/gateway: enabled
    # This port must match your Kong admin API port. 8444 is the default.
    # If you set gateway.admin.tls.containerPort, change these annotations
    # to use that value.
    traffic.kuma.io/exclude-outbound-ports: "8444"
    traffic.sidecar.istio.io/excludeOutboundPorts: "8444"

gateway:
  enabled: true
  deployment:
    kong:
      enabled: true

  admin:
    enabled: true
    type: ClusterIP
    clusterIP: None

  ingressController:
    enabled: false

  env:
    role: traditional
    database: "postgres"

Then I deploy Kong with:

helm install kong kong/ingress -n kong --create-namespace --values .\test-standard-values.yaml

And I wait for pods to be Running and Ready:

$ kubectl get pods -n kong
kong-controller-549fcc4d84-d5l2f     0/1     Running            0             45s
kong-gateway-5fd66b7498-jh4q6        0/1     Init:1/2           0             45s
kong-gateway-init-migrations-259c6   0/1     CrashLoopBackOff   2 (21s ago)   45s

However, I see that there's no pod for the Postgres database and the kong-gateway-init pod keeps crashing and restarting, with the following logs:

Error: [PostgreSQL error] failed to retrieve PostgreSQL server_version_num: connection refused

Question

Can anyone provide me an example with the configuration parameters (of the values.yaml file), needed to enable the "DB support"? Or help me understand if there's anything I'm missing or I'm doing wrong?


Solution

  • Hi You need to pass the database-related environment variables to the values yaml file. Here are the environment variables which should work for you as well.

    env:
      database: postgres
      pg_host: postgresql
      pg_user: kong
      pg_password: kong
      admin_gui_path: /
      admin_gui_api_url: /api
    

    Add your values in env: section of values yaml as shown above.