Have you ever wondered how to achieve greater agility and efficiency in multi-cloud development while minimizing overheads? In a time where businesses are increasingly striving for agility and scalability, the demand for efficient development practices in multi-cloud environments has never been more critical.
This is where Codezero can help. Codezero was launched to help revolutionize the development experience by providing a collaborative overlay environment where developers can seamlessly interact with their colleagues' work-in-progress code locally. This approach eliminates the need for extensive deployments, allowing for efficient testing, resulting in higher-quality code with fewer issues, all while seamlessly integrating with your existing software and infrastructure. (For a 3-min overview of the concepts, watch "Codezero: How It Works").
Through this tutorial, we explore a sample project that will show you how to utilize Codezero to greatly accelerate and enhance the Kubernetes development experience. This is based on a webinar we held last year where we spoke with Narayan Sainaney, CTO at Codezero, about the evolution of DevOps with modern tooling. You can watch the recording of this webinar here for more information on this tutorial.
Prerequisites
This tutorial assumes some familiarity with Kubernetes. In addition, you would need the following:
Sample project setup
In this section, we'll take a closer look at the sample project used in the demo and how Codezero simplifies accessing services within a Kubernetes cluster.
The demo showcases a sample project that represents a typical modern application. This sample project includes various components, such as:
- Front End: A single-page web app deployed to a platform like Vel or directly from Codezero.
- API Endpoints: Backend APIs that serve data to the front end and have inter-dependencies to illustrate complex service graphs.
- Internal Websockets: Internal communication using websockets.
- Internal REST Services: RESTful services for specific functionalities.
- Database Traffic: Interaction with a database tier.
Codezero provides a repo with Kubernetes manifests we can use to deploy the sample project. In a directory of choice, clone the sample repo:
git clone https://github.com/c6o/sample-project.git && cd sample-project
Create a namespace:
kubectl create ns sample-project
Deploy the sample application:
kubectl apply -n sample-project -f ./k8s
Set up Ingress to expose the front-end of the sample application using:
kubectl -n sample-project apply -f ./k8s/loadbalance/frontend.yaml
The command above exposes the sample-project-frontend
deployment as a service with a ClusterIP
and exposes port 80.
Codezero Quickstart
For this demonstration, we will need to sign up for a free account using the Codezero Hub. The onboarding wizard will guide you through creating an organization and your first Teamspace.
Install Codezero in your Cluster
After creating your teamspace you need to install the Codezero Space Agent. Click on Helm Install to copy the Helm install string. This install command is unique to your cluster. It includes a one-time token that is used to certify the Teamspace.
The Helm command will look something like this:
helm repo add --force-update codezero https://charts.codezero.io helm install --create-namespace --namespace=codezero --set space.token= codezero codezero/codezero
After running the Helm install command you should see the Certification column change to Certified and shortly thereafter, you should see an IP address or Host Name show up under DNS. At this time, your Teamspace is ready for use.
Install the Codezero CLI
To install Codezero via the command line, run the following command in your terminal:
curl -L https://releases.codezero.io/install-headless.sh | /bin/bash
Once installed, log in to your Codezero account by running:
czctl auth login
Finally, we need to start the Codezero daemon by running:
czctl start
To verify that the Codezero daemon is running, type:
czctl status
Your output should be similar to:
Full details for using the Codezero CLI are here: https://docs.codezero.io/guides/using-cli/
Navigate to your Service Catalog
One of the key features of Codezero is its ability to simplify access to services within a Kubernetes cluster. In this section, we'll learn how to use Codezero to access these services without the need for additional configurations.
Accessing Services
One of the major challenges when working with microservices on Kubernetes is service networking and exposing services. A good example of this is working on a microservice that is deployed to a remote Kubernetes cluster. In this scenario, the developer would need to either expose their application via an Ingress controller or create a port-forward to access the service and view changes locally. This process can be cumbersome and time-consuming for those unfamiliar with kubernetes, especially when dealing with multiple services or frequently making changes.
Codezero simplifies this process with its "consume" feature. This feature allows developers to interact with a remote service locally, accessing the service as if it were running on their machine.
From your terminal, run the following command to consume all the services within the sample-project
namespace:
czctl consume edit --primary-namespace sample-project
Enter sample-project/*
, save and exit the editor to consume all services from the sample project.
Your output should be similar to:
Once you are consuming all the services in the namespace, you can now access the front end of the sample application as if it were running locally. In your browser of choice, navigate to http://sample-project-frontend
, you should land on the following web page:
Recalling that Codezero requires ⚠️ sudo access to make modifications to the hosts file on your machine, you can view the modifications in real-time by running the following terminal command:
watch cat /etc/hosts
Your output should be similar to:
For each service in the sample-project
namespace, Codezero has created a local entry to make as it simple to work with remote resources as if they were running locally.
Codezero Hub - GUI interface
If you prefer a GUI over the command line, Codezero has you covered - the Codezero Hub https://hub.codezero.io allows you to consume and serve in-cluster services with the click of a mouse. Using the GUI, select the Teamspace from the Teamspace List in the top left corner of your browser window. This will take you to the Service Catalog:
When you are done your work, you can stop consuming resources using:
czctl cleanup
This will stop the Codezero daemon and restore your network to its previous state. Your output should be similar to the following (and your hosts file should return to default):
Summary
Developing microservices applications on Kubernetes can be challenging, especially when it comes to seamlessly working across local and remote environments. Codezero's collaborative development approach using a secure overlay network to shape traffic solves this problem by bridging the gap between local development and remote deployment, empowering developers to spend more time iterating on their applications instead of grappling with networking and configuration challenges.
If you’re looking to explore more about streamlining your development process, take a look at these resources:
- Codezero can also let you serve your local service easily to your shared Teamspace for collaborative testing.
- In case you missed it, here is a link to the webinar with Narayan Sainaney, CTO at Codezero.