BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
thesasuser
Pyrite | Level 9

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.

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

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: 

  • Always specify the proper namespace using the “-n namespace” option 
  • The “-l” will select only pods with the given label. 
  • The “-L” names the labels that are printed as additional columns to the standard ones. 
  • Add “--show-labels=true” to list the labels associated for instance with a pod or pvc this will help with the previous two options mentioned 

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' 

 

 

View solution in original post

2 REPLIES 2
BrunoMueller
SAS Super FREQ

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: 

  • Always specify the proper namespace using the “-n namespace” option 
  • The “-l” will select only pods with the given label. 
  • The “-L” names the labels that are printed as additional columns to the standard ones. 
  • Add “--show-labels=true” to list the labels associated for instance with a pod or pvc this will help with the previous two options mentioned 

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' 

 

 

Vincent35
Obsidian | Level 7

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

...

 

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

Discussion stats
  • 2 replies
  • 610 views
  • 1 like
  • 3 in conversation