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.

  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:              # filters and predicates including custom extensions            # API gateway
org.springframework.http.server.reactive.    # HTTP server interactions
org.springframework.web.reactive             # API gateway reactive flows
org.springframework.boot.autoconfigure.web.  # API gateway autoconfiguration             # Authentication & Authorization information
reactor.netty                                # Reactor Netty

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

You can also configure a gateway instance with specific logging levels using the spec.env property:

apiVersion: ""
kind: SpringCloudGateway
  name: gateway-demo
    - name:
      value: debug

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       2021-02-17T11:52:09Z   2021-02-17T11:28:12Z              2021-02-17T11:28:12Z

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

$ kubectl delete crd
$ kubectl delete crd
$ kubectl delete crd

Failing to pull images

When running the installation script ./scripts/ and you see errors pulling an image:

Events from from installation namespace:
LAST SEEN   TYPE      REASON              OBJECT                              MESSAGE
2m          Normal    Scheduled           pod/scg-operator-7c6b749b9-hbrkx    Successfully assigned spring-cloud-gateway/scg-operator-7c6b749b9-hbrkx to kind-control-plane
36s         Normal    Pulling             pod/scg-operator-7c6b749b9-hbrkx    Pulling image "my.registry/scg-operator:1.0.1"
2m          Normal    SuccessfulCreate    replicaset/scg-operator-7c6b749b9   Created pod: scg-operator-7c6b749b9-hbrkx
2m          Normal    ScalingReplicaSet   deployment/scg-operator             Scaled up replica set scg-operator-7c6b749b9 to 1
36s         Warning   Failed              pod/scg-operator-7c6b749b9-hbrkx    Failed to pull image "my.registry/scg-operator:1.0.1": rpc error: code = Unknown desc = failed to pull and unpack image "my.registry/scg-operator:1.0.1": failed to resolve reference "my.registry/scg-operator:1.0.1": unexpected status code [manifests 1.0.1]: 401 Unauthorized
36s         Warning   Failed              pod/scg-operator-7c6b749b9-hbrkx    Error: ErrImagePull
12s         Normal    BackOff             pod/scg-operator-7c6b749b9-hbrkx    Back-off pulling image "my.registry/scg-operator:1.0.1"
12s         Warning   Failed              pod/scg-operator-7c6b749b9-hbrkx    Error: ImagePullBackOff
Error installing Spring Cloud Gateway operator

Check to make sure you created an image pull secret (with default name spring-cloud-gateway-image-pull-secret) to your registry. See the Installation page for a step-by-step guide.

check-circle-line exclamation-circle-line close-line
Scroll to top icon