Posts

Deploying a Golang Application to Google Kubernetes Engine

Image
Introduction In this article, I will guide you through deploying a Golang Application to Google Kubernetes Engine ( GKE ). Previously, I wrote an article about deploying a NodeJS Application to GKE , which you can refer to for some basic information before continuing. Steps to Follow The process is quite similar to deploying a NodeJS Application and includes the following steps: Create a Golang Application Build a Docker image Push the Docker image Deploy the Docker image to GKE You will notice that when working with Kubernetes , the main difference is in the step where you build the Docker image. Depending on the application you need to deploy, there are different ways to build the Docker image . However, the common point is that once you build the Docker image , you have completed almost half of the process. This is because the subsequent steps involving Kubernetes are entirely the same. Detailed Process 1. Create a Golang Application In this step, you can either use an existin...

NodeJS Secure Environment Variables with Google Key Management Service

Image
Introduction When developing applications, using environment variables is essential. They help configure values for different environments like development, staging, and production. Some environment variables, such as API keys , database connections , or passwords , are sensitive and need to be kept secure. If you're using Google Cloud , their Key Management Service (KMS) can help you manage keys, and allows you to encrypt and decrypt values using those keys. Prerequisites Before we proceed, make sure you have: A Google Cloud account with permissions to use KMS . Google Cloud CLI installed . Basic knowledge of NodeJS . You can refer to this guide to set up a NodeJS TypeScript project , which will be used in this tutorial. Key Management Service KMS works with key rings, which hold multiple keys. You use these keys to encrypt and decrypt string values or file data. Be cautious: if a key is deleted, any data encrypted with it can't be decrypted anymore. To create a key ring,...

Uploading Files to Google Cloud Storage with NodeJS

Image
Introduction This guide will show you how to upload files to Google Cloud Storage using NodeJS . This method, which separates file storage from logic processing, is commonly used today. Cloud Storage offers an efficient solution for securely storing data, with major providers like Google , Amazon , and Azure leading the way. Prerequisites Before you proceed, make sure you have: A Google Cloud account or a Service Account with the necessary permissions to interact with a Bucket . Installed the Google Cloud CLI . Basic knowledge of NodeJS . You can refer to this guide to set up a NodeJS TypeScript project as used in this article . Creating a Service Account Refer to this guide to create a JSON file for your Service Account before moving on to the next steps. Setting roles for necessary permissions Ensure you have assigned the roles needed to interact with Google Bucket . gcloud projects add-iam-policy-binding {project id} \ --member=serviceAccount:{service account usern...

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