Team Development with Okteto

This section shows how to use Okteto to allow your development team to simultaneously collaborate in the same Kubernetes cluster and work with the entire application directly in the cloud. With this, Okteto allows your team to:

  • Increase your productivity through faster iteration.
  • Eliminate the need to mock up dependencies or duplicate resources.
  • Onboard new developers faster.
  • Improve collaboration across development teams as well as the teams you work with.
  • Give your team self-service access to your Kubernetes clusters.
  • Minimize your local machine setup and resources.

This guide uses the Movies app as an example, a multi-service application that exposes the following services:

  • A React based front-end, using webpack as bundler and hot-reload server for development.
  • A very simple Node.js API using Express.
  • A MongoDB database.

Prerequisites

This examples assumes that you’ve already installed Okteto CLI and that you have completed at least one of our sample guides. If not, we recommend you to read our Getting Started guide before continuing.

Step 1: Create a new namespace

Login from Okteto UI at https://cloud.okteto.com. Once inside, you will find the namespaces explorer on your left side. Click the “+” button and type movies as your new namespace in the dialog and then click the Create button.

You now have a new and isolated Kubernetes namespace where you can directly deploy and develop your new multi-service app.

Step 2: Deploy the Movies multi-service app

Make sure you are logged in from the Okteto CLI. In your terminal launch okteto login to initialize your Okteto account:

1
$ okteto login

Run the namespace command to easily change your Kubernetes context and configure your newly created namespace:

1
$ okteto namespace movies-{your-username}

All namespaces have the owner’s username as a suffix to avoid collisions and help identify shared namespaces.

Clone the samples repository:

1
2
$ git clone https://github.com/okteto/samples
$ cd samples/node

Now that your Kubernetes context is properly set, run the Movies app in your new namespace by executing:

1
$ kubectl apply -f manifests
1
2
3
4
5
6
deployment.apps/movies-api created
service/movies-api created
deployment.apps/movies-frontend created
service/movies-frontend created
service/mongo created
statefulset.apps/mongo created

If you don’t have kubectl installed, follow this guide.

Step 3: Frontend environment in development mode

Imagine that you are in charge of the development of the UI side of a new feature. Let’s set up your frontend deployment in development mode in order to work directly in the cloud:

1
$ cd frontend

From the frontend’s root directory, launch the following command:

1
$ okteto up
1
2
3
4
5
$ okteto up
✓ Okteto Environment activated
✓ Files synchronized
✓ Your Okteto Environment is ready
Name: movies-frontend

Once the Okteto Environment is ready, the Okteto Terminal will automatically open. Use it to run your frontend with the same flow you would have locally:

1
okteto> yarn start

This will compile and run webpack-dev-server listening on port 8080. The frontend of your application is now ready and in development mode. You should be able to access it at http://localhost:8080.

Step 4: Share your namespace

Okteto allows you to develop directly in the cluster synching all changes to your local filesystem with the remote environment.

Imagine that your teammate Cindy is in charge of the backend and your frontend implementation depends on API changes from her. A common flow to collaborate with her would be:

  1. Work on the frontend and mock responses from the API to match the requirements.
  2. Wait until Cindy’s changes are ready and committed to her branch.
  3. Pull changes from Cindy’s branch.
  4. Build API docker image.
  5. Run API docker image.
  6. Test

To be realistic, now that you are finally able to test everything end to end, you’ll probably find a few bugs in your implementation. Great that Okteto makes it super fast to develop and keep testing it with all the app’s dependencies.

But what if you find bugs in Cindy’s implementation? After telling Cindy and wait for her changes, the flow would repeat itself (pull, build, run, test…).

With Okteto you can allow multiple team members to work on the same cluster where they share the same resources. You could then access Cindy’s API before any code is committed and eliminating the docker build/push/pull/redeploy cycle.

Go back to the Okteto UI and select the new namespace you just created (movies-{username}). You’ll find the Share button in the main bar at the top.

In the Share dialog, type the email address of the team members you want to share this namespace with. Following our hypothetical case, we would type `[email protected]`.

At this point Cindy will be able to configure her Kubernetes context to use your shared namespace and access its resources.

Cindy’s side

Cindy step 1: Switch Kubernetes namespace and context

Cindy just needs to switch to your shared namespace using the namespace command:

1
$ okteto namespace movies-{yourusername}

Cindy step 2: API environment in development mode

Since Cindy is now working on your shared namespace, everything is already deployed and ready. Let’s enable development mode in the API environment and so she can start working.

From the api/ directory of the cloned samples repository, Cindy just needs to launch:

1
$ okteto up
1
2
3
4
5
$ okteto up
✓ Okteto Environment activated
✓ Files synchronized
✓ Your Okteto Environment is ready
Name: movies-api
1
2
3
4
5
6
7
8
9
10
11
yarn run v1.16.0
$ yarn install && nodemon server.js
[1/4] Resolving packages...
success Already up-to-date.
[nodemon] 1.18.9
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node server.js`
Connected to mongodb://mongo:27017
preloading data
Server running on port 8080.

Cindy step 3: Make changes to the API

Cindy can now change the API code. If you are following this guide with a another user, open api/data/movie.json and modify the Kung Fu League title on line 8 to Kung Fu Panda. Save the file.

1
2
3
4
5
6
7
8
{
"id": 27,
"page": 1,
"results": [
{
"id": 346910,
"vote_average": 5.3,
"original_title": "Kung Fu Panda",

Back to your side

Step 5. Test Cindy’s changes

Go back to your browser and access the frontend again at http://localhost:8080. Notice how Cindy’s changes are instantly applied. No commit, build or push required 😎!

Next steps

You now know the advantages of collaborating with your team in the same cluster. Okteto helps you accelerate iterations and boost your team’s productivity!

Start using Okteto in your projects today, it is as simple as adding an okteto.yml manifest in your repository.

Improve your team’s Kubernetes and Docker development workflows with Okteto Enterprise. Schedule your demo today!