Introduction

Kubernetes has become the de facto standard for container orchestration. It simplifies the deployment, scaling, and management of containerized applications. In this post, we’ll cover the basics of Kubernetes and how to get started.

What is Kubernetes?

Kubernetes (K8s) is an open-source container orchestration system that automates deployment, scaling, and operations of application containers across clusters of hosts. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).

Key Concepts

  • Pods: The smallest deployable units in Kubernetes that encapsulate one or more containers.
  • Nodes: The machines (virtual or physical) that run the Kubernetes cluster.
  • Deployments: Manage and update applications seamlessly.
  • Services: Expose applications running on a set of pods to the network.
  • ConfigMaps & Secrets: Manage application configuration externally.

Setting Up Kubernetes

Install Kubernetes

You can set up a local Kubernetes cluster using Minikube:

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube
minikube start

Alternatively, managed Kubernetes services like Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), or Azure Kubernetes Service (AKS) are available.

Deploying an Application

To deploy an application in Kubernetes, create a deployment.yaml file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
d spec:
  replicas: 2
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
      - name: my-app
        image: nginx:latest
        ports:
        - containerPort: 80

Apply the configuration using:

kubectl apply -f deployment.yaml

Conclusion

Kubernetes is a powerful tool for managing containerized applications. By understanding its core components and setting up a basic deployment, you are on your way to leveraging the full potential of Kubernetes.