While odo is mainly focused on application developers who would like to care less about Kubernetes and more about getting their application running on top of it, it also tries to make things simple for application architects or devfile stack authors who are comfortable with Kubernetes. One such feature of odo that we will discuss in this guide is creation of Kubernetes resources like Pods, Deployments, Services (Kubernetes Services, not the Operator backed ones) and such using odo. Using this, if an advanced user would like to create some Kubernetes resources, they could edit the
devfile.yaml and add it there. An
odo push after the edit would create the resource on the cluster. A resource thus created would co-exist with an odo component.
In this guide, we will create an nginx Deployment using its Kubernetes manifest. We will write this manifest in the
devfile.yaml. Upon doing
odo push, you will be able to see a Deployment and its Pods along with the component on the Kubernetes cluster using
As with other resources like URL, Storage and Services, to create a Kubernetes resource, we first need to have an odo component. We will keep it simple by using a nodejs starter project. In an empty directory, create a component using:
Reference the Deployment manifest in
odo supports referencing a URI in the
devfile.yaml so that you don't have to copy the entire manifest into it. Assuming you have a Deployment manifest like below stored in a file called
Add below to the
components section in
devfile.yaml. Note that there is already a
runtime component in this section:
Now you need to do
odo push. odo will create the component and also the nginx deployment for you on the cluster. Note that, unlike for Operator backed service, odo won't show you any message indicating that a service or some resource was created on the cluster. This is by design because the feature is meant for advanced users who can play with resources created in this way through
kubectl CLI. However, if odo fails to create a resource, it will error out and let you know about it.
See if the Deployment and its Pods were created on the cluster using:
odo adds a Kubernetes label to the resources created in this way. It is
app.kubernetes.io/managed-by: odo. odo also sets the
ownerReferences for such objects to the underlying odo component so that when you do
odo delete, such resources are deleted from the cluster. Other than that, odo doesn't help in managing such resources and users are expected to know how to do so.