Add schematics to the system
As described in the OAM playground concepts, an application is composed by different components that are then referenced in the application configuration. The application configuration can also use traits and scopes. Adding schematics is as simple as any other kubernetes entity.
Prerequirements
- Playground tools are installed (kubectl & playground)
- A
napptive-kubeconfig
file is available
playground login
Login success
playground get-kubeconfig
...
Use this kubeconfig to connect to the cluster and deploy applications:
kubectl --kubeconfig <napptive-kubeconfig> ...
Adding schematics
Let’s assume you want to add a new component to the system. Using the drawio component from the tutorial, save the following content to a new file named drawio_component.yaml
(you can choose any name for the file).
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
Now you can deploy it with:
playground schematics components add drawio_component.yaml
STATUS INFO
SUCCESS component [drawio] added
or using kubectl command:
kubectl --kubeconfig <path_to>/napptive-kubeconfig create -f drawio_component.yaml
component.core.oam.dev/drawio created
The same process applies to traits and scopes. To list the existing schematics:
- Components
playground schematics components
NAME drawio
- Traits
playground schematics traits
NAME manualscalertraits.core.oam.dev
- Scopes
playground schematics scopes
NAME healthscopes.core.oam.dev
- Workloads
playground schematics workloads
NAME containerizedworkloads.core.oam.dev
In the web interface, the left-side column allows you to navigate easily through the different schematics.
Alternatively, you can use the standard kubectl
approach:
- Components
kubectl --kubeconfig <path_to>/napptive-kubeconfig get components.core.oam.dev
NAME WORKLOAD-KIND AGE drawio ContainerizedWorkload 5m15s
- Traits
kubectl --kubeconfig <path_to>/napptive-kubeconfig get traitdefinitions.core.oam.dev
NAME DEFINITION-NAME manualscalertraits.core.oam.dev manualscalertraits.core.oam.dev
- Scopes
kubectl --kubeconfig <path_to>/napptive-kubeconfig get scopedefinitions.core.oam.dev
NAME DEFINITION-NAME healthscopes.core.oam.dev healthscope.core.oam.dev
Workloads
kubectl --kubeconfig <path_to>/napptive-kubeconfig get workloaddefinitions.core.oam.dev
NAME DEFINITION-NAME containerizedworkloads.core.oam.dev containerizedworkloads.core.oam.dev