Kubernetes Intro – HackMD
# Kubernetes Intro
– Local Google cloud setup
– Tools
—
#### Setup
– Install google SDK:
cloud.google.com/sdk/docs/install
region -> (europe-west4-a)
– Install kubectl:
kubernetes.io/docs/tasks/tools/
—
– List available clusters in our account
“`
gcloud container clusters list
“`
– List our available contexts
“`
kubectl config get-contexts
“`
– Add one cluster to our available contexts
“`
gcloud container clusters get-credentials acceptance
“`
—
– Change context
“`
kubectl config use-context acceptance
“`
– List contexts
“`
kubectl config get-contexts -o=name
“`
– Tool to fancy navigate through contexts:
github.com/ahmetb/kubectx#kubectl-plugins-macos-and-linux
—
#### Namespace
– List namespaces
“`
kubectl get namespaces
“`
– Change namespace
“`
kubectl config set-context –current –namespace=equalture-8828728
“`
—
– Fancy namespaces navigation
“`
kubens
“`
“`
(I think it is installed with kubectx)
“`
—
—
#### kube-ps1
Allows to easily know in which cluster and namespace you are
“`
github.com/jonmosco/kube-ps1
“`
![](https://i.imgur.com/ibTV5PM.png)
—
#### Basic steps
“`
kubectl get pods
“`
“`
kubectl get services
“`
“`
kubectl get cronjobs
“`
—-
#### Check logs
“`
kubectl get pods
“`
“`
kubectl logs <pod-name>
“`
“`
kubectl logs -f <pod-name>
“`
—
#### k9s
“`
github.com/derailed/k9s
“`
![](https://i.imgur.com/uB0qoIB.png)
—
#### Check secrets
– All secrets file for current
“`
kubectl get secrets
“`
– Applying base64 decoding
“`
kubectl get secrets jerry-google-cloud-credentials -o json | jq ‘.data | map_values(@base64d)’
“`
– Edit secrets:
“`
kubectl edit secrets jerry-google-cloud-credentials
“`
—
#### Cluster debugging
“`
kubectl get events
“`
—
# End
![](https://media.giphy.com/media/3orifhw6nbyAzOx0pW/giphy.gif)
Read more here: Source link