API definitions and Ingress through Tyk-operator and Gateway

I tried to create an Ingress and ApiDefinition definition through tyk-operator and it was applied successfully. When I do a get API list (tyk/apis) it is showing there also.

For some reason I deleted the gateway pod (I had only 1 pod running) and a new pod was created. In the new pod all the old APIs were also deleted since those are maintained in the pod file system (/opt/tyk-gateway/apps/).

But those APIs were showing when I run below command -

kubectl get tykapis -n tyk

When I try to reapply these existing APIs through operator it shows unchanged -

apidefinition.tyk.tyk.io/httpbin-ingress-template unchanged
ingress.networking.k8s.io/httpbin-ingress unchanged

When I try to delete these and reapply like below, it is applied successfully -

kubectl delete -f Ingress-ApiDefinition.yaml -n tyk
apidefinition.tyk.tyk.io “httpbin-ingress-template” deleted
ingress.networking.k8s.io “httpbin-ingress” deleted

kubectl apply -f Ingress-ApiDefinition.yaml -n tyk
apidefinition.tyk.tyk.io/httpbin-ingress-template created
ingress.networking.k8s.io/httpbin-ingress created

But when I do a get API list (tyk/apis) these does not come in response. Below are the gateway logs when I reapply it -

time=“Apr 15 12:29:06” level=debug msg=“Primary instance set, I am master” prefix=host-check-mgr
time=“Apr 15 12:29:06” level=debug msg=“Deleting API definition for: dHlrL3R5ay1odHRwYmluLWluZ3Jlc3MtZGNmMGFiOWVk”
time=“Apr 15 12:29:06” level=warning msg=“File does not exist! stat /opt/tyk-gateway/apps/dHlrL3R5ay1odHRwYmluLWluZ3Jlc3MtZGNmMGFiOWVk.json: no such file or directory”
time=“Apr 15 12:29:16” level=debug msg=“Primary instance set, I am master” prefix=host-check-mgr

How can we reapply the ApiDefinition and Ingress once gateway pod is recreated.

with the open source gateway, just restart the operator pod & it should recreate everything for you.

You could also set up a persistent volume so thatthe gateway will load the last saved state on startup.

1 Like