---
# System prepended metadata

title: K8s

---

# K8s

update cluster config
```shell=
aws eks --region {{region}} update-kubeconfig --name {{cluster name}} --profile aria
```

change context看pod
```shell=
kubectl config use-context cream
```

apply k8s config
```shell=
aws eks --region ap-southeast-1 update-kubeconfig --name cream-dev
```

列出所有revision
```shell=
kubectl rollout history deployment/backend-eth
```

rollback上一版本
```shell=
kubectl rollout undo deployment backend-eth
```

rollback to指定版本
```shell=
kubectl rollout undo deployment backend-eth --to-revision=<revision>
```
k8s port forward
```shell=
kubectl port-forward backend-eth-7769dc5478-hpvcj 8000:3000
```

k8s decode secret 
```shell=
kubectl get secret SECRET_NAME -o json | jq '.data | map_values(@base64d)'
```

k8s delete secret
```shell=
kubectl delete secret coingecko-api-key
```

k8s create secret
```shell=
kubectl create secret generic coingecko-api-key --from-literal=api-key=xxxxx
```

k8s create secret with file
```shell=
kubectl create secret generic poster-key-v2 --from-file=privateKey.js
```

k8s 讓pod無法部署
```shell=
kubectl scale deploy my-awesome-deployment --replicas=0
```