-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move dry-run and live-diff into an independent pkg WIP add sample and doc WIP unit test for live-diff add unit test Signed-off-by: roy wang <seiwy2010@gmail.com>
- Loading branch information
1 parent
26163aa
commit f075b33
Showing
33 changed files
with
2,828 additions
and
142 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: Application | ||
metadata: | ||
name: livediff-demo | ||
spec: | ||
components: | ||
- name: myweb-1 | ||
type: myworker | ||
properties: | ||
image: "busybox" | ||
cmd: | ||
- sleep | ||
- "2000" # change a component property | ||
lives: "3" | ||
enemies: "alien" | ||
traits: | ||
- type: myingress | ||
properties: | ||
domain: "www.example.com" | ||
http: | ||
"/": 90 # change a trait | ||
# - type: myscaler # remove a trait | ||
# properties: | ||
# replicas: 2 | ||
- name: myweb-2 | ||
type: myworker | ||
properties: # no change on component property | ||
image: "busybox" | ||
cmd: | ||
- sleep | ||
- "1000" | ||
lives: "3" | ||
enemies: "alien" | ||
traits: | ||
- type: myingress # add a trait | ||
properties: | ||
domain: "www.example.com" | ||
http: | ||
"/": 90 | ||
- name: myweb-3 # add a component | ||
type: myworker | ||
properties: | ||
image: "busybox" | ||
cmd: | ||
- sleep | ||
- "1000" | ||
lives: "3" | ||
enemies: "alien" | ||
traits: | ||
- type: myingress | ||
properties: | ||
domain: "www.example.com" | ||
http: | ||
"/": 90 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: Application | ||
metadata: | ||
name: livediff-demo | ||
spec: | ||
components: | ||
- name: myweb-1 | ||
type: myworker | ||
properties: | ||
image: "busybox" | ||
cmd: | ||
- sleep | ||
- "1000" | ||
lives: "3" | ||
enemies: "alien" | ||
traits: | ||
- type: myingress | ||
properties: | ||
domain: "www.example.com" | ||
http: | ||
"/": 80 | ||
- type: myscaler | ||
properties: | ||
replicas: 2 | ||
- name: myweb-2 | ||
type: myworker | ||
properties: | ||
image: "busybox" | ||
cmd: | ||
- sleep | ||
- "1000" | ||
lives: "3" | ||
enemies: "alien" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: TraitDefinition | ||
metadata: | ||
name: myingress | ||
spec: | ||
appliesToWorkloads: | ||
- "*" | ||
schematic: | ||
cue: | ||
template: | | ||
import ( | ||
kubev1 "kube/v1" | ||
network "kube/networking.k8s.io/v1beta1" | ||
) | ||
parameter: { | ||
domain: string | ||
http: [string]: int | ||
} | ||
outputs: { | ||
service: kubev1.#Service | ||
ingress: network.#Ingress | ||
} | ||
// trait template can have multiple outputs in one trait | ||
outputs: service: { | ||
metadata: | ||
name: context.name | ||
spec: { | ||
selector: | ||
"app.oam.dev/component": context.name | ||
ports: [ | ||
for k, v in parameter.http { | ||
port: v | ||
targetPort: v | ||
}, | ||
] | ||
} | ||
} | ||
outputs: ingress: { | ||
metadata: | ||
name: context.name | ||
spec: { | ||
rules: [{ | ||
host: parameter.domain | ||
http: { | ||
paths: [ | ||
for k, v in parameter.http { | ||
path: k | ||
backend: { | ||
serviceName: context.name | ||
servicePort: v | ||
} | ||
}, | ||
] | ||
} | ||
}] | ||
} | ||
} | ||
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: TraitDefinition | ||
metadata: | ||
annotations: | ||
definition.oam.dev/description: "Configures replicas for your service." | ||
name: myscaler | ||
spec: | ||
appliesToWorkloads: | ||
- webservice | ||
- worker | ||
definitionRef: | ||
name: manualscalertraits.core.oam.dev | ||
workloadRefPath: spec.workloadRef | ||
schematic: | ||
cue: | ||
template: | | ||
outputs: scaler: { | ||
apiVersion: "core.oam.dev/v1alpha2" | ||
kind: "ManualScalerTrait" | ||
spec: { | ||
replicaCount: parameter.replicas | ||
} | ||
} | ||
parameter: { | ||
//+short=r | ||
//+usage=Replicas of the workload | ||
replicas: *1 | int | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
apiVersion: core.oam.dev/v1beta1 | ||
kind: ComponentDefinition | ||
metadata: | ||
name: myworker | ||
spec: | ||
workload: | ||
definition: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
schematic: | ||
cue: | ||
template: | | ||
import ( | ||
apps "kube/apps/v1" | ||
) | ||
output: apps.#Deployment | ||
output: { | ||
spec: { | ||
selector: matchLabels: { | ||
"app.oam.dev/component": context.name | ||
} | ||
template: { | ||
metadata: labels: { | ||
"app.oam.dev/component": context.name | ||
} | ||
spec: { | ||
containers: [{ | ||
name: context.name | ||
image: parameter.image | ||
if parameter["cmd"] != _|_ { | ||
command: parameter.cmd | ||
} | ||
}] | ||
} | ||
} | ||
} | ||
} | ||
parameter: { | ||
// +usage=Which image would you like to use for your service | ||
// +short=i | ||
image: string | ||
// +usage=Commands to run in the container | ||
cmd?: [...string] | ||
} | ||
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.