Making K8s Simpler for Developers using KubeVela
Is there a way for us to make k8s simpler for the developers? Developers want to focus on what’s important - which is coding their app. But they should also have the ability to deploy and expose it to K8s without asking help from Operators, so that it will not interrupt their workflow.
Working with K8s is not the easiest thing. Yes, it makes deployment, scaling, and managing of application easier. But to do these, you have to learn a lots of things. To deploy your single stateless application, you need to know how Deployments, Services, ConfigMaps, and Secrets are working. To expose your application, you need to deal with Ingress or Gateway + Virtual Service depending on how your cluster is setup.
All of these are overwhelming. So for DevOps engineers, is there a way to improve their experience working with K8s?
And the answer is yes! We can do that using KubeVela, an implementation of OAM(Open Application Model).
What is the Open Application Model?
OAM is an open source specifications and provides a higher level of abtractions for deploying cloud native apps on top of hybrid and multi-cloud environment. It can be described using the following principles:
- Defined the app deployment in a self-contained model, free of the platform details.
- It is modular and extensible. Write it to a deployment plan depending to your needs.
- It is runtime agnostic. It should work on k8s, cloud or even IoT.
Using OAM, we can create an abstraction that can help developers deal with platform complexity.
KubeVela in action
Pre-Requisites
- A running K8s cluster with Ingress configured, check how I set up mine using KinD here.
- KubeVela CLI and Core - read here to learn more on how to install KubeVela CLI and Core.
Let’s say you want to deploy a simple application and expose it to public. To do that, you need the Deployment, Service, and Ingress manifest sorted out. Mind you, these manifests is as simplest as it can get.
1 | apiVersion: apps/v1 |
Once you applied these manifests, you can access your app at http://localhost/. Delete the app deployment before proceeding to the next step.
Note: When I say “applied”, I mean kubectl apply -f app.yaml. And when I say “delete”, I mean kubectl delete -f app.yaml.
But if you’re going to deploy it using KubeVela, you’ll just need this:
1 | apiVersion: core.oam.dev/v1beta1 |
Once applied, this Application manifest will handle the creation of the Deployment, Service, and Ingress resources. And your app will be accessible at http://localhost/. Neat, right?!
But what if you want to do a URL rewrite on the ingress? That is not possible with the current gateway trait the we have.
Note: Later we will discuss parts of KubeVela deployment Plan - like Component, Trait, Workflow, and Policy.
Don’t worry, Kubevela is extensible. We can create our own version of the gateway trait and tweak it so that it can accommodate such customizations.
Here’s our TraitDefinition for our new trait. Apply it:
1 | apiVersion: core.oam.dev/v1beta1 |
Note: This trait is defined using cue, read here to learn more about cue.
Now, we can attach our new trait to accommodate URL rewrite to our other webservice.
1 | apiVersion: core.oam.dev/v1beta1 |
After applying it, you can now access the hello-whale app at http://localhost/foo. This webservice is now using the new trait that we’ve created. If we’re using the old “gateway’” trait, we’ll get a 404 since this webservice can only accomodate traffic coming from “/“.
Here, I showed a very simple deployment plan and glipse of KubeVela’s extensibility where I’ve created a trait that fits my needs. But it does not stop there. You can also do this for the other parts of KubeVela.
Parts of KubeVela
KubeVela’s deployment plan consists of four parts: Component, Trait, Workflow, and Policy.
- Component - the application artifact to be deployed.
- Trait - the operations that you can attach to your components, like gateway, scaler, DNS, etc.
- Workflow - the crucial steps on the application delivery process, like manual approve, release across multi-cluster, notification, etc.
- Policy - defines a strategy for certain aspects of the application like quality assurance, security, firewall rules, SLO, etc.
Note: Read here to learn more on how to use Workflow and Policy.
Using KubeVela, we as DevOps engineers, can hide the complexity of K8s while exposing to the devs what they need to work with k8s.
If you want to learn more about OAM visit their site, and for Kubevela check here.
Check here for more samples of KubeVela components.
And that’s all I have for you about OAM and KubeVela. Thank you! :)