Open Application Model (OAM) — Bringing some sanity to application deployment on kubernetes (k8s).
Virtual machines, docker, vagrant, severless, Faas platforms, I thought they are cool and powerful and in some ways they are! However over a year ago I have been constantly working with k8s and its alway been alot of fun coverging some of the tools and platforms mentioned above, but also accompanied by some frustrations to deploy and manage applications on K8s ( Yes thats right, frustrations!).
Focused on application rather than container or orchestrator, Open Application Model [OAM] brings modular, extensible, and portable design for modeling application deployment with higher level yet consistent API.
This is the key to enable simple yet robust application delivery across hybrid environments including Kubernetes, cloud, or even IoT devices.
K8s with all it goodies can quickly get overwelming when it comes to managing or deploying applications and sometimes I say to myself “I just hate YAML files!”
I found few tools very useful when working on k8s over the last 6 months, I will talk about some of them in this post and still try to keep to the subject.
- Lens https://k8slens.dev/
The begining of my kubernetes journey is all helm, kubectl, lots of yaml and other cli tools and I wish I knew about this tool earlier. Anyways, managing workload, Configurations, Network, helm install, clusters and many more has been a bliss. I still use cli tools but lens definitely makes me more productive, you should check it out.
Lens is the most powerful Kubernetes IDE on the market. It is a standalone application, and it is available on macOS, Windows, and Linux. Kubernetes Lens is an effective, open-source IDE for Kubernetes.
Lens simplifies working with Kubernetes by helping you manage and monitor clusters in real time. It was developed by Kontena, Inc. and then acquired by Mirantis in 2020, who then open-sourced it and made it available to download for free.
2. Kubevela https://kubevela.io/
After my encounter with Lens, I have been in search for a tool to ease deployment nightmares and I found Kubvela, it looks promising so far.
Kubvela is an open source application delivery platform which uses Open Application Model (OAM) to abstracts away the complicated Kubernetes artifacts from Platform builders and developers and make deploying and operating application hybrid, multi-cloud environments easier, faster and more reliable.
Now enough of introductions lets deploy something with kubevela! or better let velalize an application as an example :-).
Prerequisites: setup local kubernetes cluster, install kubevela on it and install Lens. Do not foget to install vela cli, to confirm that it is intalled run
$ vela version
CLI Version: v1.3.0
Core Version: 1.3.0
Then I need to install all python requirements for this app
pip install flask hashids
when install above is sucessfull, create the requirements.txt file with
pip freeze >> requirements.txt
And oh you need to create a file called Dockerfile at the root of the project with the content below;
# syntax=docker/dockerfile:1FROM python:3.8-slim-busterWORKDIR /python-dockerCOPY requirements.txt requirements.txt
RUN pip3 install -r requirements.txtCOPY . .CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
and then build the image
docker build --tag shortener-docker .
Push the image to your registry
docker push <your docker id>/shortener-docker
Now lets velalize this app! first of all let us create a yaml file called shortener.yaml with content below;
Note: please replace image “sejuba/shortener-docker” with the image name you just built above.
- name: urls-shortener-service
- type: gateway
run command vela up -f shortener.yaml and you should get results similar to below;
For our app to work we need to run DB initialization script from inside our container, vela provides a cli that allows us to achieve that without sweat plus some other cli goodies;
vela exec urls-shortener-service -- python init_db.py
If you launch your Lens IDE and connect to your cluster you should be able to see the service. lens allows you to portforward with a click and viola, you should be able to access our new url shorner app.
Now if you go to http://localhost:5000/ you should be able to see our new app, assuming you portforwarded to port 5000.
Kubevela also comes with a ui called velaxux for managing and deploying services, for more details on velaux and cli check https://kubevela.io/docs/. Deploy and manage your apps stress free and happy vela-ing :-)