Kubernetes fundamentals (k8s)¶
Kubernetes (k8s) is an open-source system used for automating deployment, scaling, and management of containerized applications.^[400-devops-06-kubernetes-k8s.md]
Core Concepts¶
To organize and manage applications, Kubernetes utilizes several key abstractions and resources:
- Namespaces: These are used to divide cluster resources between multiple users or teams. Commands like
kubectl get pods -n testallow for viewing resources within a specific namespace.^[400-devops-06-kubernetes-k8s.md] - Services: An abstraction which defines a logical set of Pods and a policy by which to access them. Services can be exposed via different types:
- ClusterIP: Exposes the service on an internal IP in the cluster.
- NodePort: Exposes the service on each Node’s IP at a static port.
- LoadBalancer: Exposes the service externally using a cloud provider's load balancer.^[400-devops-06-kubernetes-k8s.md]
- Storage: Persistent storage is managed through PersistentVolumeClaims (PVC), which requests specific storage resources from the cluster.^[400-devops-06-kubernetes-k8s.md]
Common Operations¶
Interaction with the cluster is primarily performed via the command-line tool kubectl.
Configuration¶
Configuration management is handled via kubectl config, which utilizes a configuration file (typically located at ${HOME}/.kube/config) to manage cluster access and connection details.^[400-devops-06-kubernetes-k8s.md]
Contexts¶
Contexts allow switching between different clusters or namespaces. Common commands include:
* kubectl config current-context: Displays the current context.
* kubectl config get-contexts: Lists available contexts.
* kubectl config use-context <name>: Switches to the specified context.^[400-devops-06-kubernetes-k8s.md]
Inspection and Management¶
The following commands are frequently used to inspect and manage the state of resources:
* kubectl get <resource>: Lists resources (e.g., pods, deployments, services).^[400-devops-06-kubernetes-k8s.md]
* kubectl describe <resource> <name>: Provides detailed status and information about a specific resource.^[400-devops-06-kubernetes-k8s.md]
* kubectl port-forward: Maps a local port to a port on a Pod (e.g., kubectl port-forward <pod-name> 3306:3306).^[400-devops-06-kubernetes-k8s.md]
Networking and Ingress¶
While Services manage internal networking, Ingress manages external access to the services, typically via HTTP/HTTPS. Common implementations include: * Ingress NGINX: A popular Ingress Controller for Kubernetes.^[400-devops-06-kubernetes-k8s.md] * Helm NGINX Ingress: Installation of the NGINX Ingress Controller via Helm charts.^[400-devops-06-kubernetes-k8s.md]
Tooling Ecosystem¶
Kubernetes functions as part of a broader ecosystem of DevOps tools:
- Local Development: Minikube is often used to run a local Kubernetes cluster.^[400-devops-06-kubernetes-k8s.md]
- Deployment & CI/CD:
- Skaffold: A tool for facilitating continuous development for Kubernetes applications.^[400-devops-06-kubernetes-k8s.md]
- ArgoCD: A GitOps continuous delivery tool that automatically syncs Kubernetes YAML files from a Git repository.^[400-devops-06-kubernetes-k8s.md]
- Observability & Management:
- Prometheus: Used for monitoring cluster Metrics, utilizing labels like
release: prometheus.^[400-devops-06-kubernetes-k8s.md] - Kiali: Provides a visualization of the Service mesh, relying on labels such as
app: xxxxx.^[400-devops-06-kubernetes-k8s.md] - Istio: A Service mesh that extends Kubernetes to manage traffic flows and enforce policies.^[400-devops-06-kubernetes-k8s.md]
- EFK Stack: Utilizes Fluent-Bit for log aggregation.^[400-devops-06-kubernetes-k8s.md]
- Dashboard: The official Kubernetes web-based UI for managing the cluster.^[400-devops-06-kubernetes-k8s.md]
- Prometheus: Used for monitoring cluster Metrics, utilizing labels like
- Image Management:
- Buildah & Kaniko: Tools for building container images (OCI).^[400-devops-06-kubernetes-k8s.md]
- Skopeo: A command-line utility for working with remote image registries (e.g.,
skopeo copy).^[400-devops-06-kubernetes-k8s.md]
- Configuration & Infrastructure:
- Kustomize: A tool for managing customized Kubernetes YAML configurations through patching and overlays.^[400-devops-06-kubernetes-k8s.md]
- Pulumi: Infrastructure as Code (IaC) tool.^[400-devops-06-kubernetes-k8s.md]
Sources¶
^[400-devops-06-kubernetes-k8s.md]