Posts

Showing posts with the label gcp

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 ConfigMap and Secret

Image
Introduction This article will guide you on how to use ConfigMap and Secret to pass environment variables. As you know, during software development, you need to deploy on different environments such as development, staging, and production. We aim to use the same codebase across these environments but sometimes need to pass different environment variables for specific configurations. Kubernetes (K8s) supports ConfigMap and Secret to address this need. If you've used Docker before, configuring environment variables in K8s will feel similar. ConfigMap is an object that stores data in key-value pairs, intended for non-sensitive information (i.e., values that can be displayed when viewing the configuration of K8s resources). Supported data types include number , boolean , and string (it can store a string of characters or the contents of a text file). Secret has several types, with type=Opaque being the most commonly used. It works similarly to ConfigMap but is used for sensit...

Using Kubernetes Ingress to navigate traffic to Services

Image
Introduction In the previous article, I introduced the basic concepts of Kubernetes Ingress , and how to use Ingress along with related components ( Nginx Ingress Controller and cert-manager ) to automatically issue TLS certificates when deploying HTTPS applications . In this article, I'll show you how to define rules in Ingress to route traffic to different Services based on your needs. Prepare Docker Image First, you'll need a Docker image to get started. You can either use two different Docker images or follow my next instructions to prepare a Docker image . Here's a code block to create a NodeJS server that displays a title based on an environment variable input: import express from 'express' const port = 3000 const title = 'This is NodeJS Typescript Application' const app = express () app . get ( '/' , ( _ , res ) => { res . send (( process ?. env ?. TITLE ?? title ) + '! Current time is ' + Date . now ()) ...