mirror of
https://github.com/kubevela/kubevela.git
synced 2026-04-20 01:27:13 +00:00
101 lines
2.4 KiB
YAML
101 lines
2.4 KiB
YAML
apiVersion: core.oam.dev/v1beta1
|
|
kind: WorkflowStepDefinition
|
|
metadata:
|
|
name: apply-with-ip
|
|
spec:
|
|
schematic:
|
|
cue:
|
|
template: |
|
|
import ("vela/op")
|
|
parameter: {
|
|
component: string
|
|
serverIP?: string
|
|
}
|
|
|
|
// load component from application
|
|
component: op.#Load & {
|
|
component: parameter.component
|
|
value: {}
|
|
}
|
|
|
|
// apply workload to kubernetes cluster
|
|
apply: op.#Apply & {
|
|
value: {
|
|
component.value.workload
|
|
metadata: name: parameter.component
|
|
if parameter.serverIP!=_|_{
|
|
spec: containers: [{env: [{name: "PrefixIP",value: parameter.serverIP}]}]
|
|
}
|
|
}
|
|
}
|
|
|
|
// wait until workload.status equal "Running"
|
|
wait: op.#ConditionalWait & {
|
|
continue: apply.value.status.phase =="Running"
|
|
}
|
|
---
|
|
apiVersion: core.oam.dev/v1beta1
|
|
kind: WorkflowStepDefinition
|
|
metadata:
|
|
name: apply-component
|
|
spec:
|
|
schematic:
|
|
cue:
|
|
template: |
|
|
import ("vela/op")
|
|
parameter: {
|
|
component: string
|
|
prefixIP?: string
|
|
}
|
|
|
|
// load component from application
|
|
component: op.#Load & {
|
|
component: parameter.component
|
|
}
|
|
|
|
// apply workload to kubernetes cluster
|
|
apply: op.#ApplyComponent & {
|
|
component: parameter.component
|
|
}
|
|
|
|
// wait until workload.status equal "Running"
|
|
wait: op.#ConditionalWait & {
|
|
continue: apply.workload.status.phase =="Running"
|
|
}
|
|
|
|
// export podIP
|
|
myIP: apply.workload.status.podIP
|
|
---
|
|
apiVersion: core.oam.dev/v1beta1
|
|
kind: ComponentDefinition
|
|
metadata:
|
|
name: singleton-server
|
|
annotations:
|
|
definition.oam.dev/description: "singleton-server is Pod"
|
|
spec:
|
|
workload:
|
|
definition:
|
|
apiVersion: v1
|
|
kind: Pod
|
|
schematic:
|
|
cue:
|
|
template: |
|
|
parameter: {
|
|
version: *"1.14.2" | string
|
|
}
|
|
output: {
|
|
apiVersion: "v1"
|
|
kind: "Pod"
|
|
metadata: {
|
|
labels: app: "nginx"
|
|
name: context.name
|
|
}
|
|
spec:{
|
|
containers:[{
|
|
name: "nginx"
|
|
image: "nginx:"+parameter.version
|
|
ports: [{containerPort: 80}]
|
|
}]
|
|
}
|
|
}
|