Link Search Menu Expand Document

Helpful kubectl commands

Last modified on 26-Jan-23

The Soda Agent is a Helm chart that you deploy on a Kubernetes cluster and connect to your Soda Cloud account using API keys.

Kubectl is the command-line tool you use to run commands against Kubernetes clusters. To deploy a Soda Agent in a cluster, you must have installed v1.22 or v1.23 of kubectl.

Commands

  • Run kubectl version --output=yaml to check the version of an existing install.

  • Use get pods to retrieve a list of the pods running in your cluster, including some information about each. The Soda Orchestrator creates pods when it creates Jobs and CronJobs.
    kubectl get pods
    

    Example output:

    NAME                                       READY   STATUS             RESTARTS   AGE
    nybusbreakdowns                            1/1     Running            0          10m
    sa-job-3637cccd-bvp6p                      0/1     ImagePullBackOff   0          6m2s
    soda-agent-orchestrator-5cd47d77b4-7c2jn   1/1     Running            0          42m
    


  • Use describe pods to examine details about the pods running in your cluster.
    kubectl describe pods
    

    Example output:

    Name:         nybusbreakdowns
    Namespace:    soda-agent
    Priority:     0
    Node:         minikube/192.168.**.**
    Start Time:   Thu, 17 Nov 2022 16:53:54 -0800
    Labels:       app=nybusbreakdowns
    Annotations:  <none>
    Status:       Running
    IP:           172.17.**.**
    ...
    


  • Use logs to examine details of pod activity. Run kubectl logs -h for a full list of options to use with the logs command.
    For example, the following command specifies a label (-l) to reveal the activity during set up of the practice pod of nybusbreakdown data.
    kubectl logs -l app=nybusbreakdowns --all-containers=true
    

    Example output:

    server stopped
    PostgreSQL init process complete; ready for start up.
    2022-11-21 21:44:49.438 UTC [1] LOG:  starting PostgreSQL 14.3 (Debian 14.3-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
    2022-11-21 21:44:49.438 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
    2022-11-21 21:44:49.438 UTC [1] LOG:  listening on IPv6 address "::", port 5432
    2022-11-21 21:44:49.442 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
    2022-11-21 21:44:49.448 UTC [65] LOG:  database system was shut down at 2022-11-21 21:44:49 UTC
    2022-11-21 21:44:49.453 UTC [1] LOG:  database system is ready to accept connections
    


  • Use get pods to get a list of pods running in the Soda Agent’s namespace.
    kubectl get pods --namespace soda-agent
    

    Example output:

    soda-agent-orchestrator-5975ddcd9-5b5qr                         2/2     Running     0          4h6m
    


  • Use get pods to retrieve the name of the Orchestrator issuing the command.
    kubectl get pods --no-headers -o custom-columns=":metadata.name" \
    -l agent.soda.io/component=orchestrator --namespace soda-agent
    

    Example output:

    soda-agent-orchestrator-fsnip-5g7tl
    


  • Use logs to get and tail the logs from the Soda Agent Orchestrator’s pod.
    kubectl logs pods/soda-agent-orchestrator-5snip-5b5qr \
    --namespace soda-agent -f
    

    Example output:

    2022-11-22 00:29:53,128 - __main__ - INFO - <module> - Running Soda Orchestrator for agent james-bond
    2022-11-22 00:29:53,164 - agent_id_fetcher - INFO - agent_id - Retrieved agent id from secrets: ''
    2022-11-22 00:29:53,617 - soda_server_client - INFO - _execute_request - Cloud response: 200 {
    "token": "q6SV***Q",
    "organisationId": "20ab1338-e1d5-***",
    "organisations": [
      {
        "id": "20ab1338-e1d5-***",
        "name": "Soda",
        "created": "2021-09-08T23:01:46Z",
    ...
    


    Alternatively, you can use the following command to retrieve the Orchestrator’s or Scan Launcher’s logs using a label.

    kubectl logs -l agent.soda.io/component=orchestrator -n soda-agent
    
    kubectl logs -l agent.soda.io/component=scanlauncher -n soda-agent
    


Go further


Was this documentation helpful?

What could we do to improve this page?


Last modified on 26-Jan-23