Develop your Application in Okteto Cloud

This tutorial will show you how to use Okteto to develop your applications in Kubernetes. Okteto lets you code locally and see the results instantaneously in Kubernetes, the Cloud Native way.

If you haven’t deployed your first application in Okteto Cloud, we recommend that you first complete our 5-minute getting started guide, since this guide depends on having the sample application deployed in Okteto Cloud.

Step 1: Install the Okteto CLI

The Okteto CLI keeps your code synchronized between your local machine and the containers running your application. See your changes live in Kubernetes without having to rebuild images and redeploy containers!

The Okteto CLI is open source, and the code is available at Github. Check it out and star it to show your support 🤗!

Install the Okteto CLI by running the following command in your local terminal:

MacOS/Linux:

1
$ curl https://get.okteto.com -sSfL | sh

Windows:

1
$ wget https://downloads.okteto.com/cli/okteto-Windows-x86_64 -OutFile c:\windows\system32\okteto.exe

Step 2: Create your Development Environment

Open a terminal, and navigate to the folder where you cloned the sample application’s code. Once you’re there, run the okteto up command to create your development environment:

1
$ okteto up
1
2
3
4
5
6
7
8
 ✓  Persistent volume provisioned
✓ Files synchronized
✓ Okteto Environment activated
Namespace: cindy
Name: hello-world
Forward: 8080 -> 8080

okteto>

Your development environment is now ready. The okteto up command executes the following tasks:

  • Update your application container with the docker image okteto/golang:1. This image contains the required dev tools to build, test and run the sample application. Enjoy the advantages of having development environments as code.
  • Create a bidirectional file synchronization service to keep your changes up-to-date between your local filesystem and your remote containers. Moving diff of code through the internet is way faster than moving Docker layers.
  • Start a terminal into the remote container. Build, test and run your application as if you were in your local machine.

Now run your application by executing the following command:

1
2
okteto> go run main.go
Starting hello-world server...

Open your browser and go to the URL of the application to test it.

You can get the URL by logging into Okteto Cloud and clicking in the application’s endpoint.

Step 3: Develop your application in Kubernetes

Edit the file main.go and replace the word cluster with Okteto Cloud on line 23. Save your changes.

1
2
3
4
5
...
} else {
fmt.Fprint(w, fmt.Sprintf("Hello from the cluster namespace '%s'", namespace))
}
...

Cancel the execution of go run main.go by pressing ctrl + c. Rerun your application:

1
2
okteto> go run main.go
Starting hello-world server...

Go back to the browser, and reload the page. Notice how your changes are instantly applied. No commit, build or push required 😎.

Congratulations, you just developed your first application in Okteto Cloud 🚀.

Okteto helps you move your entire development workflow to Kubernetes. This way you can:

  • Eliminate integration issues by developing the same way your application runs in production.
  • Uninstall Docker or Minikube. No more cpu cycles wasted in your machine.
  • Hardware and network just limited by the power of the cloud!
  • Your development endpoints are always available. No need to expose your local machine to the internet through remote tunnels.

Step 4: Cleanup

Cancel the okteto up command by pressing Ctrl + C + Ctrl + D and run the following commands to remove the resources created by this guide:

1
$ okteto down -v
1
2
✓  Okteto Environment deactivated
✓ Persistent volume deleted
1
$ kubectl delete -f manifests
1
2
deployment.apps "hello-world" deleted
service "hello-world" deleted

Next steps

Your next step is to deploy and develop your own application in Okteto Cloud.

Notice the okteto.yml file in the sample folder? Okteto uses that manifest to determine the name of your development environment, the docker image to use and where to upload your code. Check the Okteto manifest docs to customize your development environments with your own dev tools, images, and dependencies.

Visit our samples section to learn more about developing and deploying applications with Okteto Cloud.

Got questions? Join the conversation in our Kubernetes Slack channel! If you don’t have a Kubernetes slack account yet, sign up here. We’d love to hear from you 😄.