Skip to content

Instantly share code, notes, and snippets.

@lemonteaa
Last active August 8, 2022 19:43
Show Gist options
  • Save lemonteaa/0b2300c67427fecd2dddd0fd54c7c96e to your computer and use it in GitHub Desktop.
Save lemonteaa/0b2300c67427fecd2dddd0fd54c7c96e to your computer and use it in GitHub Desktop.
kubectl cheatsheet

Kubectl cheatsheet

Just some quick n dirty stuff. (May move this note to main repo later)

Sometimes you just want to quickily spin up something in k8s, and writing all those elaborate yaml file is just too much friction. You can do a lots just from kubectl though:

kubectl create deployment <deployment name> --image=yourorg/imagename:ver

Then expose it:

kubectl create service <deployment name> --target-port=8080 --port=8080 --name=<svc name>

Okteto specific:

kubectl annotate service <svc name> "dev.okteto.com/auto-ingress=true"

If you want, you can then "extract" the "transcript" of yaml actually deployed. Just add -o yaml to the usual get statements. Example:

kubectl get deployments <name> -o yaml

It will be quite verbose as it also add some runtime state value in it. Therefore you should clean it up before saving as a template for reuse.

(Note: describe is something else)

Unrelated notes

https://dylancastillo.co/how-to-use-github-deploy-keys/ How to Use GitHub Deploy Keys

$ touch ~/.ssh/config 
$ chmod 600 ~/.ssh/config 
$ vim ~/.ssh/config # Or: nano ~/.ssh/config 
Host github-YOUR-APP 
  HostName github.com 
  AddKeysToAgent yes 
  PreferredAuthentications publickey 
  IdentityFile ~/.ssh/id_ed25519

Even more unrelated

You can install just the Postgresql client and not the server:

sudo apt-get install -y postgresql-client

Sadly, for the official way to install Rust, seems their website is not completely reliable. Fallback to using debian/ubuntu's package:

sudo apt-get install cargo

(Cargo is the package manager for Rust, and installing it will also install rustc etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment