Develop cloud native Kubernetes Java applications on Okteto Cloud
Introduction
In this post, I'll show you how to set up your Spring Boot Java project for inner loop development on top of Okteto Cloud Kubernetes. For this purpose, I'll be using Eclipse JKube's Kubernetes Maven Plugin to create the container image and deploy it to our development environment.
Requirements
The first and most important requirement is to have an Okteto account. If you have a GitHub account, this is as easy as logging in to cloud.okteto.com using GitHub. What I like best about this platform is that it doesn't require a Credit Card to get started.
Kubernetes Access
To be able to deploy to our development cluster, we'll need to configure the access credentials. Okteto provides a very simple mechanism for this. You just need to download the customized .kube/config
file, and set up your current console environment:
MacOS/Linux
export KUBECONFIG=$HOME/Downloads/okteto-kube.config:${KUBECONFIG:-$HOME/.kube/config}
Windows
$Env:KUBECONFIG=("$HOME\Downloads\okteto-kube.config;$Env:KUBECONFIG;$HOME\.kube\config")
If you have logged in to your Okteto account, you can download the file from your dashboard.

Container Registry
Okteto has its own container registry. This allows every Okteto namespace to have a private registry to store its container images. Since we are setting up the project for the inner loop, it's interesting to make use of this feature.
The easiest way to authenticate without persisting the credentials in the project or the environment is by using the docker cli to log in to the registry.
docker login registry.cloud.okteto.net
The username is the email associated with your Okteto account, or your GitHub username.
For the password, you'll need to generate an Okteto Personal Access Token which you can generate from your dashboard.

Project setup
We can now easily configure our project to be Okteto friendly.
Kubernetes Maven Plugin
If your project is not using Kubernetes Maven Plugin, or even if it's already using it, you will need to add the following configuration to the plugin section:
1<plugin>
2 <groupId>org.eclipse.jkube</groupId>
3 <artifactId>kubernetes-maven-plugin</artifactId>
4 <version>1.14.0</version>
5 <configuration>
6 <resources>
7 <annotations>
8 <service>
9 <property>
10 <name>dev.okteto.com/auto-ingress</name>
11 <value>true</value>
12 </property>
13 </service>
14 </annotations>
15 <imagePullPolicy>Always</imagePullPolicy>
16 </resources>
17 </configuration>
In line 15, we are specifying an Image Pull Policy of Always
. Since we are developing for the inner loop, and the project has a -SNAPSHOT
version, JKube automatically tags the generated container image with latest
. This configuration forces Okteto/Kubernetes to always pull a fresh version of the container image. This way, any changes you perform during your iterative development loop, will be reflected in the deployed version of the application.
In lines 7-14 we are adding an Okteto specific annotation to the service.
Following are the required changes to the properties section:
1<properties>
2 <jkube.generator.name>
3 registry.cloud.okteto.net/your-namespace/jkube-okteto-demo
4 </jkube.generator.name>
5</properties>
To be able to use Okteto's container registry, we'll need to setup a specific name for our image. In the project properties, we need to set an image name for the registry.cloud.okteto.net
registry, and our namespace. You need to replace your-namespace
, with the namespace for your user.
Deploying the application
We are now ready to deploy the application. Provided that you have set up your environment as specified in the Kubernetes Access section, you can now deploy the application by running:
mvn clean package k8s:build k8s:push k8s:resource k8s:apply
Your deployment should now be visible from your dashboard:

Once the Pod is started, we should be able to cURL the exposed endpoint:
$ curl https://jkube-okteto-your-namespace.cloud.okteto.net/
Hello Okteto!
Since we are using JKube, all of the developer specific goals such as debugging (k8s:debug
), retrieving the logs (k8s:log
), etc. should be available.
Conclusion
In this article, I've shown you how to set up a Java Maven project for inner loop development on Okteto Cloud Kubernetes with Eclipse JKube's Kubernetes Maven Plugin. Being able to develop and test your cloud native application in a remote cluster is fundamental these days. As you can see, JKube provides a very easy way to achieve this.
You can find the full source code for this post at GitHub.
References
- Okteto Cloud Documentation: Download your Kubernetes credentials
- Okteto Cloud Documentation: Okteto Registry
- Kubernetes Maven Plugin documentation