Tips Flashcards
Set an alias for ‘kubectl’
alias k=kubectl
Generate a declarative configuration file for a pod using an imperative command
kubectl run p1 –image=nginx –restart=Never –dry-run=client -o yaml > p1.yaml
Generate a declarative configuration file for a deployment using an imperative command
k run d1 –image=nginx –dry-run -o yaml > d1.yaml
Generate a declarative configuration file for a job using an imperative command
kubectl run j1 –image=nginx –restart=OnFailure –dry-run=client -o yaml > j1.yaml
Generate a declarative configuration file for a cronjob using an imperative command
kubectl run cj1 –image=nginx –restart=OnFailure –schedule=”*/1 * * * *” –dry-run=client -o yaml > cj1.yaml
Shortcut (alias) for configmaps?
cm
Shortcut (alias) for namespaces?
ns
Shortcut (alias) for nodes?
nodes
(trick question, there is no shortcut)
Shortcut (alias) for persistent volume claims?
pvc
Shortcut (alias) for persistent volumes?
pv
Shortcut (alias) for pods?
po
Shortcut (alias) for statefulsets?
sts
Shortcut (alias) for resource quotas?
quota
Shortcut (alias) for service accounts?
sa
Shortcut (alias) for services?
svc
Shortcut (alias) for deployments?
deploy
Shortcut (alias) for replica sets?
rs
Shortcut (alias) for cronjobs?
cj
Shortcut (alias) for jobs?
jobs
(trick question, there is no alias!)
Shortcut (alias) for ingresses?
ing
Shortcut (alias) for storage classes?
sc
Shortcut (alias) for network policies?
netpol
bash alias for setting namespace for current context
alias kn=’kubectl config set-context –current –namespace ‘
create a vim configuration for two spaces when tab key is pressed
vim ~/.vimrc
set tabstop=2
set expandtab
Provide a pod within the cluster from which to shell into to curl other pods
kubectl run -it --rm curl --image=radial/busyboxplus:curl --restart=Never
What is the shortcut imperative command for getting all pods in all namespaces?
k get po -A
Imperative command to get the logs of a previous instance of a pod?
(e.g. for a pod named po1)
kubectl logs po1 -p