Hello
Wondering if there is a single simple document / cheat sheet of kubectl commands a typical SAS Viya Administrator needs on a day to day basis.
Expect it to include starting/stopping of services, applying license , viewing /querying logs for keywords etc.
Something with a 'labyrinth' of cross references or scholarly master piece that overwhelms a beginner is not in my mind.
Thanks.
This is by no means a complete list, but they have helped me understand a few things.
See Managing a Specific Server or Service for details on restart/stop/start (always make sure to choose the proper version).
General
Some commands use various options some are explained here:
Set default namespace
To avoid always using “kubectl -n edu” one can set the default namespace to be used when no namespace is given. However it might be beneficial to always specify the namespace for clarity.
kubectl config set-context --current --namespace=edu
get all pods running a compute server
Will list all pods that are compute server, for instance SAS Studio launched compute servers or others like launched by the SAS extension of the VSCode or however.
kubectl -n edu get pods -l "launcher.sas.com/job-type=compute-server" -L "launcher.sas.com/username"
get all pods running either as compute server or batch server
List pods that were started by the sas-launcher
kubectl -n edu get pod -l sas.com/created-by=sas-launcher -L "launcher.sas.com/job-type,launcher.sas.com/username"
get events
Helpful to explain what is happening when starting SAS Studio or run a SAS program in batch. Depending on how the prepull is set there might be too much noise from the prepull pods.
You can switch off the prepull using this command:
kubectl patch $(kubectl get cm -n edu --selector="app.kubernetes.io/name=sas-prepull" -o=name) -n edu --type merge -p '{"data":{"SAS_PREPULL_CRCRB_INT":"86400", "SAS_PREPULL_DAEMON_INT":"86400"}}'
kubectl -n edu get events -o custom-columns=LastSeen:.lastTimestamp,From:.source.component,Type:.type,Reason:.reason,Message:.message
get pvc related to backup
Get a list of persistent volume claims that have to do with backup
kubectl -n edu get pvc -l "sas.com/backup-role=storage"
get details on a volume
This will display the actual physical directory name of a volume. For the <volume> use the volume name from the previous example
kubectl describe pv <volume>
get pvc related to CAS
Get a list of pvc’s related to the CAS server
kubectl -n edu get pvc -l 'app.kubernetes.io/part-of=cas'
get information on backups
Get a list of backup jobs that run or are running. The duration column indicates the time it took for the backup.
kubectl -n edu get jobs -l "sas.com/backup-job-type=scheduled-backup" -L "sas.com/sas-backup-id,sas.com/backup-job-type,sas.com/sas-backup-job-status"
get log info from readiness pod
Check the log of the sas readiness pod. During startup you can check the progress of the services, only two keys from the JSON are displayed.
kubectl -n edu logs -l app=sas-readiness --tail -1 -f | jq "{timeStamp, message}"
get log from a pod and only display some fields from json
This command will read certain “fields” from the json returned and display it as plain text line. The example displays the log of the default CAS server.
kubectl -n edu logs sas-cas-server-default-controller sas-cas-server | jq -R -r '. as $line | try (fromjson| "\(.timeStamp) \(.level) \(.properties.logger) \(.message)" ) catch $line'
This is by no means a complete list, but they have helped me understand a few things.
See Managing a Specific Server or Service for details on restart/stop/start (always make sure to choose the proper version).
General
Some commands use various options some are explained here:
Set default namespace
To avoid always using “kubectl -n edu” one can set the default namespace to be used when no namespace is given. However it might be beneficial to always specify the namespace for clarity.
kubectl config set-context --current --namespace=edu
get all pods running a compute server
Will list all pods that are compute server, for instance SAS Studio launched compute servers or others like launched by the SAS extension of the VSCode or however.
kubectl -n edu get pods -l "launcher.sas.com/job-type=compute-server" -L "launcher.sas.com/username"
get all pods running either as compute server or batch server
List pods that were started by the sas-launcher
kubectl -n edu get pod -l sas.com/created-by=sas-launcher -L "launcher.sas.com/job-type,launcher.sas.com/username"
get events
Helpful to explain what is happening when starting SAS Studio or run a SAS program in batch. Depending on how the prepull is set there might be too much noise from the prepull pods.
You can switch off the prepull using this command:
kubectl patch $(kubectl get cm -n edu --selector="app.kubernetes.io/name=sas-prepull" -o=name) -n edu --type merge -p '{"data":{"SAS_PREPULL_CRCRB_INT":"86400", "SAS_PREPULL_DAEMON_INT":"86400"}}'
kubectl -n edu get events -o custom-columns=LastSeen:.lastTimestamp,From:.source.component,Type:.type,Reason:.reason,Message:.message
get pvc related to backup
Get a list of persistent volume claims that have to do with backup
kubectl -n edu get pvc -l "sas.com/backup-role=storage"
get details on a volume
This will display the actual physical directory name of a volume. For the <volume> use the volume name from the previous example
kubectl describe pv <volume>
get pvc related to CAS
Get a list of pvc’s related to the CAS server
kubectl -n edu get pvc -l 'app.kubernetes.io/part-of=cas'
get information on backups
Get a list of backup jobs that run or are running. The duration column indicates the time it took for the backup.
kubectl -n edu get jobs -l "sas.com/backup-job-type=scheduled-backup" -L "sas.com/sas-backup-id,sas.com/backup-job-type,sas.com/sas-backup-job-status"
get log info from readiness pod
Check the log of the sas readiness pod. During startup you can check the progress of the services, only two keys from the JSON are displayed.
kubectl -n edu logs -l app=sas-readiness --tail -1 -f | jq "{timeStamp, message}"
get log from a pod and only display some fields from json
This command will read certain “fields” from the json returned and display it as plain text line. The example displays the log of the default CAS server.
kubectl -n edu logs sas-cas-server-default-controller sas-cas-server | jq -R -r '. as $line | try (fromjson| "\(.timeStamp) \(.level) \(.properties.logger) \(.message)" ) catch $line'
After few weeks, you will know all needed commands. You can install "k9s" binary (https://k9scli.io/). A "light linux interface" that generates all kubectl commands for you. You will navigate through an interface into your pods, jobs, sasdeployment (ALL k8s objects), ... and kill, check, edit yaml, ... do a LOT, and gain a lot of time.
Everything is done just by keyboard shortcuts.
Example of daily/weekly use :
- check pods, and sort them by status, namespace, consumption, nodes, ...
- kill a pod/job
- plan a job via cronjob
- edit a k8s object in "live" : change a replica, change a label
- check logs of a pod in "tail" mode
- describe and check events of a pod
...
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.