This post aims at describing the deployment of Coder on a Kubernetes cluster via the K3s distribution.
Coder is an online development environment platform that offers the possibility to code directly from a web browser. All the compilation toolchain is then deported on the server. Coder provides a ready-to-use remote development environment and reduces the installation and configuration issues that could arise from the heterogeneity of developer's workstation architectures and software used.
This kind of solution has gained popularity in recent years, with several alternative solutions such as:
These alternative solutions have a lot in common, but also some distinguishing features that can make them attractive.
I am interested in deploying an online development platform within a higher education governmental institution. This platform is meant to be used by researchers and students. Several features are mandatory, such as self-hosting, open source, great community, ease of installation, and the ability to handle multiple programming languages.
A first experimentation was based on Gitpod. Unfortunately, Gitpod no longer supports self-hosting, as explained on the Gitpod blog. Furthermore, setting up Gitpod was not easy, and I can understand the choice made by Gitpod developers, as explained on the blog post, to drop support for self-hosting since there were many issues arising from the heterogeneity of Kubernetes distributions. A second solution was JupyterHub, which was fairly easy to install but limited to the Python language. In a third experimentation, I therefore turned to Coder. In this post I will explain how I deployed it on a K3s cluster.
Coder solution matches all features I need, because it is self-hosted, open source and has a greatDiscord community. From a technical point of view, Coder provisions remote development environments via Terraform to supply users with Workspaces. For example, via Terraform, you can specify that you want to use a specific Docker image that contains the necessary compilation toolchain to build Java programs and that you want to install VIM as a code editor. Resources will also be specified, such as the memory or storage capacity of Workspaces. As for K3s, it is a lightweight Kubernetes distribution designed for production environments with limited resources, such as embedded systems. I appreciate K3s because it is designed to be easy to install.
The deployment of Coder on a K3s cluster is broken down into the following steps:
All materials can be found on my Github repository: https://github.com/mickaelbaron/coder-k3s-guide
Before starting the Coder install process, you must have:
The following infrastructure (to reproduce the experimentation):
k3sserver
, k3snode1
and k3snode2
.k3sserver
.k3sserver
to deploy the reverse-proxy.Locally
Note: in the following infrastructure, I will present a configuration where TLS certificates will be managed by a reverse-proxy outside of Kubernetes. It is a restriction of my higher education governmental institution and I would like to reproduce the same setup and to show you this specific use case. But, I agree in many cases, the ingress could/should also be secured via cert-manager or by passing TLS certificates in directly. It would be better to stay within the K8s infrastructure.
k3sserver
) and run:
k3snode1
) and run:
k3snode2
) and execute the same command line:
These instructions are based on the K3s website: https://docs.k3s.io/quick-start.
coder
in this example:
The cluster-internal DB URL for the PostgreSQL database is:
# TODO
comments:
The service will be configured as a ClusterIP. We configure Ingress to handle requests for the (coder.mydomain.com
) domain.
coder
namespace:
These instructions are based on the Coder website: https://coder.com/docs/v2/latest/install/kubernetes.
As mentioned in the setup section, a reverse-proxy will be deployed outside of your Kubernetes cluster.
The reverse-proxy will also be in charge of managing SSL/TLS certificates. Let's describe how to generate certificates with LetsEncrypt.
k3sserver
) and install Certbot:
You need to configure your Kubernetes cluster to update HTTP and HTTPS listen ports.
k3sserver
) and create a /var/lib/rancher/k3s/server/manifests/traefik-config.yaml file with the following content:
We suppose Docker is installed on the server node (k3sserver
).
reverseproxynetwork
:
Two reverse-proxy solutions will be presented: NGINX and Apache HTTP. Choose only ONE at your convenience.
Connect to the server node (k3sserver
).
Create an nginx directory:
Connect to the server node (k3sserver
).
Create an apachehttp directory.
Copy and update at your convenience the apachehttp/httpd.conf configuration file.
Create a file apachehttp/docker-compose.yaml with the following content:
I hope this post helped you deploy Coder on a Kubernetes cluster via the K3s distribution.
I still have a lot to learn on how to use and configure Coder. In a future post, I will try to provide some feedback on my use of Coder and Kubernetes. Several questions still remain unanswered:
The answers to these questions, among others, might help me conclude whether Coder is the solution to my problem.
Want to stay up to date on all things Coder? Subscribe to our monthly newsletter and be the first to know when we release new things!