Warning
This content has been generated by machine translation. The translations are automated and have not undergone human review or validation.
6.2 Understanding the Open Application Model and deploying applications
Reference
Open Application Model
The Open Application Model (OAM) is a model that seeks to enable developers to focus on their applications rather than containers or orchestrators or infrastructure. In order to deploy an application as a container on Kubernetes, in addition to deployment, various resources must be deployed for additional settings such as monitoring and traffic handling, and YAML files must be defined accordingly. Developers focus on this part of the application, and many parts necessary for operation and management are standardized through templates. Open Application Model is currently up to 0.3, and in Verrazzano, [Open Application Model 0.2.1](https://github.com/oam-dev/ spec/tree/v0.2.1), so there are some syntax differences from the latest version.
Key concepts
Component: One application, you can easily think of it as a container app. This component can have a type, and in Verrazzano, there will be an app developed through the Helidon framework, a WebLogic app, or a Coherence server, and depending on the type, there will be characteristics at the time of deployment or monitoring. So, in the component, which type of workload is specified.
Workload: This indicates what type it is. It can be defined through WorkloadDefinition, and you can use the types defined in Verrazzano in advance, such as VerrazzanoHelidonWorkload and VerrazzanoWebLogicWorkload, or the basic resource types of Kubernetes, such as Deployment and ConfigMap, as they are.
Application Configuration: This means one application, which includes several components. It can be a form with settings related to a single container app, or a form of packaged app with multiple containers as components.
Trait: Additional settings for one component according to the needs of operation, monitoring, etc. Looking at the site’s documentation examples, common examples include metric collection settings, Ingress settings, etc.
Scope: This is a setting for several components at once.
Deploy the Helidon sample application
Through an example of deploying a Java application developed using the Helidon framework, we will check the deployment in Verrazzano using the Open Application Model. It is not difficult to develop in Java and build a container image, so let’s check out the Verrazzano deployment after that.
Example application: Helidon sample, a simple container application that sends a welcome message when you request /greet with the REST API.
Create Component
Define a Kubernetes CRD component used by Verrazzano.
- spec.workload: Defines the Workload of the component.
- spec.workload.kind: Select VerrazzanoHelidonWorkload Workload Definition predefined by Verrazzano for non-generic Helidon-based containers
- spec.workload.spec: VerrazzanoHelidonWorkload specification that uses the Kubernetes Deployment specification as it is
apiVersion: core.oam.dev/v1alpha2 kind: Component metadata: name: hello-helidon-component namespace: hello-helidon spec: workload: apiVersion: oam.verrazzano.io/v1alpha1 kind: VerrazzanoHelidonWorkload metadata: name: hello-helidon-workload labels: app: hello-helidon spec: deploymentTemplate: metadata: name: hello-helidon-deployment podSpec: containers: - name: hello-helidon-container image: "ghcr.io/verrazzano/example-helidon-greet-app-v1:0.1.10-3-20201016220428-56fb4d4" ports: - containerPort: 8080 name: http
Create Application Configuration
Define Application Configuration, which is the Kubernetes CRD used by Verrazzano.
- spec.components.componentName: This refers to the just-defined component hello-helidon-component. You can see that multiple components can be added under spec.components.
- spec.components.traits.trait: Defines the parts to be added to the target component for operation and management. We currently provide IngressTrait, LoggingTrait, and MetricsTrait.
apiVersion: core.oam.dev/v1alpha2 kind: ApplicationConfiguration metadata: name: hello-helidon-appconf namespace: hello-helidon annotations: version: v1.0.0 description: "Hello Helidon application" spec: components: - componentName: hello-helidon-component traits: - trait: apiVersion: oam.verrazzano.io/v1alpha1 kind: MetricsTrait spec: scraper: verrazzano-system/vmi-system-prometheus-0 - trait: apiVersion: oam.verrazzano.io/v1alpha1 kind: IngressTrait metadata: name: hello-helidon-ingress spec: rules: - paths: - path: "/greet" pathType: Prefix
Application Deployment
Create namespace
kubectl create namespace hello-helidon kubectl label namespace hello-helidon verrazzano-managed=true istio-injection=enabled
Component distribution
kubectl apply -f https://raw.githubusercontent.com/verrazzano/verrazzano/v1.1.0/examples/hello-helidon/hello-helidon-comp.yaml
Application Configuration Deployment
kubectl apply -f https://raw.githubusercontent.com/verrazzano/verrazzano/v1.1.0/examples/hello-helidon/hello-helidon-app.yaml
Check the registered ingress DNS through istio of the deployed app
kubectl get gateway hello-helidon-hello-helidon-appconf-gw \ -n hello-helidon \ -o jsonpath='{.spec.servers[0].hosts[0]}'
Execution example
$ kubectl get gateway hello-helidon-hello-helidon-appconf-gw \ > -n hello-helidon \ > -o jsonpath='{.spec.servers[0].hosts[0]}' hello-helidon-appconf.hello-helidon.myenv.thekoguryo.ml
Application testing
You can see that it is called normally with the resolved https://{ingress DNS address}/greet address.
monitoring
Verrazzano console
Log in to the Verrazzano Console.
Example) https://verrazzano.myenv.thekoguryo.ml
- Accessed user: verrazzano
- Password: Password initialized during installation
In the Resources section on the left, you can check the deployed app information in the Application and Component sections.
Log Monitoring (Elasticsearch / Kibana)
Click the Kibana link in the Verrazzano console. SSO is configured, so additional login is not required.
Select Stack Management from the Navigation Menu.
Click Index Pattern > + Create index pattern.
You will see multiple sources of possible patterns, including the namespace you added for the example app.
You can use an expression, but here we enter an example namespace name as the pattern name. Example) verrazzano-namespace-hello-helidon
Select @timestamp as the Time field
Addition completed
From the Navigation Menu, go to the Kibana > Discover menu.
You can see logs collected for the created index pattern and all logs collected on the target namespace.
After applying the filter, you can check the log accurately.
$ kubectl logs -n hello-helidon hello-helidon-deployment-c4d7859-nqt7l -c hello-helidon-container ... 2021.12.29 03:22:44 INFO io.helidon.microprofile.server.ServerCdiExtension Thread[main,5,main]: Server started on http://localhost:8080 (and all other host addresses) in 3075 milliseconds (since JVM startup). http://localhost:8080/greet 2021.12.29 03:22:44 INFO io.helidon.common.HelidonFeatures Thread[features-thread,5,main]: Helidon MP 2.3.2 features: [CDI, Config, Fault Tolerance, Health, JAX-RS, Metrics, Open API, REST Client, Security, Server, Tracing]
Monitoring metrics (Prometheus / Grafana)
Click the Grafana link in the Verrazzano console. SSO is configured, so additional login is not required.
From the Navigation Menu, select Dashboard > Manage.
Select the Helidon dashboard among the default dashboards.
You can check the status of the previously deployed app on the Helidon dashboard.
Service Mesh Monitoring (Kiali)
Click the Kiali link in the Verrazzano console. SSO is configured, so additional login is not required.
Click Graph in the left menu.
If you select the target Namespace, you can see the mutual calling relationship as shown below. It looks simple as an example consisting of a single service.
Additional notes
I checked Octant, an open source client tool, for resources related to ApplicationConfiguration.
- You can check that Deployment (including children), Service, Istio Gateway, and Virtual Service are deployed by adding to the content resources directly specified in ApplicationConfiguration and Component.
As an individual, this article was written with my personal time. There may be errors in the content of the article, and the opinions in the article are personal opinions.