Kubernetes
Notes relating to Kubernetes!
Kubernetes
Tools
Super useful for easily switching contexts and namespaces
Great for live tailing logs from multiple pods/containers
Shows some nice Kubernetes output in the CLI
The ct
command is great for testing Helm charts
Commands
Get pods
kubectl get po
Create Service Account
ClusterRoleBinding
Rollout Restart
kubectl rollout restart -n $namespace deployment/$deployment-name
Running a one-off command against a pod
The below runs env
within the pod without having the directly exec into it
kubectl exec -it my-pod-name -- env
Tail logs
Use stern for this!
Init Containers
To view logs from the init container, use the -c
flag
kubectl logs <pod-name> -c <init-container>
Resources
Used to create Secret
resources without needing to store credentials in source control!
AWS system manager (Parameter )
Basic Setup
apiVersion: "kubernetes-client.io/v1"
kind: ExternalSecret
metadata:
name: hello-service
spec:
backendType: systemManager
data:
- name: password
key: /hello-service/password
Namespaces
Deleting namespaces
Namespaces can often get stuck in a Terminating
process despite being completely empty
To fully delete the namespace, run the following
NAMESPACE=linkerd
kubectl get namespace $NAMESPACE -o json > $NAMESPACE.json
sed -i -e 's/"kubernetes"//' $NAMESPACE.json
kubectl replace --raw "/api/v1/namespaces/$NAMESPACE/finalize" -f ./$NAMESPACE.json
Last updated