Repository navigation
[Addon]: add open-component-model operator as source for deliverables #808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| apiVersion: core.oam.dev/v1beta1 | ||
| kind: Application | ||
| metadata: | ||
| name: ocm-cli-demo | ||
| spec: | ||
| components: | ||
| - name: ocm-cli | ||
| type: ocm-component | ||
| properties: | ||
| repository: | ||
| type: OCIRegistry | ||
| baseUrl: ghcr.io/open-component-model | ||
| component: ocm.software/cli | ||
| semver: 0.23.0 | ||
| - name: ocm-cli-image | ||
| type: ocm-resource | ||
| dependsOn: [ocm-cli] | ||
| properties: | ||
| componentRef: ocm-cli | ||
| resource: | ||
| name: image | ||
| additionalStatusFields: | ||
| image: resource.access.imageReference | ||
| outputs: | ||
| - name: image | ||
| valueFrom: output.status.additional.image | ||
| - name: ocm-version | ||
| type: task | ||
| dependsOn: [ocm-cli-image] | ||
| inputs: | ||
| - from: image | ||
| parameterKey: image | ||
| properties: | ||
| image: placeholder | ||
| cmd: ["/ocm", "version"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| # open-component-model | ||
|
|
||
| [Open Component Model (OCM)](https://ocm.software) packages software as signed, location-independent component versions. | ||
| This addon installs the [OCM controller](https://github.com/open-component-model/open-component-model/tree/main/bindings/go/kubernetes/controller), | ||
| which resolves, verifies and replicates component versions in the cluster. KubeVela then orchestrates the delivered resources. | ||
|
|
||
| Not to be confused with the `ocm-cluster-manager` addon, which is Open Cluster Management. | ||
|
|
||
| ## Install | ||
|
|
||
| ```shell | ||
| vela addon registry add experimental --type helm --endpoint=https://kubevela.github.io/catalog/experimental | ||
| vela addon enable experimental/open-component-model | ||
| ``` | ||
|
|
||
| Install into a different namespace: | ||
|
|
||
| ```shell | ||
| vela addon enable experimental/open-component-model namespace=my-ocm | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| The addon provides two component types: | ||
|
|
||
| - `ocm-component` resolves a component version from an OCM repository. | ||
| - `ocm-resource` resolves and verifies one resource of that component version. | ||
| `additionalStatusFields` publishes values from the resource under `status.additional`, so other components can consume them. | ||
|
|
||
| This application ([examples/open-component-model/app.yaml](../../../examples/open-component-model/app.yaml)) resolves the published OCM CLI component and runs its image as a job. | ||
| The job's `image` comes from the verified, digest-pinned reference in the component version. | ||
|
|
||
| ```yaml | ||
| apiVersion: core.oam.dev/v1beta1 | ||
| kind: Application | ||
| metadata: | ||
| name: ocm-cli-demo | ||
| spec: | ||
| components: | ||
| - name: ocm-cli | ||
| type: ocm-component | ||
| properties: | ||
| repository: | ||
| type: OCIRegistry | ||
| baseUrl: ghcr.io/open-component-model | ||
| component: ocm.software/cli | ||
| semver: 0.23.0 | ||
| - name: ocm-cli-image | ||
| type: ocm-resource | ||
| dependsOn: [ocm-cli] | ||
| properties: | ||
| componentRef: ocm-cli | ||
| resource: | ||
| name: image | ||
| additionalStatusFields: | ||
| image: resource.access.imageReference | ||
| outputs: | ||
| - name: image | ||
| valueFrom: output.status.additional.image | ||
| - name: ocm-version | ||
| type: task | ||
| dependsOn: [ocm-cli-image] | ||
| inputs: | ||
| - from: image | ||
| parameterKey: image | ||
| properties: | ||
| image: placeholder | ||
| cmd: ["/ocm", "version"] | ||
| ``` | ||
|
|
||
| ```shell | ||
| $ vela status ocm-cli-demo | ||
| ... | ||
| - Name: ocm-cli-image | ||
| Type: ocm-resource | ||
| Health: ✅ | ||
| Message: image from ocm.software/cli:0.23.0 | ||
| ... | ||
| $ kubectl logs job/ocm-cli-demo-ocm-version | ||
| OCM CLI (Open Component Model v2) | ||
| Version: 0.23.0 | ||
| ``` | ||
|
|
||
| Use `vela show ocm-component` and `vela show ocm-resource` for all parameters. | ||
|
|
||
| ## Requirements | ||
|
|
||
| KubeVela v1.11.0 or later, for the native `helmchart` component. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| "ocm-component": { | ||
| type: "component" | ||
| description: "Resolves an OCM component version from an OCM repository." | ||
| labels: {} | ||
| annotations: {} | ||
| attributes: { | ||
| workload: type: "autodetects.core.oam.dev" | ||
| status: { | ||
| healthPolicy: #""" | ||
| _ready: [ for o in [context.output, context.outputs.repository] { | ||
| *false | bool | ||
| if o.status.conditions != _|_ { | ||
| len([ for c in o.status.conditions if c.type == "Ready" && c.status == "True" {c}]) > 0 | ||
| } | ||
| }] | ||
| isHealth: len([ for r in _ready if !r {r}]) == 0 | ||
| """# | ||
| customStatus: #""" | ||
| message: *"Resolving" | string | ||
| if context.output.status.component.version != _|_ { | ||
| message: context.output.status.component.component + ":" + context.output.status.component.version | ||
| } | ||
| """# | ||
| } | ||
| } | ||
| } | ||
|
|
||
| template: { | ||
| output: { | ||
| apiVersion: "delivery.ocm.software/v1alpha1" | ||
| kind: "Component" | ||
| metadata: name: context.name | ||
| spec: { | ||
| repositoryRef: name: context.name | ||
| component: parameter.component | ||
| semver: parameter.semver | ||
| downgradePolicy: parameter.downgradePolicy | ||
| interval: parameter.interval | ||
| if parameter.semverFilter != _|_ { | ||
| semverFilter: parameter.semverFilter | ||
| } | ||
| if parameter.ocmConfig != _|_ { | ||
| ocmConfig: parameter.ocmConfig | ||
| } | ||
| } | ||
| } | ||
|
|
||
| outputs: repository: { | ||
| apiVersion: "delivery.ocm.software/v1alpha1" | ||
| kind: "Repository" | ||
| metadata: name: context.name | ||
| spec: { | ||
| repositorySpec: parameter.repository | ||
| interval: parameter.interval | ||
| if parameter.ocmConfig != _|_ { | ||
| ocmConfig: parameter.ocmConfig | ||
| } | ||
| } | ||
| } | ||
|
|
||
| parameter: { | ||
| // +usage=The OCM repository specification, for example {type: "OCIRegistry", baseUrl: "ghcr.io/my-org"} | ||
| repository: {...} | ||
| // +usage=The name of the OCM component, for example "ocm.software/my-app" | ||
| component: string | ||
| // +usage=The semver constraint the component version must match, for example ">=1.0.0" | ||
| semver: string | ||
| // +usage=A regex that further filters the versions matching the semver constraint | ||
| semverFilter?: string | ||
| // +usage=Whether the component may be downgraded to a lower version | ||
| downgradePolicy: *"Deny" | "Allow" | ||
| // +usage=How often the repository is checked for new component versions | ||
| interval: *"10m" | string | ||
| // +usage=References to objects that can provide ocm configuration data to the referring object. These can be secrets, config maps, or other OCM objects that have configuration to propagate. | ||
| ocmConfig?: [...{ | ||
| kind: "Secret" | "ConfigMap" | "Repository" | "Component" | "Resource" | ||
| name: string | ||
| apiVersion?: string | ||
| namespace?: string | ||
| policy?: *"Propagate" | "DoNotPropagate" | ||
| }] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| "ocm-resource": { | ||
| type: "component" | ||
| description: "Resolves and verifies a resource of an OCM component version resolved by an ocm-component." | ||
| labels: {} | ||
| annotations: {} | ||
| attributes: { | ||
| workload: type: "autodetects.core.oam.dev" | ||
| status: { | ||
| healthPolicy: #""" | ||
| isHealth: *false | bool | ||
| if context.output.status.conditions != _|_ { | ||
| isHealth: len([ for c in context.output.status.conditions if c.type == "Ready" && c.status == "True" {c}]) > 0 | ||
| } | ||
| """# | ||
| customStatus: #""" | ||
| message: *"Resolving" | string | ||
| if context.output.status.resource.name != _|_ && context.output.status.component.version != _|_ { | ||
| message: context.output.status.resource.name + " from " + context.output.status.component.component + ":" + context.output.status.component.version | ||
| } | ||
| """# | ||
| } | ||
| } | ||
| } | ||
|
|
||
| template: { | ||
| output: { | ||
| apiVersion: "delivery.ocm.software/v1alpha1" | ||
| kind: "Resource" | ||
| metadata: name: context.name | ||
| spec: { | ||
| componentRef: name: parameter.componentRef | ||
| resource: byReference: { | ||
| resource: parameter.resource | ||
| if parameter.referencePath != _|_ { | ||
| referencePath: parameter.referencePath | ||
| } | ||
| } | ||
| verificationPolicy: parameter.verificationPolicy | ||
| if parameter.additionalStatusFields != _|_ { | ||
| additionalStatusFields: parameter.additionalStatusFields | ||
| } | ||
| if parameter.ocmConfig != _|_ { | ||
| ocmConfig: parameter.ocmConfig | ||
| } | ||
| } | ||
| } | ||
|
|
||
| parameter: { | ||
| // +usage=The name of the ocm-component in this application that resolves the component version | ||
| componentRef: string | ||
| // +usage=The identity of the resource in the component version, for example {name: "chart"} | ||
| resource: { | ||
| name: string | ||
| [string]: string | ||
| } | ||
| // +usage=Identities of component references to follow to reach the resource | ||
| referencePath?: [...{[string]: string}] | ||
| // +usage=Whether to verify the resource digest | ||
| verificationPolicy: *"Always" | "Never" | ||
| // +usage=CEL expressions evaluated against the resource, published under status.additional, for example {image: "resource.access.imageReference"} | ||
| additionalStatusFields?: {...} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree with your reply to cubic, the CRD takes free JSON. If you fancy it, |
||
| // +usage=References to objects that can provide ocm configuration data to the referring object. These can be secrets, config maps, or other OCM objects that have configuration to propagate. | ||
|
Skarlso marked this conversation as resolved.
Resolved
|
||
| ocmConfig?: [...{ | ||
| kind: "Secret" | "ConfigMap" | "Repository" | "Component" | "Resource" | ||
|
Skarlso marked this conversation as resolved.
Resolved
|
||
| name: string | ||
| apiVersion?: string | ||
| namespace?: string | ||
| policy?: *"Propagate" | "DoNotPropagate" | ||
| }] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| name: open-component-model | ||
| version: 0.1.0 | ||
| description: Deliver Open Component Model (OCM) component versions to KubeVela applications. | ||
| icon: https://raw.githubusercontent.com/open-component-model/open-component-model/main/website/assets/logo-image.png | ||
| url: https://ocm.software | ||
|
|
||
| tags: | ||
| - experimental | ||
| - Delivery | ||
|
|
||
| deployTo: | ||
| controlPlane: true | ||
| runtimeCluster: false | ||
|
|
||
| system: | ||
| vela: ">=v1.11.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| parameter: { | ||
| // +usage=The namespace to install the OCM controller into | ||
| namespace: *"ocm-system" | string | ||
| // +usage=Helm values for the OCM controller chart. fullnameOverride is fixed to "ocm-k8s-toolkit". | ||
| values?: { | ||
| // The addon health check looks the controller Deployment up by this name. | ||
| fullnameOverride?: "ocm-k8s-toolkit" | ||
| ... | ||
| } | ||
|
Comment on lines
+5
to
+9
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On KubeVela 1.11 the addon loader generates an OpenAPI schema from this file before enabling, and the encoder fails on values?: {
// The addon health check looks the controller Deployment up by this name.
fullnameOverride?: "ocm-k8s-toolkit"
...
}With |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package main | ||
|
|
||
| ocmController: { | ||
| name: "ocm-controller" | ||
| type: "helmchart" | ||
| properties: { | ||
| chart: { | ||
| source: "oci://ghcr.io/open-component-model/kubernetes/controller/chart" | ||
| version: "0.23.0" | ||
| } | ||
| release: { | ||
| name: "ocm-k8s-toolkit" | ||
| namespace: parameter.namespace | ||
| } | ||
| values: { | ||
| if parameter.values != _|_ { | ||
| parameter.values | ||
| } | ||
| fullnameOverride: "ocm-k8s-toolkit" | ||
| } | ||
| // KubeVela 1.11's helmchart health check needs the resource name; fullnameOverride is fixed so this one is stable. | ||
| healthStatus: [{ | ||
| resource: { | ||
| kind: "Deployment" | ||
| name: "ocm-k8s-toolkit-controller-manager" | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
| condition: type: "Available" | ||
| }] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package main | ||
|
|
||
| output: { | ||
| apiVersion: "core.oam.dev/v1beta1" | ||
| kind: "Application" | ||
| spec: { | ||
| components: [ocmController] | ||
| policies: [] | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.