cheatsheet-kubernetes
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cheatsheet-kubernetes [2025/10/26 19:59] – sjoerd | cheatsheet-kubernetes [2026/02/08 14:49] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 4: | Line 4: | ||
| **Date**: 15 December 2024 \\ | **Date**: 15 December 2024 \\ | ||
| {{tag> | {{tag> | ||
| + | |||
| + | == Terminology == | ||
| + | |||
| + | **Pods**\\ | ||
| + | Basic scheduling unit that holds one or more containers. | ||
| + | |||
| + | **Nodes**\\ | ||
| + | Machines (physical or virtual) in the cluster where pods are scheduled. | ||
| + | |||
| + | **Cluster**\\ | ||
| + | Collection of nodes and associated resources. | ||
| + | |||
| + | **Kubelet**\\ | ||
| + | An agent running on each node, responsible for managing the node and its containers. | ||
| + | |||
| + | **Kubernetes Controller Manager**\\ | ||
| + | Manages controllers to regulate the state of the system. | ||
| + | |||
| + | **Kube Proxy**\\ | ||
| + | Maintains network rules to allow communication between pods and external traffic. | ||
| + | |||
| + | **etcd**\\ | ||
| + | Consistent and highly-available key-value store used for all cluster data. | ||
| + | |||
| + | **API Server**\\ | ||
| + | Serves the Kubernetes API and is the primary entry point for administrative tasks. | ||
| + | |||
| + | **Scheduler**\\ | ||
| + | Assigns pods to nodes based on resource requirements and other constraints. | ||
| + | |||
| + | **Controller**\\ | ||
| + | Maintains the desired state of the system, such as ensuring the correct number of replicas for a particular application. | ||
| + | |||
| + | **Service**\\ | ||
| + | Provides a consistent way to access a set of pods. | ||
| + | |||
| + | **Namespace**\\ | ||
| + | A way to divide cluster resources between multiple users. | ||
| + | |||
| + | **Volumes**\\ | ||
| + | Kubernetes supports various types of storage volumes, providing data persistence for pods. | ||
| + | |||
| + | **Secrets and ConfigMaps**\\ | ||
| + | Mechanisms to manage sensitive information and configuration data separately from application code. | ||
| + | |||
| + | **Deployment**\\ | ||
| + | A higher-level resource that manages updates to applications by handling the deployment and scaling of pods. | ||
| + | |||
| + | **StatefulSets**\\ | ||
| + | Manages stateful applications, | ||
| + | |||
| + | **DaemonSets**\\ | ||
| + | Ensures that specific pods run on all (or specific) nodes for cluster-wide tasks like logging or monitoring. | ||
| + | |||
| + | **Jobs and CronJobs**\\ | ||
| + | Run short-lived or scheduled tasks within the cluster. | ||
| + | |||
| + | **Ingress**\\ | ||
| + | Manages external access to services, typically HTTP. | ||
| + | |||
| + | **Network Policies**\\ | ||
| + | Define how groups of pods can communicate with each other and other network endpoints. | ||
| + | |||
| + | **Horizontal Pod Autoscaler**\\ | ||
| + | Automatically adjusts the number of replica pods to handle varying load. | ||
| + | |||
| + | **Vertical Pod Autoscaler**\\ | ||
| + | Adjusts the resources allocated to individual pods based on their usage. | ||
| + | |||
| + | **Operators**\\ | ||
| + | A way to package, deploy, and manage applications using Kubernetes APIs and controllers. | ||
| + | |||
| + | **Kubectl**\\ | ||
| + | The command-line interface to interact with Kubernetes clusters. | ||
| == Kubectl == | == Kubectl == | ||
| Line 79: | Line 153: | ||
| # Start the debug command to connect to the node using an image from a private container registry | # Start the debug command to connect to the node using an image from a private container registry | ||
| kubectl debug node/ | kubectl debug node/ | ||
| - | >/code> | + | </code> |
| ==== Resources ==== | ==== Resources ==== | ||
| Line 181: | Line 255: | ||
| </ | </ | ||
| \\ | \\ | ||
| + | > Restart all deployments in a namespace | ||
| + | <code bash> | ||
| + | kubectl rollout restart deployment -n shared | ||
| + | </ | ||
| > Apply a manifest | > Apply a manifest | ||
| <code bash> | <code bash> | ||
| Line 227: | Line 305: | ||
| <code bash> | <code bash> | ||
| kubectl scale statefulset myapp1 --replicas=0 | kubectl scale statefulset myapp1 --replicas=0 | ||
| + | </ | ||
| + | \\ | ||
| + | > Restart a statefulset | ||
| + | <code bash> | ||
| + | kubectl rollout restart statefulset/ | ||
| + | </ | ||
| + | \\ | ||
| + | > Restart all statefulsets in a namespace | ||
| + | <code bash> | ||
| + | kubectl rollout restart statefulset -n shared | ||
| </ | </ | ||
| Line 300: | Line 388: | ||
| grafana cli admin reset-admin-password < | grafana cli admin reset-admin-password < | ||
| </ | </ | ||
| - | \\ Check for kafka topics | + | \\ |
| + | > Check for kafka topics | ||
| <code bash> | <code bash> | ||
| # open a terminal on one of the kafka brokers (eg kafka-kafka-0) | # open a terminal on one of the kafka brokers (eg kafka-kafka-0) | ||
| ./ | ./ | ||
| </ | </ | ||
| - | \\ Get all resource kinds with their name from a manifest: | + | \\ |
| + | > Get all resource kinds with their name from a manifest: | ||
| <code bash> | <code bash> | ||
| cat opentelemetry-operator.yaml | grep -i ' | cat opentelemetry-operator.yaml | grep -i ' | ||
| + | </ | ||
| + | |||
| + | == Loop commands with kubectl == | ||
| + | |||
| + | Here are some examples I use to perform actions on multiple resources at once. | ||
| + | |||
| + | > Remove all finalizers for kafka topics | ||
| + | <code bash> | ||
| + | kubectl get kafkatopic.kafka.strimzi.io -n shared -o name | | ||
| + | while read topic; do | ||
| + | echo " | ||
| + | kubectl patch $topic -n shared -p ' | ||
| + | done | ||
| + | </ | ||
| + | \\ | ||
| + | > Delete all jobs that start with " | ||
| + | <code bash> | ||
| + | export NAMESPACE=shared | ||
| + | kubectl get jobs -n $NAMESPACE -o name | grep backup- | | ||
| + | while read job; do | ||
| + | echo " | ||
| + | kubectl delete $job -n $NAMESPACE | ||
| + | done | ||
| </ | </ | ||
| Line 386: | Line 499: | ||
| </ | </ | ||
| </ | </ | ||
| - | |||
| - | |||
cheatsheet-kubernetes.1761508753.txt.gz · Last modified: by sjoerd
