How to setup a remote development environment with code-server and nextcloud

Prerequisites

In this tutorial you need to have the following components

  • A kubernetes cluster (I recommend to use k3s.io)
  • A nextcloud installation (you can install via helm within the same k8s cluster)
  • A k8s storage class where you can save your files

System Architecture

This is the system architecture used in this tutorial

System architecture

Configure nextcloud sync client

In order to sync all out files across multiple devices we are going to use nextcloud as sync system, in this tutorial we used the nextcloudcmd command to sync our files using a docker container.

kubectl apply -f k8s/01-pvc-nextcloud-client.yaml
kubectl apply -f k8s/conf/nextcloud-client-conf.yaml
kubectl apply -f k8s/conf/nextcloud-client-conf.yaml

Configure vscode on the server

In this tutorial we are using the linuxserver/code-server which includes the web version of visual studio code (oss version) and is highly customizable due to s6-overlay system. This docker image allow us to extend the capabilities of the base image using docker mods.

Docker mods

In this tutorial I’m using my own docker mod, this docker mod install the required packages such as psql, awscli, python, kubectl, helm, zsh, etc. This docker mod also bootstrap the config files such a gitconfig, aws credentials, zshrc file, ssh keys, kube config file, etc. This files are mounted in the code-server pod then the bootstrap scrip will copy these files in her location with the correct owner and permissions.

apiVersion: v1
kind: ConfigMap
metadata:
name: code-server-configmap
namespace: prod
data:
...
DOCKER_MODS: "linuxserver/mods:code-server-extension-arguments|ghcr.io/ivanmorenoj/lsio-mods:code-server-ws"
...

Configure code-server on k8s

Create the Persistent Volume Claim for code-server deployment

kubectl apply -f k8s/02-pvc-code-server.yaml
kubectl apply -f k8s/conf/code-server-conf.yaml
kubectl apply -f k8s/04-code-server.yaml

Configure the ingress

In this step we are going to setup the ingress in order to access to our code-server installation through a FQDN domain with TLS endpoint.

kubectl apply -f k8s/05-ingress.yaml

Results

When you finished the setup you’ll have a remote environment with your files synchronized in a remote server with nextcloud just like this:

code-server working as web application

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ivan Moreno

Ivan Moreno

Engineer || MSc student || DevOps in progress