Subscribe Us

Kubernetes Tips and Tricks


Kubernetes  :: Helpful aliases to save time :

  • alias c='clear'
  • alias v='vim'
  • alias l='ls -lrt'

  • alias k='kubectl'
  • alias kdel='kubectl delete pod'
  • alias kdp='kubectl describe pod'
  • alias kf='kubectl create -f'
  • alias kp='kubectl apply -f'
  • alias ke='kubectl explain'
  • alias kgp='k get pod'
  • alias kr='kubectl replace -f'
  • alias kexe='kubectl exec -it'

  • alias ks='kubectl get namespaces'
  • alias kgaa='k get pod --all-namespaces'
  • alias kc='k config view --minify | grep name'
  • alias krh='kubectl run --help | more'
  • alias kgh='kubectl get --help | more'
  • alias kg='kubectl get pods --show-labels'
  • alias kh='kubectl --help | more'
  • alias krh='kubectl run --help | more'
  • alias kgaa='kubectl get all --show-labels'


Create YAML from kubectl commands :


The following commands will create a YAML file with name yamlfile. Once you create the YAML file from these kubectl commands, you can modify it based on your requirements and use it instead of writing from scratch:

  • kubectl run busybox --image=busybox --dry-run=client -o yaml --restart=Never > yamlfile.yaml
  • kubectl create job my-job --dry-run=client -o yaml --image=busybox -- date  > yamlfile.yaml
  • kubectl get -o yaml deploy/nginx > 1.yaml (Ensure that you have a deployment named as nginx)
  • kubectl run busybox --image=busybox --dry-run=client -o yaml --restart=Never -- /bin/sh -c "while true; do echo hello; echo hello again;done" > yamlfile.yaml
  • kubectl run wordpress --image=wordpress –-expose –-port=8989 --restart=Never -o yaml
  • kubectl run test --image=busybox --restart=Never --dry-run=client -o yaml -- bin/sh -c 'echo test;sleep 100' > yamlfile.yaml  (Notice that --bin comes at the end. This will create yaml file.)

Another good idea for creating the YAML file is obtaining the file directly from the internet using the wget command. 



Post a Comment

0 Comments