Visual Studio Code and Dev containers in the Windows Subsystem for Linux (WSL)
UPDATE (2020-04-08): With the 1.44 release of Visual Studio Code (and the corresponding Remote Containers release), the Insiders release is no longer needed as the . I have updated the post to reflect this (update made in vscode dev container on stable release 😁).
Introduction
In my previous post I gave some thoughts on using Visual Studio Code dev containers. Until very recently your source code needed to be cloned in Windows in order to be able to build and run dev containers with Visual Studio Code. While this has still been a great experience overall, I have hit a few edge cases where being able to have my source code in Linux (under WSL) and then create a dev container from there would have been a big help.
[Read More]Visual Studio Code and Dev Containers
Visual Studio Code has support for Remote Development which is a really cool feature. You can connect to another machine via SSH and work with code there (the language services etc run remotely which is the really cool part!), connect to the Windows Subsystem for Linux, or run your development environment in containers (aka dev containers). The last of these is the topic for this post.
My team has been using dev containers quite heavily for the last few months and found a lot of benefits with them. They allow you to describe your development environment with a Dockerfile
and run your tools, terminal and debugger inside that container whilst keeping the editor UI local. This image from the docs shows this split:
Error Back-off with Controller Runtime
Kubebuilder provides tooling to help get you started quickly writing operators for Kubernetes, and builds on top of controller-runtime. I’ve been looking at how errors are handled in a couple of Kubebuilder projects recently. I’d seen a couple of GitHub issues that mentioned that controller-runtime has back-off behaviour for errors so started looking through the docs to find out more, but didn’t find anything. If I get chance, I’d like to find a suitable place to send a PR to add some details in the docs, but for now I’m collating my notes here as a reference for future me!
[Read More]Working With Multiple Kubernetes Contexts
If you’re working with Kubernetes then there’s a pretty good chance that you’ve been working with kubectl
!
There’s also a pretty good chance that you end up working with more than one cluster context. So, how do you manage multiple contexts?
KUBECONFIG
One way that you might have encountered is obtaining a kubeconfig
file that contains the details of how to connect to a cluster. kubectl
allows you to pass a --kubeconfig
option to commands to specify which kubeconfig
should be used to connect to a cluster to execute the command. E.g. kubectl get pods --kubeconfig=/path/to/kubeconfig
.
Working With Git Rebase in Visual Studio Code
Following the git theme for mini-posts, I thought I’d give git rebase
a mention this time.
When I first started working with git I found a way to pretend that it was a source control system like any other that I’d used. Eventually, I was working on a pull request for an OSS project and a maintainer asked me to rebase my changes. Now, I’d heard of rebase at that point but I hadn’t used it, so I was a bit daunted. So this post has a few tips that I wish I’d known at that point. By way of encouragement, I’ll add that getting familiar with git rebase is a huge part of the reason that I love git and has improved my developer workflow.
[Read More]Setting Visual Studio Code As Your Git Editor
Working With Pull Requests in Azure DevOps
Using Event Filters with Kubebuilder
Part 2: Filtering Updates
Background
As I recently posted, I’ve worked on a couple of projects that have involved using Kubebuilder to create Kubernetes operators.
In last post we looked at using event filters to prevent delete notifications being processed by the reconciliation loop. Another thing I’ve noticed as I’ve been developing operators is that the flow when an object is created is typically: receive create notification, take some action, update the object Status
property. It turns out that updating the Status
triggers the reconciliation loop again (this also happens when you add a finalizer)! In this post we’ll look at filtering out these updates that occur due to the Status
object changing.
Connection re-use in Golang with http.Client
Just before Christmas I was working with Eliise and Lawrence and we observed port exhaustion during load testing of a Golang application that makes HTTP requests against an API. I hoped for a quick win and had a quick scan of the code but that confirmed that the was correctly reading the Body
and calling Close
- time to dig a bit deeper.
After some head-scratching we noticed that the code creates a new http.Client
for each request. Not only that, when it creates the http.Client
it also assigns a Transport
instance. This last piece is very important - the docs for Transport
state: