Kubernetes - Introduction, Architecture, and Basic Commands: Day 7 of 50 days DevOps Tools Series

shivam_agnihotri

Shivam Agnihotri

Posted on July 15, 2024

Kubernetes - Introduction, Architecture, and Basic Commands: Day 7 of 50 days DevOps Tools Series

Introduction

Kubernetes (often abbreviated as K8s) is an open-source platform designed to automate the deployment, scaling, and management of containerized applications. It has become the de facto standard for container orchestration in the industry, providing a robust and flexible framework for managing applications at scale.

Why Kubernetes is Important for DevOps?

Scalability: Automatically scale your applications up or down based on demand.
Self-Healing: Automatically replace failed containers and restart them.
Load Balancing: Distribute traffic evenly across your application instances.
Automated Rollouts and Rollbacks: Simplify application updates and rollbacks.
Secret and Configuration Management: Securely manage application configurations and secrets.

Kubernetes Architecture

Kubernetes architecture consists of several key components, each playing a vital role in the system's functionality:

Master Node
Worker Nodes
Pods
Services
Volumes
ConfigMaps and Secrets

1. Master Node The master node is responsible for managing the Kubernetes cluster. It runs several key components:

API Server: The API server is the central management point of the Kubernetes cluster, handling all RESTful requests.
Controller Manager: Manages various controllers that regulate the state of the cluster.
Scheduler: Allocates resources to pods based on availability and requirements.
etcd: A key-value store that maintains the cluster's state and configuration data.

2. Worker Nodes
Worker nodes are the machines where application containers run. Each worker node runs the following components:

kubelet: An agent that communicates with the master node and ensures the containers are running.
kube-proxy: A network proxy that facilitates communication between services.
Container Runtime: The software responsible for running containers (e.g., Docker, containerd).

3. Pods
Pods are the smallest deployable units in Kubernetes. A pod can contain one or more containers that share the same network namespace and storage.

4. Services
Services define a logical set of pods and a policy for accessing them. Kubernetes supports different types of services such as ClusterIP, NodePort, and LoadBalancer.

5. Volumes
Volumes provide persistent storage for containers within a pod. Kubernetes supports various volume types, including emptyDir, hostPath, and persistentVolumeClaim.

6. ConfigMaps and Secrets
ConfigMaps and Secrets are used to manage configuration data and sensitive information such as passwords and API keys.

Basic Kubernetes Commands
Now, let's explore some basic Kubernetes commands and their usage.

kubectl version: Displays the version of the Kubernetes client and server.

kubectl version
Enter fullscreen mode Exit fullscreen mode

kubectl cluster-info: Provides information about the Kubernetes cluster.

kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

kubectl get nodes: Lists all the nodes in the cluster.

kubectl get nodes
Enter fullscreen mode Exit fullscreen mode

kubectl describe node : Displays detailed information about a specific node.

kubectl describe node <node-name>
Enter fullscreen mode Exit fullscreen mode

kubectl get pods: Lists all the pods in the default namespace.

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

To list pods in a specific namespace:

kubectl get pods -n <namespace>
Enter fullscreen mode Exit fullscreen mode

kubectl describe pod : Displays detailed information about a specific pod.

kubectl describe pod <pod-name>
Enter fullscreen mode Exit fullscreen mode

kubectl get services: Lists all the services in the default namespace.

kubectl get services
Enter fullscreen mode Exit fullscreen mode

kubectl describe service : Displays detailed information about a specific service.

kubectl describe service <service-name>
Enter fullscreen mode Exit fullscreen mode

kubectl create -f : Creates resources defined in a YAML configuration file.

kubectl create -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

kubectl apply -f : Applies changes to resources defined in a YAML configuration file.

kubectl apply -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

kubectl delete -f : Deletes resources defined in a YAML configuration file.

kubectl delete -f deployment.yaml
Enter fullscreen mode Exit fullscreen mode

kubectl logs : Fetches the logs of a specific pod.

kubectl logs <pod-name>
Enter fullscreen mode Exit fullscreen mode

kubectl exec -it -- : Executes a command inside a running pod.

kubectl exec -it <pod-name> -- /bin/bash
Enter fullscreen mode Exit fullscreen mode

Conclusion
Kubernetes is a powerful platform that simplifies the management of containerized applications. Understanding its architecture and mastering its basic commands are essential for any DevOps engineer. In the next post, we will explore more advanced Kubernetes concepts such as deployments, stateful sets, and persistent storage.

šŸ”„ Subscribe to our blog to get notifications on upcoming posts.

šŸ’– šŸ’Ŗ šŸ™… šŸš©
shivam_agnihotri
Shivam Agnihotri

Posted on July 15, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related