While exploring Jenkins X features, including the amazing pre-assembled GitOps workflow to automatically manage application deployment to staging environment, then pull-request based promotion to production, I had a strange feeling: Jenkins X for sure can manage, in a clever way, a whole continuous delivery process, but how does it help me as a Developer ?
Let me explain: Jenkins X's mission is to offer “a CI/CD solution for modern cloud applications on Kubernetes.” And yes, it helps me get CI/CD implemented nicely for my Kubernetes app, but I still need to work hard to get a development environment up and running so I can work on my application with required dependencies. Considering I’m working on a NodeJS application, I still need to install them both on my machine, ensure I’m running the right version as defined in my Dockerfile (or Jenkins X build pack), manage port exposure and all sort of initial setup before I can even start doing some concrete stuff.
But guess the good news? Here again, Jenkins X can help us.
In an ideal world, the cloud deployment configuration used to run application should be replicated as-is on my developer workstation, to enforce I’m running the exact same environment. The other option would be to host my development environment on the target Kubernetes cluster. This is exactly what DevPod is about. A DevPod is a special flavor of an application’s environment, extended to include development tools. Better use a concrete sample to demonstrate.
Here I’m using the Jenkins X node-http quickstart , a very basic skeleton for NodeJS application serving a simple html file. For sure I could get node and npm setup on my machine, but let’s say I’m lazy and would better ask Jenkins X to prepare a development environment for me. (Actually I’m a lazy developer, so this is not just a hypothetical scenario)
➜ (master ✗) demo jx create devpod ? Pick which kind of DevPod you wish to create: nodejs Creating a DevPod of label: nodejs Created pod nicolas-nodejs - waiting for it to be ready... Updating Helm repository... Helm repository update done. Pod nicolas-nodejs is now ready! You can open other shells into this DevPod via jx create devpod You can edit your app using Theia (a browser based IDE) at https://nicolas-nodejs-theia.jx.timey-wimey.io You can access the DevPod from your browser via the following URLs: * https://nicolas-nodejs-port-3000.jx.timey-wimey.io * https://nicolas-nodejs-port-8080.jx.timey-wimey.io * https://nicolas-nodejs-port-9229.jx.timey-wimey.io Attempting to install Bash Completion into DevPod Defaulting container name to nodejs. Use 'kubectl describe pod/nicolas-nodejs -n jx' to see all of the containers in this pod. Generated Git credentials file /home/jenkins/git/credentials Cloning into 'demo'... Checking connectivity... done. [root@nicolas-nodejs demo]#
What happened?
Jenkins X created a nicolas-nodejs pod on my Jenkins X cluster. This pod is running two containers : one based on jenkinsxio/builder-nodejs docker image, designed to match my NodeJS quickstart’s environment. The other one is running Theia web IDE . Depending on the selected runtime, DevPod could include more relevant tools in such side containers. Once pod is fully setup, I get a console connected into my DevPod container, with a local clone of the git repository, ready to hack on my app.
Let’s open the suggested URLs:
- On nicolas-nodejs-port-3000 I get Theia IDE, which I can use to hack on my JavaScript code and HTML static file.
- On nicolas-nodejs-port-8080 I would expect to get my application, but I first need to start it. As I’m running in development mode, I will use a live-reload enabled server so I don’t need to hit refresh key on my browser. This isn’t installed by default, so let’s just add the adequate tool for it. Maybe I missed something. Could be fixed in builder-nodejs anyway, feel free to make a pull-request :P
[root@nicolas-nodejs demo]# npm install -g live-server
And now, let’s start the app
[root@nicolas-nodejs demo]# live-server
And here we go: I have my development environment setup, fully hosted on my Kubernetes cluster, and can hack the code just like I would do on my workstation, without having to worry about installing stuff.
Important note: whenever I pretended to be one here, I’m clearly not a Javascript developer. My JavaScript skills are limited to some basic JQuery hacks . If you feel such a setup is missing some major component for realistic NodeJS development, let me know on #jenkins-x-user, or create issues/pull-requests on jenkinsxio/builder-nodejs repository!
Additional resources
- How to install Jenkins X
- What serverless Jenkins with Jenkins X
- Read why one user migrated to Jenkins X