Skip to content

Instantly share code, notes, and snippets.

@resouer
Last active January 23, 2020 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save resouer/8776830bb48238f615f17c5273539622 to your computer and use it in GitHub Desktop.
Save resouer/8776830bb48238f615f17c5273539622 to your computer and use it in GitHub Desktop.
# 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:
...
@resouer
Copy link
Author

resouer commented Jan 19, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment