Photo by Shahadat Rahman on Unsplash
Guide on migrating open-source applications OAM with Napptive
Get started right now!
"Open Application Model (OAM) is like a blueprint for building cloud-native applications - it provides a clear and standardized way to describe and manage application components, making it easier to build and maintain complex systems in the cloud." ~ ChatGPT
Even ChatGPT!
Even ChatGPT has recognized the potential and capabilities of the Open Application Model (OAM) in the Cloud-native space. (Don't worry, this article is not written by ChatGPT though.... is it?)
I have been publishing a couple of articles on OAM and its significance in the Cloud-native ecosystem. I have been fiddling around with OAM projects like Kubevela and Napptive and I find it very easy to get started in this space.
In this article, we are going to practically deep-dive into OAM components and deploy the open-source project Apache CouchDB, a NoSQL database alternative to MongoDB to Napptive Catalog.
Exploring fundamental concepts in OAM
The Most important entity in OAM is the Application resource defined in core.oam.dev/v1beta1 resource in Kubevela.
"An application is a collection of independent and loosely coupled services that work together to provide a set of functionalities that are associated with a business value. While the concept of Application is sometimes associated or perceived as the UI (e.g., the web, a mobile application, etc), in the NAPPTIVE platform this concept refers to all the services that are typically referred to as “the backend” and are running in the cloud, not on the user’s computer or device." ~ Napptive Documentation
In simple words, Application is a way to logically aggregate groups of services to form a single application. This is the heart of Open Application Model. Each application have components and traits which may resemble deployments and services in Kubernetes, but that is not completely true. Open Application Model actually removes complexity of managing and wiring those services and ingresses and scalability hurdles and makes you to focus more on the development and business features of your application instead of Kubernetes.
You can find more information here.
Prerequisites
A free account on playground.napptive.dev.
Napptive playground CLI installed. (Check here)
Passion for learning Cloud-native!!!! (Must have)
Are you Ready? Let's get Started!
As I have mentioned earlier, we are going to deploy Apache CouchDB, an open-source NoSQL database management software similar to MongoDB with some additional features like Admin Dashboard! So let's get started.
Create a new folder to store all your files.
You can use
mkdir -p path/to/folder
command.I have created a folder called
napptive
inside my projects directory.Open up your favorite code editor (for me it's Visual Studio Code).
Command:
code .
Create threeYaml files, one for application definition, one for application metadata and one for README.md.
deploy-couchdb.yaml: This file contains all the required definitions (main deployment file) to deploy CouchDB to Napptive along with components and ingress.
meta-couchdb.yaml: This file contains the metadata (additional information) about your applications so that Napptive can handle its documentation.
README.md: This file contains a detailed description of your application.
The contents of deploy-couchdb.yaml is as follows:
apiVersion: core.oam.dev/v1beta1 kind: Application metadata: # Name of the application which will be used to refer to it once deployed. name: couchdb spec: # List of components that are part of the application. components: # Each component must have a name. The name will be used during the translation process # to Kubernetes entities. - name: couchdb # Each component is associated with a type. The type works as a template and defines # how a high-level component will be translated into Kubernetes. # The type is set as webservice as we need api endpoint to access the pods. type: webservice # Properties that can be configured for the user. This can be use to set the parameters # that are defined by the component type. # Specify image link here. By default it fetches from docker hub repository. properties: image: couchdb:latest ports: # This is the default port that is used by CouchDB. - port: 5984 expose: true # These environment variables are required by couchdb image # visit https://hub.docker.com/_/couchdb for getting more information on environment variables and ports env: - name: COUCHDB_USER value: admin - name: COUCHDB_PASSWORD value: password # Traits are extensions that augment the capabilities of a component. For example, # changing the replication, importing a config map, etc. # napptive-ingress exposes component to the outside world, for our case it is CouchDB. # napptive-ingress is a customised ingress provider (it will work only with Napptive platform, for alternative, use gateway trait if you are using Kubevela) traits: - type: napptive-ingress properties: name: nginx-ingress port: 5984 path: /
Here a couple of things to note:
napptive-ingress
trait is customized to work with Napptive platform which provides valid DNS name along with TLS certificate for secured HTTP i.e. HTTPS connections. But this trait only works with Napptive platform and for deploying to other clusters, usegateway
trait provided by Kubevela.Env files are dependent upon the application and cannot be generalized.
Private container repositories can be accessed by adding Personal Access Tokens.
Contents of meta-couchdb.yaml is as follows:
apiVersion: core.napptive.com/v1alpha1 # Required kind: ApplicationMetadata # Specifies name for the application name: "Apache CouchDB" # Version of your application version: 1.0 # Short description for your application description: "This application is for deploying an Apache CouchDB instance" # Related keywords for SEO. keywords: - "CouchDB" - "Couch" - "Database" - "DB" - "db" - "Apache" # Provide license license: "Apache License Version 2.0" # url and doc url: "https://hub.docker.com/_/couchdb" doc: "https://docs.couchdb.org/en/stable/" # Logo for your application logo: - src: "xqFwoTCLjYzdbKmv4CFQAAAAAdAAAAABAEhttps://w7.pngwing.com/pngs/133/140/png-transparent-couchdb-original-logo-icon-thumbnail.png" type: "image/png" size: "120x120"
- Add content to the README.md file accordingly.
Now there are two ways you deploy your application to the catalog:
Using WebUI:
Click on the catalog icon.
Click on the Upload App button.
Provide the necessary details here and upload all three yaml files.
Choose a namespace and click on the Deploy app.
Select catalog deploy and find couchdb-napptive (it has already been published so you won't be able to use the same name) and click on the deploy button.
- Give a name accordingly and select the target environment:
Optionally, you can update the definition file.
!Warning:! DO NOT UPDATE THE PORT here if you are using my app listed in the Catalog.
Click on Deploy and confirm the deployment.
Using playground CLI:
Login to your playground CLI using:
playground login
For making your app publicly available:
playground catalog push <your_napptive_username>/<application_name>:v1.0 /path/to/your/app
- To make your app private, append --private flag.
You have done it!!! Yayy!!
Your deployment is live! Visit the endpoint to interact with CouchDB.
My endpoint: https://nginx-ingress-cgo1q75t998c97mfujd0.apps.playground.napptive.dev/_utils/
(don't worry I have changed the default credentials)
So are you ready to go Cloud Native with Napptive?
Napptive is currently hosting a hackathon in collaboration with WeMakeDevs and I hope this guide would be helpful to all participants. Until next time, Kubernetes steers the ship with might, Helm charts the course, guiding right.
~ Nimish Kashyap