Skip to content

Instantly share code, notes, and snippets.

@GuillaumeFalourd
Created December 26, 2024 13:11
Show Gist options
  • Select an option

  • Save GuillaumeFalourd/c10c871e67dd93eae35797b336a5046d to your computer and use it in GitHub Desktop.

Select an option

Save GuillaumeFalourd/c10c871e67dd93eae35797b336a5046d to your computer and use it in GitHub Desktop.
Kubernetes concepts

Kubernetes Concepts

  1. Pod: A pod is the smallest deployable unit in Kubernetes, encapsulating one or more containers that share storage, network, and specifications. Pods ensure co-located containers work together as a single application.

  2. Node: A node is a physical or virtual machine in a Kubernetes cluster. It runs pods and includes essential components like kubelet, kube-proxy, and a container runtime to manage workloads.

  3. Service: A service provides a stable network endpoint to expose a set of pods. It enables communication between components or external clients, abstracting dynamic pod IPs with consistent DNS or IP.

  4. ConfigMap: A ConfigMap stores non-sensitive configuration data as key-value pairs. It decouples configuration from application code, allowing pods to consume settings dynamically via environment variables, command-line arguments, or mounted volumes.

  5. Namespace: A namespace is a logical partition within a Kubernetes cluster. It isolates resources like pods, services, and ConfigMaps, enabling multi-tenancy, resource organization, and access control for different teams or projects.

Useful K8s CLI command lines

  1. kubectl get pods

Lists all pods in the current namespace or a specified namespace.

  1. kubectl get nodes

Displays the status and details of all nodes in the cluster.

  1. kubectl describe pod <pod-name>

Provides detailed information about a specific pod, including events and resource usage.

  1. kubectl logs <pod-name>

Fetches the logs of a specific pod to debug or monitor its output.

  1. kubectl exec -it <pod-name> -- /bin/bash

Opens an interactive shell session inside a running pod for troubleshooting.

  1. kubectl apply -f <file.yaml>

Creates or updates resources in the cluster using a YAML configuration file.

  1. kubectl delete -f <file.yaml>

Deletes resources defined in a YAML configuration file from the cluster.

  1. kubectl scale deployment <deployment-name> --replicas=<number>

Adjusts the number of replicas for a deployment to scale up or down.

  1. kubectl rollout status deployment <deployment-name>

Monitors the status of a deployment rollout to ensure it completes successfully.

  1. kubectl get services

Lists all services in the current namespace or a specified namespace.

  1. kubectl port-forward <pod-name> <local-port>:<pod-port>

Forwards a local port to a port on a pod for accessing services locally.

  1. kubectl get configmaps

Lists all ConfigMaps in the current namespace, which store configuration data.

  1. kubectl get secrets

Lists all secrets in the current namespace, which store sensitive data like passwords.

  1. kubectl top pods

Displays resource usage (CPU and memory) of pods in the cluster.

  1. kubectl create namespace <namespace-name>

Creates a new namespace to logically isolate resources within the cluster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment