Troubleshooting Spring Cloud Gateway for Kubernetes

This topic describes how to troubleshoot Spring Cloud Gateway for Kubernetes operator and instances.

Check the status of Gateway

You can check the current status of your gateway by running

$ kubectl get scg my-gateway
NAME               READY   REASON
my-gateway         True    Created

Get scg-operator and Gateway events

In case of errors events are published for the Operator and the Gateway components (mappings and routes as well), you can display them using the describe option.

$ kubectl describe scg my-gateway
$ kubectl describe scgm my-gateway-mapping
$ kubectl describe scgrc my-gateway-route-config

For example, in case some routes are not present, using kubectl describe scgm may show the referenced gateway is not present. Creating such Gateway instance would fix the issue.

Events:
  Type     Reason    Age        From                          Message
  ----     ------    ----       ----                          -------
  Warning  NotFound  <unknown>  SpringCloudGatewayController  Specified SpringCloudGateway resource "demo-gateway" is not found / not ready

Configure Gateway’s logging levels

The following loggers may contain valuable troubleshooting information at the DEBUG and TRACE levels:

org.springframework.cloud.gateway
org.springframework.http.server.reactive
org.springframework.web.reactive
org.springframework.boot.autoconfigure.web
reactor.netty
redisratelimiter

You can set a specific logger’s logging level for a gateway statefulset by running the following command, which will automatically update the underlying pod.

$ kubectl set env statefulset.apps/my-gateway logging_level_org_springframework_cloud_gateway=TRACE

Check scg-operator or Gateway logs

You can access the scg-operator or your Gateway logs by running

$ kubectl logs deployment.apps/scg-operator -n spring-cloud-gateway
$ kubectl logs statefulset.apps/my-gateway

Resolve unresponsive scg-operator

If you find that scg-operator won’t fully start or respond, and none of the above techniques help point out the problem, you could try increasing the requested CPU resource by 100m by running

$ kubectl edit deployment.apps/scg-operator

Alternatively, you can restart the deployment by running

$ kubectl rollout restart deployment.apps/scg-operator

Restart Gateway

In case of some errors, a restart might help solve the issue. You can restart your Gateway by running

$ kubectl rollout restart statefulset.apps/my-gateway

Manually delete Custom Resource Definitions

If there are problems while uninstalling, sometimes the Custom Resource Definitions don’t get deleted. After uninstalling, you can check if there are any of the Spring Cloud Gateway Custom Resource Definitions by running

$ kubectl get crds
NAME                                              CREATED AT
springcloudgatewaymappings.tanzu.vmware.com       2021-02-17T11:52:09Z
springcloudgatewayrouteconfigs.tanzu.vmware.com   2021-02-17T11:28:12Z
springcloudgateways.tanzu.vmware.com              2021-02-17T11:28:12Z

If any of these three appear, you can manually delete them by running

$ kubectl delete crd springcloudgatewaymappings.tanzu.vmware.com
$ kubectl delete crd springcloudgatewayrouteconfigs.tanzu.vmware.com
$ kubectl delete crd springcloudgateways.tanzu.vmware.com