OAM applications are defined by an application configuration entity that links all the components that form the application applying traits and scopes. To deploy an application, you will need to create all associated entities.
- Playground tools are installed
- kubectl if you prefer to install an application with it
napptive-kubeconfigfile is available
To deploy an OAM application, we recommend having all files in a single directory. This faciliates having a consolidate place to work on your application definitions.
To illustrate this, let’s deploy the Drawio application.
Create the following files and store them in a directory:
apiVersion: core.oam.dev/v1alpha2 kind: Component metadata: name: drawio spec: workload: apiVersion: core.oam.dev/v1alpha2 kind: ContainerizedWorkload metadata: name: drawio spec: osType: linux containers: - name: drawio securityContext: runAsUser: 1001 image: jgraph/drawio:14.3.0 imagePullPolicy: IfNotPresent resources: cpu: required: 150m memory: required: 256Mi ports: - name: http value: 8080 containerPort: 8080 type: tcp - name: https value: 8443 containerPort: 8443 type: tcp
apiVersion: core.oam.dev/v1alpha2 kind: ApplicationConfiguration metadata: name: drawio annotations: version: 14.3.0 description: "draw.io (formerly Diagramly) is free online diagram software" spec: components: - componentName: drawio traits: - trait: apiVersion: core.napptive.com/v1alpha1 kind: Ingress metadata: name: drawio-ingress spec: name: drawio protocol: HTTP port: 8080 path: / rewritePath: / - trait: apiVersion: core.oam.dev/v1alpha2 kind: ManualScalerTrait metadata: name: example-appconfig-trait spec: replicaCount: 1
After both files are saved, the simplest way to deploy the application is executing:
playground apps deploy <path_to_drawio_files>
STATUS INFO SUCCESS application [drawio] deployed CREATED core.oam.dev/v1alpha2, Kind=Component "drawio" created core.oam.dev/v1alpha2, Kind=ApplicationConfiguration "drawio" created
NAME STATUS drawio APP_OK
Or if you prefer, you can deploy the application using kubectl.
In this case, you need to obtain the kubeconfig file executing:
ASSOCIATED SERVER https://188.8.131.52 Use this kubeconfig to connect to the cluster and deploy applications: kubectl --kubeconfig <napptive-kubeconfig> ...
kubectl --kubeconfig <path_to>/napptive-kubeconfig create -f <path_to_drawio_files>
component.core.oam.dev/drawio created applicationconfiguration.core.oam.dev/drawio created
playground apps NAME STATUS drawio APP_OK
On the web interface, you will see the app is now ready, and you can easily explore what is doing and the cluster usage.
Alternatively, you may create each component separately. Make sure to create components before the application configuration. In some cases, you will receive a message related to dependent components not available if you create the entities in a different order.
kubectl --kubeconfig <path_to>/napptive-kubeconfig create -f <path_to_drawio_files>/010.drawio.component.yaml
kubectl --kubeconfig <path_to>/napptive-kubeconfig create -f <path_to_drawio_files>/020.drawio.appconfig.yam
This application has an endpoint declared, you can open it in a browser executing:
playground apps open drawio