Upgrading Your Cluster

One of the things I noticed while studying for my CKAD exam is that my test cluster was a bit behind. It’s been up and running for over 200 days at this point and I’m several versions behind. Version 1.17 is out, the exam was based on 1.16, and I’m running 1.13.

NAME                         STATUS   ROLES    AGE    VERSION
runlevl41c.mylabserver.com   Ready    master   207d   v1.13.5
runlevl42c.mylabserver.com   Ready    <none>   207d   v1.13.5
runlevl43c.mylabserver.com   Ready    <none>   207d   v1.13.5

Read More

Post to Twitter

Executing Commands Against a Pod

I recently responded to another user in a Slack channel regarding this topic and thought I’d post it here as well. The discussion revolved around when you need to use the -- command demarcation with the kubectl exec command.

As for the necessity or not of the — command, it depends on what you’re doing. If you’re not passing any arguments to the command, it’s not needed.

Let’s create a new pod based on busybox to test the theory: kubectl run bb --image=busybox --restart=Never --command -- sleep 3600

If we want to list the directories with ls, we can do it your way:

$ kubectl exec bb ls
bin
dev
etc
home
proc
root
sys
tmp
usr
var

Let’s say we want to know more about the contents so we try to do a long listing. This will generate an error.

$ kubectl exec bb ls -al
Error: unknown shorthand flag: 'a' in -al

However, if we include the --, the command and argument(s) are handled properly and we get the desired results.

$ kubectl exec bb -- ls -al
total 44
drwxr-xr-x    1 root     root          4096 Dec  8 21:17 .
drwxr-xr-x    1 root     root          4096 Dec  8 21:17 ..
-rwxr-xr-x    1 root     root             0 Dec  8 21:17 .dockerenv
drwxr-xr-x    2 root     root         12288 Dec  2 20:12 bin
drwxr-xr-x    5 root     root           360 Dec  8 21:17 dev
drwxr-xr-x    1 root     root          4096 Dec  8 21:17 etc
drwxr-xr-x    2 nobody   nogroup       4096 Dec  2 20:12 home
dr-xr-xr-x  238 root     root             0 Dec  8 21:17 proc
drwx------    2 root     root          4096 Dec  2 20:12 root
dr-xr-xr-x   13 root     root             0 Dec  8 21:16 sys
drwxrwxrwt    2 root     root          4096 Dec  2 20:12 tmp
drwxr-xr-x    3 root     root          4096 Dec  2 20:12 usr
drwxr-xr-x    1 root     root          4096 Dec  8 21:17 var

Hopefully this will clear up any confusion.

Post to Twitter