Tag Archives: kubernetes
Docker and Kubernetes basics for developers
Docker Docker containers are much more lightweight compared to classic VMs as they leverage host OS instead of starting their own OS. Containers are using 2 features of Linux-based OS: Namespaces and Cgroups (Control Groups). Namespace Lets you allocate resources in an isolated environment (like a sandbox). On a container start, docker daemon generates a …
Using tcpdump for k8s pods
You need wireshark to be installed on your local machine — download (more on this below). If you don’t have tcpdump installed inside the pod, you can install it with # get pod name kubectl get po -Lversion,cfg,infra-cfg -lapp= kubectl exec -it sh # inside the pod, alpine apk add tcpdump Then, on your local …
Forward multiple kubernetes pods for local development
kubefwd is a great tool that can forward a lot of pods at once to your local machine. The only downside for me is that it touches your local `/etc/hosts`. That’s how I use it: sudo KUBECONFIG=<path to your k8s config> kubefwd svc -l «app in (first-api, second-api, third-service)» It does not have huge documentation, …
How to update your k8s pod limits
kubectl edit deployment ←name-of-your-app→ Then search for memory (for instance) and update request/limit for it. When you quit, it will be saved automatically for you.
Port forwarding with kubectl
If you want some kubernetes pod to forward all the traffic to you local machine, you can do this: 1. get pod id with kubectl —kubeconfig get po -lapp= -Lversion,cfg,infra-cfg 2. forward exact port from it to you localhost with kubectl —kubeconfig port-forward localhost_port:pod_port And you can request you localhost to reach pod on selected …
Kubernetes’ cronjobs
That’s what it is — https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ Get all cronjobs in env: kubectl —kubeconfig … —namespace platform -o wide get cronjobs Get info on exact cronjob: kubectl —kubeconfig … —namespace platform describe cronjob/smartrouting-cron-import-from-bi Get pods with this cronjob: kubectl —kubeconfig … —namespace platform -o wide get pods|grep «rou» Get logs of cronjob kubectl —kubeconfig … —namespace …
Kubectl helpful commands
k8s cheatsheet. Get all pods by label $ kubectl —kubeconfig <config file> get po -lapp=<pod name without hash> -Lversion,cfg,infra-cfg Exec into the pod $ kubectl —kubeconfig <config file> exec -it <pod name> sh Port forwarding $ kubectl —kubeconfig <config file> port-forward <pod name> <local port>:<remote port> Getting logs $ kubectl —kubeconfig <config file> logs <pod …