Exploring Crossplane #1: Introduction
(Image taken from official crossplane website) Managing infrastructure across multiple cloud providers can be complex and challenging. Enter Crossplane鈥攁 powerful, open-source Kubernetes native control plane that allows developers and platform teams to use Kubernetes to manage cloud resources like databases, storage, and networking across multiple cloud providers (AWS, GCP, Azure, etc.) and not limited to this and much more other non-cloud resources as well such as Pagerduty, Github, etc. In this introduction to Crossplane, we鈥檒l explore its core capabilities, why it鈥檚 gaining popularity, and where it鈥檚 particularly useful....
Building mkdir (linux) command in Go
One of the best way to learn language is to try recreating familiar linux command in it. In one of the previous post, we have seen how we can implement simple which command, you can check the blog post here. In this blog post, we will try to implement mkdir command, Let鈥檚 get started. mkdir is one of the important commands in Linux which helps to create directories. we will cover following in the blog post:...
Understanding iota function in Go
Iota is predefined identifier which is used in constant declaration in Go. It is used to simplify incrementing value of constants. iota value always start at 0 and increments automatically by 1 for next constant. here鈥檚 the syntax for the iota, const ( a = iota // 0 b = iota // 1 c = iota // 2 ) or you can simply write it as, const ( a = iota b c ) Let鈥檚 look at simple example,...
Refactoring Terraform easily with moved block
As Terraform codebase grows, there are chances where you may need to refactor or rename resources in your codebase which can result into deletion and recreation of resources. This happens because terraform thinks that you want to delete and create new resource and it allocates new id to the resource. Instead, you should let terraform know that you want to simply move the resource instead of replacing it. To mimic this we will take simple example where we will have AWS instance with name a and we want to change it to b...
Piping Command Output in Go
In a previous blog post, we learned how to create and run commands in Go. Now, let鈥檚 explore how to recreate the following command: ls -l | grep hello Let鈥檚 create the first command: lsCmd := exec.Command("ls", "-l") Next, create the second command: grepCmd := exec.Command("grep", "hello") To connect them, we need to understand what鈥檚 happening in the Linux command. Essentially, we are taking the stdout of the first command ls -l and passing it to the stdin of the second command grep hello....
Running Shell Commands in Go using os/exec
Sometimes, there are certain use cases where you may have to run shell commands through a Golang app. This is where the os/exec package comes in handy. If you want to run a command like sleep 1, you can simply do the following: cmd := exec.Command("sleep", "1") err := cmd.Run() This will run the command and wait until the execution finishes, but it doesn鈥檛 capture the stdout. If you intend to capture both stdout and stderr, you can use the following code:...
Building which (Linux) command in Go
One of the best ways to learn a language is via building equivalent Linux commands using the language of your choice. which is my all-time favourite command to see if the binary is present on the server or not. You can see which usage as shown below, $ which kubectl-eks /Users/surajnarwade/.krew/bin/kubectl-eks We simply pass the binary name to which command and it will give us the absolute path to the binary....