Key-auth plugin keeps returning 401 (unauthorized)

Hi, I really need help with this one, i have been trying to resolve this for the past 2 days. i am doing everything by the book and really don’t know why it’s not working.

I installed kong api gateway on my kubernetes cloud cluster using the following guide (the OSS version)

I followed the following guide to apply the key-auth plugging

Kong api gateway class / api gateway yaml

apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
  name: kong
  annotations:
    konghq.com/gatewayclass-unmanaged: "true"

spec:
  controllerName: konghq.com/kic-gateway-controller

---

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
  name: kong
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod-issuer
spec:
  gatewayClassName: kong
  listeners:
    - name: proxy
      port: 80
      protocol: HTTP
    - name: proxy-ssl
      port: 443
      protocol: HTTPS
      allowedRoutes:
        namespaces:
          from: All
      tls:
        mode: Terminate
        certificateRefs:
          - name: prod-cert-secret

---

apiVersion: v1
kind: Service
metadata:
  name: proxy
spec:
  ports:
    - name: proxy
      port: 80
      protocol: TCP
      targetPort: 8000
    - name: proxy-ssl
      port: 443
      protocol: TCP
      targetPort: 8443
 

key-auth yaml

apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: api-auth
  annotations: 
    kubernetes.io/ingress.class: kong 
plugin: key-auth
config:
  run_on_preflight: true
  hide_credentials: true
  key_in_body: false
  key_names:
    - apikey
 

KongConsumer yaml

apiVersion: configuration.konghq.com/v1
kind: KongConsumer
metadata:
  name: web
  annotations:
    kubernetes.io/ingress.class: kong
#username: web
credentials:
  - webkey

secret

kubectl create secret generic webkey \
  --from-literal=kongCredType=key-auth \
  --from-literal=key=password

http route

apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
  name: api-route
  annotations:
    konghq.com/strip-path: "true"
    konghq.com/plugins: api-auth
spec:
  parentRefs:
    - name: kong
  rules:
    - matches:
        - path:
            type: PathPrefix
            value: /api/v1/
      backendRefs:
        - name: api-svc
          kind: Service
          port: 3000

despite following the process and rechecking the yamls over and over, i don’t know what might be wrong as when my web application calls the api, I keep getting 401 (unauthorized). please help, i would appreciate any guidance on this