How to view the logs of your microservices
In a lot of cases a developer will need to look at the logs of a service to monitor health status, trace a bug or evaluate performance. This section walks you through how can you check the logging of a microservice deployed to Skygear be retrieved.
Have a Skygear account and an app registered. We will be using Secret on Skygear, which is a resource designed to hold sensitive information, registered under and can used by a Skygear app. The latter part of this definition means you will need an app before you can add Secrets.
Before you start this section, please ensure you have
skycliinstalled and configured properly.
Although this section doesn't really require
skyclias we will be adding database connection via Secrets which can be done with Skygear Portal, to try out the newly connected database you will still need an app deployed and
skycliis the only way to perform that.
Also, make sure the version of your
kubectlis >= 1.15.
TL;DR Sooner or later you will need to install and configure
While you can access logs with
kubectlby entering bunch of commands, commands from
skyclihave some of the details and operations abstracted.
This writes the context of your Skygear cluster to your local k8s configuration file:
$ skycli --app <your_app_name> app get-k8s-credentials
# The necessary configuration was written to KUBECONFIG.
# Follow the instruction in the output to
# switch kubectl context if you wish.
Then you can verify the configuration was correctly set by
$ kubectl config view
current-contextof kubectl isn't that of your Skygear cluster, you can set it with:
$ kubectl config use-context <skygear_context_name>
Now the set-up is done, you can list out your pods (i.e. the microservices):
$ kubectl get pod
Then put in the name of the microservice you would like its logs to be retrieved:
$ kubectl logs <your_target pod>