Posts

Showing posts with the label cluster

Kubernetes Health Check and Auto Restart

Image
Introduction When you deploy an application to a production environment, various issues can cause it to stop working. These could be code bugs, database problems, or external service issues. Each problem requires a different solution. However, if you’re using Kubernetes to deploy your application and want it to automatically restart when an issue occurs, this article is for you. Prerequisites Before proceeding, ensure you have: A Kubernetes cluster set up. You can use Google Kubernetes Engine or set up a local Kubernetes cluster with Kind . Knowledge of Kubernetes , specifically how to create Deployments and Services . Kubernetes Probes In this article, I'll guide you through using three types of probes to check the status of your application: 1. Startup Probe    - As the name suggests, this probe runs when the application starts. It ensures the container has started successfully. Only after the Startup Probe succeeds do the Readiness and Liveness Probes execute. 2. Readin...

Kubernetes PersistentVolume and PersistentVolumeClaim to storage data

Image
Introduction In previous articles, I've guided you through using Kubernetes (K8s) to create resources from Docker images , resulting in stateless applications. This means no data is retained during usage, and restarting resources resets the application to its initial state. If you're familiar with Docker , you might know about mounting volumes to save data externally and reattach it to a Docker container as needed. In Kubernetes , you can achieve a similar result using PersistentVolume (PV) and PersistentVolumeClaim (PVC) to build stateful applications. Using PV and PVC in Kubernetes is crucial for real-world applications because they allow your data to persist across frequent deployments and restarts. Applications often face crashes or restarts due to issues, and having persistent data ensures seamless operation. PersistentVolume (PV) : A storage resource provisioned by an administrator. It exists independently of the pod lifecycle PersistentVolumeClaim (PVC) : A reques...

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 ...

Deploying a NodeJS Server on Google Kubernetes Engine

Image
Introduction to GKE Google Kubernetes Engine (GKE) is a managed Kubernetes service provided by Google Cloud Platform , facilitating simple and efficient deployment of Docker images. We only need to provide some configuration for the number of nodes, machine types, and replicas to use. Some Concepts Cluster A Cluster is a collection of Nodes where Kubernetes can deploy applications. A cluster includes at least one Master Node and multiple Worker Nodes . The Master Node is used to manage the Worker Nodes . Node A Node is a server in the Kubernetes Cluster. Nodes can be physical servers or virtual machines. Each Node runs  Kubernetes , which is responsible for communication between the Master Node and Worker Node , as well as managing Pods and containers running on it. Pod A Pod is the smallest deployable unit in Kubernetes . Each Pod contains one or more containers, typically Docker containers. Containers in the same Pod share a network namespace, meaning they have the ...