Posts

Use BFS algorithm to find the accessible area of a robot in a 2D graph

Image
Recently, I found myself started to love working with algorithms. The funny thing is I was never interested in algorithms back in my university time. Maybe because I'm more attracted to something that has a visual appearance or has real-life applications, something like Physics I thought. After more than 10 years working in the field of cloud computing, networks, and computer system, I realized everything are operating by algorithms. Algorithms to optimize network configurations, algorithms to make the application process faster, algorithms to auto-scale the clusters, etc. It may be a little bit too late but right now I can tell algorithms are beautiful. I tried some HackerRank coding challenges and the problem below caught my eye because it's used in pathfinder, searching, etc. They can be very useful for a cloud architect like myself when optimizing network configurations or building some automation apps. The Problem: There is a robot that can move around on a grid. The robot

Dockerize your development environment

Image
Recently, a friend of mine asked me about how I set up my development so that it's easy to move onto production without many issues such as the differences between the environments, dependencies, etc. Here are a couple of questions. Deploy Dev environment + staging environment in containers? Is deploying a big container and stuffing all packages reasonable? What are the differences between Python container vs Ubuntu container? and which one to use? Can Dockerfile execute commands or scripts (e.g., automatically create users, run an existing script, etc.)? When deploying the application with the container, how are the logs collected? How to handle the versioning process? So your company is on the way to streamline the process of developing, testing, and deploying software to production? But you are confused because there are so many tools out there such as Kubernetes, the "CI/CD universe" and stuff, ain't you? No problem. You just need to get started with

Kong for your microservices

Image
The Kong API Gateway [1] has been around for some time and it has been evolving from an APIs Management solution to an industry-standard tool for the cloud-native environments. People are choosing Kong because it is super easy to set up and operate, as well as its capability to scale and extend with plugins. I have been a Kong user and administrator for a while as a DevOps engineer, and I think I should write down my experience with it before too many new things take over my head. This article will focus on a deployment strategy for Kong in a microservice architecture [2]. CONTENTS Introduction Kong's architecture Kong for microservices Common issues & what we can improve INTRODUCTION A quick introduction of Kong and Microservice Architecture could be a great way to get started. Kong We can summarize Kong as follows. Open-source cloud-native, fast, scalable, and distributed Microservice Abstraction Layer. It means that Kong can be deployed in containerized e

Delete all Kong targets using bash

Some times I just want to delete all the Kong targets and redeploy all the APIs to troubleshoot some issues. So, I wrote the below bash script: Usage ./clean_all_kong_targets.sh kong.dangtrinh.com:8001

Scale multiple ECS services at once

You use the following bash script I wrote to scale multiple ECS services at once: Prerequisite - AWS CLI [1] - An IAM account that has permission to update or scale ECS services - A text file that contains all the ECS service names, each line contains 1 service name. For example: service1 service2 ... Usage ./mass_scale_ecs_svc.sh <cluster name> <path to the ECS service names text file> <desired count, e.g., 0> References: [1]  https://aws.amazon.com/cli/

Create a sock proxy to a private network

Last week, I wrote a bash script that can be used to create a sock proxy that connects my computer and a private network via a bastion server (the bastion server is a server that sitting inside a private network that I can ssh into using a pem key). Usage: ./gen_sockproxy.sh /path/to/sshkey.pem <bastion_username> <bastion_address> It will output the sock proxy address. For example:  socks5://localhost:13000

Add MetalLB to MicroK8S

Image
There is a question that pops up inside my head every time I work with Kubernetes [1], " Why the hell does it not implement a network load balancer? ". It did have network load balancers but tied to public cloud providers (e.g., AWS, GCP, etc.). What if I want to run Kubernetes clusters in my private clouds or even in my bare-metal infrastructures? Fortunately, I found  MetalLB [2]. "MetalLB hooks into your Kubernetes cluster, and provides a network load-balancer implementation. In short, it allows you to create Kubernetes services of type “LoadBalancer” in clusters that don’t run on a cloud provider, and thus cannot simply hook into paid products to provide load-balancers." ~MetalLB documentations. So, whenever I spin up a new Kubernetes cluster in my bare-metal infrastructures (or for my MicroK8S [4] clusters), I normally have to deploy MetalLB and with Layer 2 configuration as depicted in figure 1. There are also other configurations such as BGP, automatic