Last active
January 23, 2020 03:01
-
-
Save resouer/8776830bb48238f615f17c5273539622 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1: Define and install WorkloadType and Trait | |
--- | |
apiVersion: core.oam.dev/v1alpha1 | |
kind: WorkloadType | |
metadata: | |
name: cache.crossplane.io/v1.Radius # we endorse G/V/K convension as WorkloadType name | |
spec: | |
schematic: | | |
apiVersion: apiextensions.k8s.io/v1 | |
kind: CustomResourceDefinition | |
metadata: | |
name: radius.cache.crossplane.io | |
scope: Namespaced | |
names: | |
plural: radius | |
singular: radius | |
kind: Radius | |
spec: | |
group: cache.crossplane.io | |
versions: | |
- name: v1 | |
schema: | |
openAPIV3Schema: | |
type: object | |
properties: | |
spec: | |
type: object | |
properties: | |
address: | |
type: string | |
maxMemory: | |
type: integer | |
thread: | |
type: integer | |
--- | |
apiVersion: core.oam.dev/v1alpha1 | |
Kind: Trait | |
metadata: | |
name: autoscaling | |
spec: | |
appliesTo: | |
- core.oam.dev/v1alpha1.Server | |
- cache.crossplane.io/v1.Radius | |
schematic: | | |
apiVersions: apiextensions.k8s.io/v1 | |
kind: CustomResourceDefinition | |
metadata: | |
name: autoscaling.scaling.crossplane.io | |
spec: | |
group: crossplane.io | |
scope: Namespaced | |
names: | |
plural: autoscalings | |
singular: autoscaling | |
kind: Autoscaling | |
versions: | |
- name: v1 | |
served: true | |
storage: true | |
schema: | |
openAPIV3Schema: | |
type: object | |
properties: | |
spec: | |
type: object | |
properties: | |
interval: | |
type: integer | |
maxCpuUsage: | |
type: integer | |
minInstance: | |
type: integer | |
maxInstance: | |
type: integer | |
--- | |
apiVersion: core.oam.dev/v1alpha1 | |
Kind: Trait | |
metadata: | |
name: ingress | |
spec: | |
appliesTo: | |
- core.oam.dev/v1alpha1.Server | |
- cache.crossplane.io/v1.Radius | |
schematic: | | |
// networking.crossplane.io/v1.Ingress | |
// ... | |
# Step 2: Define Component and Application Configuration | |
--- | |
apiVersion: core.oam.dev/v1alpha1 | |
kind: ApplicationConfiguration | |
metadata: | |
name: hello-world-app | |
annotations: | |
version: v0.0.1 | |
description: "very first OAM app for the new spec" | |
spec: | |
components: | |
- name: ryan-radius | |
workloadSettings: | |
apiVersion: cache.crossplane.io/v1 | |
kind: Radius | |
metadata: | |
name: ryan-radius | |
spec: | |
maxMemory: 256 | |
thread: 2 | |
address: "[fromParam(address, '127.0.0.1', string)]" # this is a function for parameter override. So we don't need `parameters` field | |
parameterValues: | |
- name: address | |
value: 192.168.0.1 | |
traits: | |
- name: scale-radius | |
properties: | |
apiVersion: scaling.crossplane.io/v1 | |
kind: Autoscaling | |
metadata: | |
name: scale-radius | |
spec: | |
interval: 1 | |
maxCpuUsage: 80 | |
minInstance: 2 | |
maxInstance: 10 | |
- name: nginx-ingress | |
properties: | |
apiVersion: networking.crossplane.io/v1 | |
kind: Ingress | |
metadata: | |
name: nginx-ingress | |
spec: | |
route: myapp.com | |
tls: true | |
# (optional) Non-overlay version | |
--- | |
apiVersion: core.oam.dev/v1alpha1 | |
kind: Component | |
metadata: | |
name: ryan-radius | |
spec: | |
workloadSettings: | |
apiVersion: cache.crossplane.io/v1 | |
kind: Radius | |
metadata: | |
name: ryan-radius | |
spec: | |
maxMemory: 256 | |
thread: 2 | |
address: "[fromParam(address, '127.0.0.1'), string]" # this is a function for parameter override. So we don't need `parameters` field | |
--- | |
apiVersion: core.oam.dev/v1alpha1 | |
kind: ApplicationConfiguration | |
metadata: | |
name: hello-world-app | |
annotations: | |
version: v0.0.1 | |
description: "very first OAM app for the new spec" | |
spec: | |
components: | |
- name: ryan-radius | |
componentRef: ryan-radius # the name of Component | |
parameterValues: | |
- name: address | |
value: 192.168.0.1 | |
traits: | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compare with old proposal: https://gist.github.com/resouer/d2a0f9846df65ae478f472889e4839d7