Posts

Showing posts with the label kubectl

Kubernetes Practice Series

Image
Introduction Kubernetes (often abbreviated as K8s ) is an open-source system designed to automate the deployment, scaling, and management of containerized applications. This page serves as a collection of articles related to Kubernetes (K8s) , including theoretical concepts and practical guides on using Kubernetes to set up essential tools for the software development process. I will continue to update this series with new articles as ideas come to mind, to ensure the series becomes more comprehensive. The articles are arranged in increasing order of difficulty to make it easier for you to follow. If you have time, it's recommended that you start from the beginning of the series to acquire the necessary knowledge and information that will prepare you for the subsequent articles. Key Topics Covered in This Series Basic Knowledge : Fundamental concepts, common commands, etc. Resources : Pod, Deployment, Service, StatefulSet, Ingress, etc. Pod Autoscaler : Horizontal vs. Vertical sc

Kubernetes Horizontal Pod Autoscaling

Image
Introduction There are two common scaling methods: Vertical scaling and Horizontal scaling . Vertical scaling involves adding more hardware, such as RAM or CPU , or increasing the number of server nodes. Horizontal scaling , on the other hand, means adding more instances of an app to fully utilize the available resources on a node or server. However, horizontal scaling has its limits. Once a node's resources are maxed out, vertical scaling becomes necessary. This article will focus on horizontal scaling using Kubernetes Horizontal Pod Autoscaling (HPA) , which automatically scales resources up or down based on system demands. Implementation Process 1. Build a Docker image for your application. 2. Deploy the image using a Deployment and LoadBalancer service. 3. Configure HPA to automatically scale resources. To use HPA for auto-scaling based on CPU/Memory , Kubernetes must have the metrics-server installed. If you’re using a cloud provider, the metrics-server is usually instal

Setting Up an EXTERNAL-IP for Local LoadBalancer Service

Image
Introduction If you've used a LoadBalancer service from a Cloud Provider , you'll know how convenient it is to have an EXTERNAL-IP assigned automatically. However, when using local Kubernetes , the default setting doesn't provide an EXTERNAL-IP . Building on our previous discussion, this guide will show you how to use ` cloud-provider-kind ` to assign an EXTERNAL-IP to your local LoadBalancer service . First, make sure you've set up your local Kubernetes using Kind as outlined in my previous guide. This is necessary to proceed with the next steps. Installing cloud-provider-kind Since this is a Go package , you'll need to install Go first. Then, you can install the package with the following steps: go install sigs.k8s.io/cloud-provider-kind@latest Then execute command to use: cloud-provider-kind Keep in mind that you need to keep the terminal running while using Kubernetes to create the EXTERNAL-IP . Testing with local EXTERNAL-IP Create a deployment and e

Setting up Kubernetes Dashboard with Kind

Image
Introduction In a previous article, I guided you through using Helm to deploy on Google Kubernetes Engine . However, if you want to cut down costs by using Kubernetes in your local environment instead of relying on a cloud provider during development, then Kind is your go-to. There are several tools to help set up Kubernetes locally, such as MiniKube , Kind , K3S , KubeAdm , and more. Each tool has its own pros and cons. In this article, I'll walk you through using Kind to quickly set up a Kubernetes cluster on Docker . Kind stands out for its compactness, making Kubernetes start up quickly, being user-friendly, and supporting the latest Kubernetes versions. Working with Kind Firstly, follow the instructions here to install Kind according to your operating system. If you're using Ubuntu , execute the command: [ $( uname -m ) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.23.0/kind-linux-amd64 chmod +x ./kind sudo mv ./kind /usr/local/bin/ki

Kubernetes Pod Cheatsheet

Image
Introduction This article is here to guide you on using Pod  in Kubernetes . I'll give you some concepts and commands that Kubernetes often uses to handle Pod . Pod Introduction A Pod is the smallest deployable unit in Kubernetes . Here are some key points about Pods: Multiple Containers : A Pod can contain more than one container, and there's no limit to how many containers you can run inside a Pod. These containers are relatively tightly coupled and share resources such as disk. Shared Resources : All the containers inside a Pod are connected via localhost and share the same memory space. They also share storage (volumes), IP address, and configuration information. Unique IP Address : Each Pod gets a unique IP address. Ephemeral Nature : Pods are ephemeral in nature; they can be created, deleted, and updated. Prerequisites Before we begin, make sure you have the following: For Kubernetes systems, you can use minikube or have permissions to provision resources on cloud pro

Using Terraform to deploy a docker image on Google Kubernetes Engine

Image
Introduction to Terraform Terraform is an Infrastructure as Code (IaC) tool developed by HashiCorp . It allows you to build, change, and version your infrastructure safely and efficiently. Here are some key features of Terraform : Human-Readable Configuration Files : Terraform lets you define both cloud and on-prem resources in human-readable configuration files that you can version, reuse, and share. Multi-Cloud Support : Terraform can manage infrastructure on multiple cloud platforms. Providers enable Terraform to work with virtually any platform or service with an accessible API. Lifecycle Management : The core Terraform workflow consists of three stages: Write : Define resources across multiple cloud providers and services. Plan : Terraform creates an execution plan describing what it will create, update, or destroy. Apply : On approval, Terraform performs the proposed operations in the correct order, respecting any resource dependencies. State Management : Terraform keeps track