Kris Cotten
Software engineering | Infrastructure | DevOps | Root Cause Analysis
Creating infrastructure with code is an extremely powerful tool that can abstract away the need for on-premises hardware. Instead of attempting to hand provision things in private cloud consoles such as AWS, GCP, or Azure we can instead rely on tools such as Terraform and Pulumi to help automate this and in both cases help to keep track of the state of the infrastructure. Sometimes, if you just need something quickly, one could also use Bash and the aws-cli to provision the same.
[Read More]
Connect from WSL2 to a Windows Service
Recently, while doing some experimentation with MongoDB I noticed that my Spring app would no longer connect to mongo with the old WSL1 configuration. After some digging I was able to reconnect my app running in WSL2 to the Mongo service running on the Windows side. The following steps should get packets flowing:
Allow packets through the firewall by firing up a Powershell console and issuing:
New-NetFirewallRule -DisplayName "MongoDB from WSL2" -InterfaceAlias "vEthernet (WSL)" -Direction Inbound -Protocol TCP -LocalPort 27017 -Action Allow Reconfigure Mongo to listen for requests on all interfaces, as this is just for local development, by editing the mongod.
[Read More]
Add An Existing Repo to Github via CLI
If you’d like to push an already existing git repository to github then you can easily create the repository from the cli and begin the foundations of interacting with remote repos programmatically. First, you need a personal access token and if you do not yet have one then perform the following:
Access your github account settings Developer Settings Personal access tokens Generate new token Be sure to save/download the token, as you will be unable to access it in the future.
[Read More]
Dynamic JSON Parsing
Almost always when writing a REST endpoint you will know beforehand the format of the data you will receive and you can write your downstream client accordingly. Barring documentation you can parse a curl response and adjust accordingly, but what if the tables were turned and you needed to dynamically parse unknown JSON?
In Python, with a dynamic type system, this is relatively straight forward. Let’s parse and print the results such as in this example.
[Read More]
Simple IPC with gRPC
Once an application has been broken up into microservices there is a need for these processes to communicate with one another. Enter gRPC a consistent, lightweight remote procedure call framework. Loosely speaking, the protocol allows a client and server to communicate via HTTP2 through an interface called a protocol buffer. Refer to this page for a visual breakdown of the call flow. Without getting bogged down in the details, suffice to say grpc’s strict protocol definitions are advantageous to developers by simplifying the hassle around Inter-process Communication (IPC).
[Read More]
Go Rest Endpoint
An example of a simple REST endpoint in go is:
https://github.com/kcotten/restep Choosing gorilla/mux yields a cleaner, simpler interface that works well with the standard library. From main() instantiate the router, for handling the HTTP routes, initialize it, and finally listen and serve.
The router instantiated is the mux.Router that we will use to register routes to be served. Since this is just an example nothing more sophisticated than serving a GET endpoint at /info is happening.
[Read More]
Dockerize Your Go Web App
After browsing around the internet I couldn’t find any guides for exactly what I wanted to do with a prototype I was writing and so decided to share my discoveries. After writing your web app in Go to get it ready for deployment in docker (and later to the cloud) create a new file named dockerfile in the main directory ~/go/src/<my-app>.
Check the version of go you are using quickly with $ go version and then add the following to your new dockerfile:
[Read More]
Replacing a disk on a headless Ubuntu server
Recently I picked up a new 4 TB SSD on sale at the Amazon Prime day sale to replace an aging RAID5 array in my media server. Over the last couple days I made the exchange and thought I should save an outline of the steps for posterity.
Connect the new drive through your preferred method, I chose USB.
Log into the server with SSH.
Identify the new drive with:
[Read More]