Wednesday, October 30, 2019

Useful DOS commands

From the 80s to 2020, I find myself living more and more in DOS, Windows, Powershell, Bash/Zsh, Kube and Cloud shells, and looking forward to leveraging the new Windows Terminal once my work laptop gets upgraded.

I appreciate the complexity and flexibility that Zsh has vs. DOS, and miss a lot of the features.

Sometimes though, there are some interesting tricks I forget about when using DOS/Windows/Powershell.

Grab the history to a file.  I always hit F7, and would appreciate having my session's file around for a basic command window.

doskey /HISTORY > history.txt
https://www.howtogeek.com/298163/how-to-use-your-command-history-in-the-windows-command-prompt/

Also see Start Transcript
https://4sysops.com/archives/powershell-transcript-record-a-session-to-a-text-file/

Pipe a python script's output and stderr output
python -m myscript.py &2>1

Teeing Objects
https://adamtheautomator.com/tee-object-powershell/

Ascii Doom
https://dario-zubovic.itch.io/1337-doom

Last one should be cross-platform!

Monday, October 28, 2019

Common Kubernetes Commands


The Kubernetes Client kubectl recently became an independent tool outside of the main Kubernetes repo.

Some common Kubernetes kubectl commands.

https://kubernetes.io/docs/reference/kubectl/overview/
https://github.com/kubernetes/kubectl/
https://kubernetes.io/docs/reference/kubectl/cheatsheet/

Get the current cluster / namespace context

kubectl config get-context

Use the specified cluster context
kubectl config use-context my-cluster-name

Which cluster am I on
kubectl cluster-info

Create my service/deployment/secret/configmap/replicationcontroller/pod/job
kubectl apply -f myyaml.yaml

Delete the applied object(s)
kubectl delete -f myyaml.yaml

Delete a pod
kubectl delete -n dev mydevpod

Get a list of pods for all namespaces
kubectl get pods -A

Get the logs for a pod
kubectl logs -n dev mydevpod-abcde

kubectl get internals
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/get/get.go

Copy files to a pod
kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir

Other commands
https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/cmd/cmd.go

get, describe, delete, label, edit, patch, annotate, expose, scale, autoscale, taint, rollout, logs, exec, rolling-update, cordon, config use-context, config delete-cluster, cp

kubectl get namespace
kubectl config get-context
kubectl config get-clusters
kubectl config get-users