Kubernetes Usage Guide: A Beginner's Guide for Engineers and Developers

Kubernetes Usage Guide: A Beginner's Guide for Engineers and Developers

For engineers and developers new to Kubernetes, I'll briefly explain the basic concepts of Kubernetes along with practical usage examples.

For detailed information, please refer to the official documentation!

Kubernetes Documentation
Kubernetes is an open source container orchestration engine for automating deployment, scaling, and management of containerized applications. The open source project is hosted by the Cloud Native Computing Foundation.

Kubernetes Documentation Kubernetes is an open source container orchestration engine for automating deployment, scaling, and management of containerized applications. The open source project is hosted by the Cloud Native Computing Foundation.

1. The Need for Containers and Kubernetes

1.1. What are Containers?

Containers are lightweight, isolated environments that package applications and their dependencies (libraries, configuration files, etc.) into a single package for execution. Unlike virtual machines (VMs), containers share the host operating system's kernel, making them more efficient.

Containers provide the following advantages:

  • Consistency: Ensures identical execution environments across development, testing, and production.
  • Efficiency: Uses fewer resources than VMs.
  • Scalability: Easily deploy and manage hundreds or thousands of containers.
  • Isolation: Different applications can run safely on the same host.

The most widely used container runtime is Docker. https://chonchony.tistory.com/m/entry/Docker-%EB%8F%84%EC%BB%A4%EB%9E%80-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80

Docker is used to create, deploy, and run containers. To create containers, you follow these steps:

  1. Write Dockerfile: Define the application environment (base image, code, dependencies, configuration).
  2. Build Image: Create a container image using the Dockerfile.
  3. Run Container: Execute containers based on the image.

1.2. The Importance of Containers

Containers are essential in modern software development. We use containers for the following reasons:

  • Portability: Containers run identically across cloud, on-premises, and local environments.
  • Scaling: Applications can be easily replicated and scaled.
  • Microservices: Complex applications can be separated into small, independent services.

However, managing containers at scale requires complex tasks (e.g., scaling, networking, failure recovery). This is where Kubernetes becomes necessary.

2. Introduction to Kubernetes

2.1. What is Kubernetes?

Kubernetes (K8s) is an open-source platform that automatically deploys, scales, and manages containerized applications. Developed by Google and currently managed by the Cloud Native Computing Foundation (CNCF), Kubernetes provides the following key features:

FeatureDescription
Service Discovery & Load BalancingAssigns DNS names or IPs to containers and distributes traffic.
Storage OrchestrationAutomatically mounts various storage types including local and cloud storage.
Automated Rollouts & RollbacksSafely applies application updates and recovers to previous versions if issues occur.
Automatic Bin PackingOptimizes resources to efficiently place containers.
Self-healingAutomatically restarts or replaces failed containers.
Secret ManagementSafely manages sensitive information like passwords and tokens.
Batch ExecutionRuns one-time jobs or CI/CD pipelines.
Horizontal ScalingAutomatically scales applications up/down based on CPU usage and other metrics.
IPv4/IPv6 Dual StackSupports both IPv4 and IPv6 addresses.
ExtensibilityDesigned to allow addition of new features.

Kubernetes is used in many TOP500 supercomputer systems and supported by major cloud providers like AWS, Google Cloud, and Azure.

2.2. Why Use Kubernetes?

Kubernetes is essential for container management for the following reasons:

  • Automation: Automates deployment, scaling, and updates to increase developer productivity.
  • Scalability: Supports everything from small clusters to large-scale production environments.
  • High Availability: Ensures applications run without interruption.
  • Portability: Works identically across various environments.
  • Community Support: As an open-source project, it provides active community support and rich documentation.

3. Kubernetes Architecture

A Kubernetes cluster consists of several components. The main components are:

ComponentDescription
Master NodeManages the cluster, including API server, scheduler, and controller manager.
Worker NodeNodes where applications run, including kubelet and kube-proxy.
etcdDistributed key-value storage that stores cluster state and configuration information.
kube-apiserverProvides the Kubernetes API and manages cluster state.
kube-schedulerPlaces workloads on appropriate nodes.
kube-controller-managerMaintains cluster state and manages replication, node status, etc.
kubeletRuns and manages containers on nodes.
kube-proxyHandles networking and load balancing.
Container RuntimeRuntime that executes containers, such as Docker or containerd.

Key Kubernetes objects:

  • Pod: The basic execution unit in Kubernetes, containing one or more containers.
  • Deployment: Manages pods and handles scaling and updates.
  • Service: Provides stable network endpoints for pods.

4. Getting Started with Kubernetes

4.1. Basic kubectl Commands

Here are frequently used kubectl commands:

CommandDescription
kubectl get nodesDisplays the list of cluster nodes.
kubectl get podsDisplays the list of running pods.
kubectl get deploymentsDisplays the list of deployments.
kubectl get servicesDisplays the list of services.
kubectl createCreates resources (deployments, services, etc.).
kubectl deleteDeletes resources.
kubectl logsDisplays pod logs.
kubectl describeDisplays detailed information about resources.

5. Example: Deploying a Simple Application

Here's a simple example of deploying an nginx web server:

bash

# Create a deployment
kubectl create deployment nginx-deployment --image=nginx

# Expose the deployment as a service
kubectl expose deployment nginx-deployment --port=80 --type=NodePort

# Check the status
kubectl get pods
kubectl get services

6. Conclusion

Kubernetes is a frequently used tool for efficiently managing and orchestrating containerized applications. From a user perspective, understanding this much should be sufficient. For those studying server infrastructure, I think you'll quickly master it by reading the official documentation mentioned above.

Next Steps

To deepen your Kubernetes knowledge:

  1. Practice with local tools like Minikube or Docker Desktop
  2. Learn about advanced concepts like ConfigMaps, Secrets, and Persistent Volumes
  3. Explore monitoring and logging solutions
  4. Study security best practices
  5. Consider managed Kubernetes services (EKS, GKE, AKS)

Kubernetes may seem complex at first, but once you understand the core concepts, it becomes an incredibly powerful tool for modern application deployment and management.

Read more