TheKoguryo's Tech Blog

Version 2023.10.13

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

  • https://verrazzano.io/latest/docs/concepts/verrazzanooam/

    OAM five core 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

  1. Define a Kubernetes CRD component used by Verrazzano.

    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

  1. 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

  1. Create namespace

    kubectl create namespace hello-helidon
    kubectl label namespace hello-helidon verrazzano-managed=true istio-injection=enabled
    
  2. Component distribution

    kubectl apply -f https://raw.githubusercontent.com/verrazzano/verrazzano/v1.1.0/examples/hello-helidon/hello-helidon-comp.yaml
    
  3. Application Configuration Deployment

    kubectl apply -f https://raw.githubusercontent.com/verrazzano/verrazzano/v1.1.0/examples/hello-helidon/hello-helidon-app.yaml
    
  4. 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]}'
    
  5. 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
    
  6. Application testing

    You can see that it is called normally with the resolved https://{ingress DNS address}/greet address.

    image-20211229123211182

monitoring

Verrazzano console

  1. Log in to the Verrazzano Console.

    Example) https://verrazzano.myenv.thekoguryo.ml

    • Accessed user: verrazzano
    • Password: Password initialized during installation
  2. In the Resources section on the left, you can check the deployed app information in the Application and Component sections.

    image-20211229131428942

Log Monitoring (Elasticsearch / Kibana)

  1. Click the Kibana link in the Verrazzano console. SSO is configured, so additional login is not required.

  2. Select Stack Management from the Navigation Menu.

    image-20211229131928208

  3. Click Index Pattern > + Create index pattern.

  4. You will see multiple sources of possible patterns, including the namespace you added for the example app.

    image-20211229132243789

  5. You can use an expression, but here we enter an example namespace name as the pattern name. Example) verrazzano-namespace-hello-helidon

    image-20211229132532627

  6. Select @timestamp as the Time field

    image-20211229132611953

  7. Addition completed

    image-20211229132745498

  8. From the Navigation Menu, go to the Kibana > Discover menu.

  9. You can see logs collected for the created index pattern and all logs collected on the target namespace.

    image-20211229135258744

  10. 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]
    

    image-20211229141547400

Monitoring metrics (Prometheus / Grafana)

  1. Click the Grafana link in the Verrazzano console. SSO is configured, so additional login is not required.

  2. From the Navigation Menu, select Dashboard > Manage.

  3. Select the Helidon dashboard among the default dashboards.

    image-20211229142135880

  4. You can check the status of the previously deployed app on the Helidon dashboard.

    image-20211229142544655

Service Mesh Monitoring (Kiali)

  1. Click the Kiali link in the Verrazzano console. SSO is configured, so additional login is not required.

  2. Click Graph in the left menu.

  3. 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.

    image-20211229143004928

Additional notes

  1. 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.

    image-20211229144023152



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.

Last updated on 28 Dec 2021