How to set ttl for key-auth plugin

The key auth plugin mentions that is possible to set a ttl
" The number of seconds the key is going to be valid. If missing or set to zero, the ttl of the key is unlimited. If present, the value must be an integer between 0 and 100000000."

I’m deploying Kong ingress controller on Kubernetes as follows, however not sure where to configure the ttl parameter

kind: Ingress
metadata:
name: baas
annotations:
konghq.com/plugins: key-auth-example
konghq.com/strip-path: “true”
spec:
ingressClassName: kong
rules:
- host: test.example.com

kind: KongPlugin
metadata:
name: key-auth-example
config:
key_names:
- apikey
key_in_body: false
key_in_header: true
key_in_query: true
hide_credentials: false
run_on_preflight: true
plugin: key-auth

data:
key: bXktc29vcGVyLXNlY3JldC1rZXk=
kongCredType: a2V5LWF1dGg=
kind: Secret
metadata:
name: harry-apikey
type: Opaque

kind: KongConsumer
metadata:
name: harry
annotations:
kubernetes.io/ingress.class: kong
username: harry
credentials:

  • harry-apikey

The ttl field is part of the credential, so it will be another item in your Secret’s data.

Thanks traines for replying,

Configured the secret with the ttl and base64 encoded value for 1000 and got an error in kong ingress controller logs:
time=“2022-06-30T23:37:36Z” level=error msg=“failed to provision credential: failed to decode key-auth credential: failed to decode credential: 1 error(s) decoding:\n\n* ‘ttl’ expected type ‘int’, got unconvertible type ‘string’, value: ‘1000’” kongconsumer_name=harry kongconsumer_namespace=default secret_name=harry-apikey secret_namespace=default

apiVersion: v1
data:
key: bXktc29vcGVyLXNlY3JldC1rZXk=
kongCredType: a2V5LWF1dGg=
ttl: MTAwMA==
kind: Secret
metadata:
name: harry-apikey
type: Opaque

That looks like it’s a limitation in the credential parser that I can’t see an easy way to address, so I’ve created Int fields in credential Secrets incorrectly handled as strings · Issue #2734 · Kong/kubernetes-ingress-controller · GitHub to investigate a fix.