Upgrade your development workflow: Use DevSpace instead of Docker

Upgrade your development workflow: Use DevSpace instead of Docker

·

4 min read

In the fast-paced world of software development, keeping an efficient workflow is crucial. Local Docker setups often face challenges like high resource use, complex configurations, and differences between development and production environments. These issues can slow productivity and make team collaboration harder. Enter DevSpace, a powerful tool designed to improve your development workflow by using Kubernetes. In this article, we will explore why moving from local Docker to DevSpace can greatly enhance your development process, offering a more streamlined, scalable, and collaborative approach.

The limitations of local Docker development

Docker has transformed how developers build and run applications, but it goes along with several challenges:

  • Resource Consumption: Local Docker environments demand significant CPU and memory resources, often leading to sluggish machine performance, especially with multiple containers or resource-intensive applications.

  • Configuration Complexity: Setting up and maintaining local Docker configurations can be time-consuming and error-prone. Making sure all dependencies and environment variables are correctly set up for different projects can cause conflicts and inconsistencies.

  • Environment Inconsistencies: Differences between local and production environments can cause applications to behave differently, leading to the "it works on my machine" problem.

  • Collaboration Difficulties: Setting up the same environment on every team member's machine can be hard, causing differences and wasted time fixing issues.

These limitations underscore the need for a more robust solution like DevSpace, which addresses these challenges and streamlines the development workflow.

What is DevSpace?

DevSpace is an open-source tool designed to enhance and simplify development workflows by leveraging Kubernetes. It enables developers to deploy applications directly into Kubernetes clusters, ensuring consistency and reliability between development and production environments.

The key benefits of using DevSpace are:

  • Improved Resource Management: Offload your development environment to a Kubernetes cluster, enabling you to develop applications efficiently even on a low-powered PC.

  • Streamlined Collaboration: Provides a shared development environment, making it easier for teams to work together.

  • Faster Iteration Cycles: Real-time synchronization and hot-reloading allow for quicker testing and development.

  • Seamless CI/CD Integration: Facilitates automated testing and deployment, integrating smoothly with existing CI/CD pipelines.

  • Simplified Development Experience: Use the built-in UI to effortlessly stream application logs, monitor all containers, and utilize the convenient 1-click port-forwarding feature.

Getting started with DevSpace

DevSpace is a super lightweight client-only binary, which does not require any server-side component.

💡
Make sure you already have kubectl and your cluster configuration ready and working

Installation
Depending on your system, please read the official installation guide.
Mac (Homebrew) example: brew install devspace

Initialize a Project (Golang example)

git clone https://github.com/loft-sh/devspace-quickstart-golang
cd devspace-quickstart-golang

Run devspace init and follow the provided steps to get started with your project. If finished successfully you should now have the following files/folders in your project:

  1. New file devspace.yaml --> General DevSpace configuration file

  2. New file devspace_start.sh --> used when you use a terminal inside your dev container

  3. New folder .devsace/ --> Cache for DevSpace to store some information locally. Should be added to the .gitignore file

A detailed reference for the devspace.yaml file can be found here: https://www.devspace.sh/docs/configuration/reference

Start development

This is your starting point for daily work and launching your application. Before we begin, we need to make sure that DevSpace is using the correct namespace.

Run devspace use namespace <your-namespace> to configure this. You can optionally execute devspace use context <your-context> to switch to a different Kubernetes cluster.

To deploy your project and start the dev container please run devspace dev. This will execute the defined dev pipeline in your devspace.yaml and will execute the defined steps.
Depending on your configuration you might need to start your application manually. In our example project, a terminal session should be opened automatically and you can run go run main.go to start your application

When you executed devspace dev the DevSpace UI is started by default in the background and you can open it under localhost:8080. Optionally you can run it manually with devspace ui

Troubleshooting

If you encounter any issues with your DevSpace environment try the following:

  • Run devspace purge to remove your deployments from the cluster

  • Delete the local .devspace/ folder

For more information about cleanup see here: https://www.devspace.sh/docs/getting-started/cleanup

Conclusion

Switching from local Docker environments to DevSpace can significantly enhance your development workflow. By leveraging Kubernetes, DevSpace ensures that your development and production environments are aligned, reducing the "it works on my machine" problem and enhancing overall productivity.

Visit the DevSpace documentation to get started, join the vibrant DevSpace community to share your experiences, and explore additional resources. Try it now and see the difference for yourself!