Skip to content

Instantly share code, notes, and snippets.

@resouer
Last active January 22, 2020 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save resouer/d2a0f9846df65ae478f472889e4839d7 to your computer and use it in GitHub Desktop.
Save resouer/d2a0f9846df65ae478f472889e4839d7 to your computer and use it in GitHub Desktop.
# -------------------------- Step 1: Define and install WorkloadType and Trait ---------------------
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: radius.cache.crossplane.io
annotations:
core.oam.dev/oam-type: WorkloadType
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: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: autoscaling.scaling.crossplane.io
annotations:
core.oam.dev/oam-type: Trait
core.oam.dev/applies-to: “core.oam.dev/v1alpha1.Server,cache.crossplane.io/v1.Radius"
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
# -------------------------- Step 2: Define Application Configuration ---------------------
---
apiVersion: core.oam.dev/v1alpha1
kind: ApplicationConfiguration
metadata:
name: hello-world-app-v2
annotations:
version: v0.0.1
description: "very first OAM app for the new spec"
spec:
components:
- apiVersion: cache.crossplane.io/v1
kind: Radius
metadata:
name: ryan-radius
annotations:
core.oam.dev/oam-type: Component
core.oam.dev/policies: "min-replicas:100,max-latency:20ms"
spec:
maxMemory: 256
thread: 2
address: "[fromParam(address, '127.0.0.1')]"
parameterOverride:
- name: address
value: 192.168.0.1
traits:
- apiVersion: crossplane.io/v1 # CR
kind: autoscaling
metadata:
name: scale-radius
spec:
interval: 1
maxCpuUsage: 80
minInstance: 2
maxInstance: 10
- apiVersion: crossplane.io/v1 # CR
kind: ingress
metadata:
name: nginx-ingress
spec:
route: myapp.com
tls: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment