Posts

Using fluent-ffmpeg to work with videos in NodeJS

Image
Introduction ffmpeg is a popular library that provides APIs for extracting information and manipulating videos. It supports various programming languages such as JavaScript , Ruby , and more. In this article, I'll give you a simple example of how to use ffmpeg to create thumbnails from videos and resize videos in NodeJS with TypeScript . Prerequisites Before we start, you need to install ffmpeg . The installation process depends on your operating system. If you're using Ubuntu , it's straightforward: sudo apt install ffmpeg Next, set up your NodeJS Typescript project. After that, install the package ` fluent-ffmpeg `. This package will serve as the interface for interacting between NodeJS and the previously installed ` ffmpeg `. yarn add fluent-ffmpeg Source Code Update the ` main.ts ` file with the following content: import * as ffmpeg from 'fluent-ffmpeg' const srcVideo = 'path/test.mp4' const outputVideo = 'path/test-resized.mp4...

Deploying a Python Flask Server to Google Kubernetes Engine

Image
Introduction In this article, I will guide you through deploying a Python Flask Server 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 Python Flask Server 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 Python Flask Server In this step, you can either use an exist...

Integrating NodeJS with Google Cloud Pub/Sub

Image
Introduction Google Cloud Pub/Sub is a fully-managed, real-time messaging service that enables you to send and receive messages between independent applications. This article will guide you through integrating NodeJS with Google Cloud Pub/Sub for simple message sending and receiving. Additionally, I've written an article on using Kafka , a distributed event streaming platform, to demonstrate message sending and receiving through NodeJS and Golang . Prerequisites Before proceeding with the following steps, make sure you have: A Google Cloud account with Pub/Sub enabled. Basic knowledge of NodeJS . In this article, I'm using a NodeJS TypeScript project. You can find setup instructions here . Implementing the Code After setting up your NodeJS TypeScript project , install the following package: yarn add @google-cloud/pubsub Next, update the ` main.ts ` file with the following content: import { PubSub , Topic , Subscription } from '@google-cloud/pubsub' export c...

Kubernetes Deployment for Zero Downtime

Image
Introduction In Kubernetes (K8s) , a Pod is the smallest resource unit used to run one or more containers during deployment. There are several ways to create a Pod : you can create it directly, use a ReplicationController , or a ReplicaSet . However, the most commonly used resource for managing Pods is the Deployment . When you use a Deployment , it actually creates a ReplicaSet to manage the Pods but comes with many additional benefits that support the deployment process. Some Advantages of Deployment : Ensures Pod Availability : It guarantees that the specified number of Pods are always running according to the configuration, automatically deploying additional Pods if any failures occur. Supports Restart and Undo Deployment : Allows you to easily restart or roll back to previous versions of your Deployment . Zero Downtime Deployment : When updating configurations or scaling Deployments , zero downtime is crucial. This means that new Pods are created while the old Pods are stil...

Deploying the Go Function to Google Cloud Function

Image
Introduction Previously, I wrote a guide on deploying a NodeJS TypeScript Function to Google Cloud Functions (GCF) and provided some basic information about GCF , which you can check out here. In this article, I'll walk you through a simple way to deploy a Go Function to GCF . Prerequisites Before we dive in, make sure you: Have a Google Cloud account and have enabled Cloud Functions . Have a basic understanding of Go . You can refer to this guide to set up the Go project used in this article. Implement Cloud Function After setting up your Go project , rename the module in the ` go.mod ` file to follow this format: ` example.com/moduleName `. This is required to deploy a Go Function . Next, update the content of the ` main.go ` file as follows: package packageName import ( "encoding/json" "fmt" "net/http" "strings" "time" ) // get method func GoCloudFunction1 ( w http . ResponseWriter , r * http . Request ) { f...

Deploying the NodeJS TypeScript Function to Google Cloud Function

Image
Introduction Google Cloud Functions (GCF) is a component of Google Cloud Platform (GCP) that allows you to deploy functions in a simple and flexible way. With a serverless approach, you can focus on developing your product without spending much time and effort managing infrastructure or cloud storage. I previously wrote about deploying a NodeJS TypeScript application to Google App Engine . Now, let's explore how Google Cloud Functions can help you deploy the necessary functions on-demand. GCF supports multiple runtime environments such as NodeJS , Golang , Python , Ruby , Java , and .NET . You can create a Cloud Function directly through the Google Cloud Console or via the Google Cloud CLI . In this article, I'll guide you through using the Google Cloud CLI to deploy a Cloud Function developed with NodeJS and TypeScript. Prerequisites Before we proceed, make sure you have the following: A Google Cloud account with Cloud Functions enabled Basic knowledge of NodeJS . ...