Remote Development Overview
Introduction
Remote Development allows software engineers to work and perform tests on environments which are identical to production from an architecture and configuration standpoint.
This solves two main issues:
- It allows engineers to run their code on exactly the same type of services as production. There is no longer a need to emulate/simulate cloud services.
- It allows engineers to use environments which they would not be able to run on their local machines due to available hardware resources.
You can use Bunnyshell's Remote Development feature in one of two ways, depending whether you prefer to keep a local copy of the code or not:
- have nothing but your IDE on your local machine and edit the file directly in the container. The IDE will connect through SSH into the container.
- have the code and your favourite IDE on your local machine and edit the files locally and sync them into the container. The code will be synchronized using a 3rd party tool named Mutagen from your device to the container of your choice, running in Kubernetes.
How it works
- Bunnyshell prepares the targeted component by installing the Mutagen agent and an SSH server on its Kubernetes Pod.
- A Mutagen process will be started on your machine, which will connect to the remote Mutagen agent. It will sync the files in
two-way-resolved
mode, meaning it will sync files two-ways: both from local into the container, as well as from the container to local, using a high-performance file sync'ing algorithm, in which the local will win any potential conflicts (files modified both on local and in the container). - The SSH server forwarded port will be used to open an interactive shell into the
Pod
which will allow you to execute commands in the container running in Kubernetes, so you can preserve your way of working, and run the same commands in the Kubernetes cluster, as you did on local.
Target component changes
Volumes added
remote-dev-work
: aPersistentVolumeClaim
storing the code for the application that's about to be remote developed onremote-dev-bin
: anEmptyDir
volume, used to copy files needed by Bunnyshell from theremote-dev-bin
container into the target containerremote-dev-config
: secret containing theauthorized_keys
for SSH
Init Containers Added
remote-dev-work
: a container which will initialize theremote-dev-work
volume by copying the code from the main container into theremote-dev-work
PersistemVolumeClaim
(only if the volume is empty)remote-dev-work-permissions
: a container which sets the correct permissions on the folders within theremote-dev-work
volumeremote-dev-bin
: a container based on a Bunnyshell image (bunnyshell/remote-binaries
) containing the binaries needed for Bunnyshell; will mount the volumeremote-dev-bin
, which will copy the files in the target container in/opt/bunnyshell/bin
Probes
Since the development containers usually don't start the processes same as production/staging ones the Kubernetes probes livenessProbe
, readinessProbe
and startupProbe
are removed (overwritten with null).
Command
The command is overridden for the target container, into /opt/bunnyshell/bin/start.sh
: this will start the SSH server and if in file sync mode, will also install the Mutagen agent .
Also, some additional labels are added on the Pods
, ReplicaSet
and Deployment
:
remote-dev.bunnyshell.com/active: true
remote-dev.bunnyshell.com/service: {COMPONENT_NAME}
as well as some annotations:
remote-dev.bunnyshell.com/container: {CONTAINER_NAME}
remote-dev.bunnyshell.com/started-at: '{TIMESTAMP}'
Additionally, to be able to restore the Pods to their previous state after a Remote Development session ends, the ReplicaSet
has the previous manifest saved as text in an annotation:
remote-dev.bunnyshell.com/rollback-manifest: {"metadata":{"name":"frontend","namespace":"env-2nhc3f","creationTimestamp":"2022-11-01T14:09:20Z","labels":{"app.kubernetes.io/instance-f...
and some annotations are added on the Deployment
:
remote-dev.bunnyshell.com/container: frontend
remote-dev.bunnyshell.com/rollback-manifest: {"metadata":{"name":"frontend","namespace":"env-2nhc3f","creationTimestamp":"2022-11-01T14:09:20Z","labels":{"app.kubernetes.io/instance-f...
remote-dev.bunnyshell.com/started-at: 1667577628
Explore the topics below to get a complete understanding on Remote Development in Bunnyshell, and learn how you can make the most of it.
Updated about 1 year ago