Recap of “Getting Started with Kubernetes” Course

Introduction

In this article, we’ll recap the essential parts of the “Getting Started with Kubernetes” course, focusing on basic concepts, microservices, containerization, and practical steps for deploying applications both locally and in th…


This content originally appeared on DEV Community and was authored by Amanda Guan

Introduction

In this article, we'll recap the essential parts of the "Getting Started with Kubernetes" course, focusing on basic concepts, microservices, containerization, and practical steps for deploying applications both locally and in the cloud. We'll integrate illustrations to visualize key concepts and provide code snippets and terminal commands for practical understanding.

What Is Kubernetes?

Kubernetes is an open-source platform that automates the deployment, scaling, and operation of application containers. It orchestrates containerized applications to ensure reliable operations.

What Are Microservices?

Microservices are a design pattern that allows for fault isolation and the independent management of application features. They enable faster development and iteration by smaller, specialized teams but can be complex to manage.

What Is Cloud Native?

Cloud-native applications are specifically designed to leverage the advantages of cloud computing, such as scaling on demand, self-healing, supporting zero-downtime rolling updates, and running anywhere with Kubernetes.

Why Do We Need Kubernetes?

Kubernetes organizes microservices, scales applications automatically, self-heals by replacing failed containers, and allows for seamless updates with zero downtime, making it essential for managing complex microservices architectures.

Illustration: Microservices Architecture

Image description

What Does Kubernetes Look Like?

Masters and Nodes

A Kubernetes cluster consists of Master Nodes (control plane) and Worker Nodes (running user applications). Masters handle the cluster's control plane, while Nodes execute the application workloads.

Illustration: Kubernetes Cluster Components

Image description

Kubernetes in the Cloud with Linode Kubernetes Engine (LKE)

LKE simplifies the setup and management of Kubernetes clusters in the cloud, handling the control plane while users manage their applications and worker nodes.

Introduction to Containerization

Containerization involves packaging an application with its dependencies and configurations into a container image. This ensures consistent operation across different environments.

Build and Host the Image

Steps to containerize the application include writing a Dockerfile, building the image, and pushing it to a registry like Docker Hub.

Dockerfile Example

FROM node:current-slim

# Copy source code to /src in container
COPY . /src

# Install app and dependencies into /src in container
RUN cd /src; npm install

# Document the port the app listens on
EXPOSE 8080

# Run this command (starts the app) when the container starts
CMD cd /src && node ./app.js

Illustration: Containerization Workflow

Image description

Get Hands-on With Kubernetes

Setup Required

Ensure you have Docker Desktop, Git, and optional accounts for Linode and DockerHub. Familiarize yourself with the kubectl command-line tool.

Deploy the Application Locally

  1. Define the Pod in pod.yml:
   apiVersion: v1
   kind: Pod
   metadata:
     name: first-pod
     labels:
       project: qsk-course
   spec:
     containers:
       - name: web-ctr
         image: educative1/qsk-course:1.0
         ports:
           - containerPort: 8080
  1. Deploy the Pod:
   kubectl apply -f pod.yml
  1. Verify Pod is running:
   kubectl get pods
  1. Forward port to access the application:
   kubectl port-forward --address 0.0.0.0 first-pod 8080:8080
  • Access at http://localhost:8080.

Illustration: Kubernetes Pod Definition

Image description

Deploy the Application on Cloud

  1. Copy-paste kubeconfig to config file and configure kubectl:
   export KUBECONFIG=/usercode/config
  1. Deploy the Pod:
   kubectl apply -f pod.yml

Connect to the Application

  1. Define a Service in svc-cloud.yml or svc-local.yml:
   apiVersion: v1
   kind: Service
   metadata:
     name: svc-local
   spec:
     type: NodePort
     selector:
       app: web
     ports:
       - protocol: TCP
         port: 80
         targetPort: 8080
  1. Deploy the Service:
   kubectl apply -f svc-local.yml
  1. Verify the Service:
   kubectl get svc
  1. Access the application via the Service.

Kubernetes Deployments

  1. Define Deployment in deploy.yml:
   apiVersion: apps/v1
   kind: Deployment
   metadata:
     name: qsk-deploy
   spec:
     replicas: 5
     selector:
       matchLabels:
         project: qsk-course
     template:
       metadata:
         labels:
           project: qsk-course
       spec:
         containers:
           - name: hello-pod
             image: educative1/qsk-course:1.0
             ports:
               - containerPort: 8080
  1. Deploy the Deployment:
   kubectl apply -f deploy.yml
  1. Self-healing from failures:
    • Monitor and manually delete a Pod to see Kubernetes self-heal.
    • Delete a Node and observe automatic Pod replacement.

Illustration: Kubernetes Deployment

Image description

Scaling an Application

  1. Scale up:

    • Edit deploy.yml to set replicas to 10.
    • Apply changes and verify:
     kubectl apply -f deploy.yml
     kubectl get pods
    
  2. Scale down:

   kubectl scale --replicas=5 deployment/qsk-deploy
   kubectl get pods

Rolling Update

  1. Perform rolling updates by modifying deploy.yml:

    • Set minReadySeconds, maxSurge, and maxUnavailable.
    • Apply updates and monitor progress.
  2. Clean up resources after update:

   kubectl delete deployment qsk-deploy
   kubectl delete svc svc-local

Conclusion

The "Getting Started with Kubernetes" course provides a comprehensive overview of Kubernetes, from understanding microservices and cloud-native applications to deploying and managing containerized applications. Through practical exercises and hands-on labs, you gain the skills needed to effectively use Kubernetes in both local and cloud environments.

By following this recap and using the provided illustrations and code snippets, you should have a solid foundation to continue exploring and mastering Kubernetes.


This content originally appeared on DEV Community and was authored by Amanda Guan


Print Share Comment Cite Upload Translate Updates
APA

Amanda Guan | Sciencx (2024-07-15T20:47:24+00:00) Recap of “Getting Started with Kubernetes” Course. Retrieved from https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/

MLA
" » Recap of “Getting Started with Kubernetes” Course." Amanda Guan | Sciencx - Monday July 15, 2024, https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/
HARVARD
Amanda Guan | Sciencx Monday July 15, 2024 » Recap of “Getting Started with Kubernetes” Course., viewed ,<https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/>
VANCOUVER
Amanda Guan | Sciencx - » Recap of “Getting Started with Kubernetes” Course. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/
CHICAGO
" » Recap of “Getting Started with Kubernetes” Course." Amanda Guan | Sciencx - Accessed . https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/
IEEE
" » Recap of “Getting Started with Kubernetes” Course." Amanda Guan | Sciencx [Online]. Available: https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/. [Accessed: ]
rf:citation
» Recap of “Getting Started with Kubernetes” Course | Amanda Guan | Sciencx | https://www.scien.cx/2024/07/15/recap-of-getting-started-with-kubernetes-course/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.