# Kubectl

## [Kubectl](https://kubernetes.io/docs/home/)

:thumbsup: [Cheatsheet](https://kubernetes.io/docs/reference/kubectl/cheatsheet/)

* `uses curl under the hood`
* **kubectl** \[command] --help
* kubectl api-versions
* **kubectl** get nodes
* **kubectl** get all
* :warning: `@Deprecated` **kubectl** run&#x20;
  * **kubectl** run ngnix-run --image=nginx

The context that **kubectl** uses is stored in `~/.kube/config` . (`kubectl config view` shows parts of current configuration).

* kubectl inspect -> etcs
* kubectl logs -> pod
* kubectl exec -it -> container

### Pod commands

* kubectl create -f podD*efinitionF*ile.yaml
* kubectl delete pods \[name]
* kubectl get pods \[pod\_name]
* kubectl get pods -o wide

### Deployment commands

`kubectl rollout status deployment nginx-deployment`

### ReplicaSet commands

`k get rs -o wide`

## Curl

You need kubectl proxy to use curl commands.\
`kubectl proxy --port=8001 &`&#x20;

Proxy takes care of TLS connection => you can use `http` .

## Authentication/Authorization

* kubectl config specifies to which cluster to authenticate
* authorization is what this users can do
  * behind is a RBAC
  * `kubectl auth can-i get prods` to find out what you can do

## Useful utilities

* brew install kubectx
* brew install kube-ps1
