Skip to content

Commit

Permalink
feat: Add VM Preemption Example
Browse files Browse the repository at this point in the history
Closes: vmware-samples#696
Signed-off-by: Michael Gasch <mgasch@vmware.com>
  • Loading branch information
Michael Gasch committed Oct 25, 2021
1 parent b0c5e9d commit 2fb5449
Show file tree
Hide file tree
Showing 8 changed files with 1,568 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/knative/go/kn-go-preemption/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
create category/tag


create sinkbinding for functions so they can inject `replyTo` address:

```
apiVersion: sources.knative.dev/v1
kind: SinkBinding
metadata:
name: vsphere-preemption-binding
spec:
subject:
apiVersion: serving.knative.dev/v1
kind: Service
selector:
matchLabels:
workflow: vsphere-preemption
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: rabbit
```

`com.vmware.workflows.vsphere.VmPreemptedEvent.v0`

govc fields.info -n com.vmware.workflows.vsphere.preemption -json test-vm-1 | jq '.Info[].Value|fromjson'


Address string `envconfig:"TEMPORAL_URL" required:"true"`
Namespace string `envconfig:"TEMPORAL_NAMESPACE" required:"true"`
Queue string `envconfig:"TEMPORAL_TASKQUEUE" required:"true"`
Workflow string `envconfig:"TEMPORAL_WORKFLOW" required:"true"`

Tag string `envconfig:"VSPHERE_PREEMPTION_TAG" required:"true"` // vsphere tag
AlarmName string `envconfig:"VSPHERE_ALARM_NAME" required:"true"` // vsphere alarm name
45 changes: 45 additions & 0 deletions examples/knative/go/kn-go-preemption/config/function.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: kn-go-preemption
labels:
app: veba-ui
workflow: vsphere-preemption
spec:
template:
metadata:
annotations:
autoscaling.knative.dev/maxScale: "1"
autoscaling.knative.dev/minScale: "1"
spec:
containers:
- image: ko://github.com/vmware-samples/vcenter-event-broker-appliance/examples/go/kn-go-preemption
env:
- name: TEMPORAL_URL
value: "temporaltest-frontend.default.svc.cluster.local:7233"
- name: TEMPORAL_NAMESPACE
value: "vsphere-preemption"
- name: TEMPORAL_TASKQUEUE
value: "vsphere-preemption"
- name: TEMPORAL_WORKFLOW
value: "PreemptVMsWorkflow"
- name: VSPHERE_PREEMPTION_TAG
value: "preemptible"
- name: VSPHERE_ALARM_NAME
value: "memory-usage-above-5-critical"
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: vsphere-preemption
spec:
broker: rabbit
filter:
attributes:
type: com.vmware.vsphere.AlarmStatusChangedEvent
subscriber:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: kn-go-preemption
namespace: default
60 changes: 60 additions & 0 deletions examples/knative/go/kn-go-preemption/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module github.com/vmware-samples/vcenter-event-broker-appliance/examples/go/kn-go-preemption

go 1.17

require (
github.com/cloudevents/sdk-go/v2 v2.5.0
github.com/embano1/vsphere-preemption v0.0.0-20211021093510-fbef5d5179bd
github.com/hashicorp/go-multierror v1.0.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/vmware/govmomi v0.27.0
go.temporal.io/api v1.5.0
go.temporal.io/sdk v1.10.0
go.uber.org/zap v1.19.1
knative.dev/pkg v0.0.0-20211018141937-a34efd6b409d
)

require (
github.com/benbjohnson/clock v1.1.0 // indirect
github.com/blendle/zapdriver v1.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/gogo/status v1.1.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/twmb/murmur3 v1.1.6 // indirect
github.com/uber-go/tally v3.4.2+incompatible // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/net v0.0.0-20210928044308-7d9f5e0b762b // indirect
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0 // indirect
google.golang.org/grpc v1.41.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.22.2 // indirect
k8s.io/apimachinery v0.22.2 // indirect
k8s.io/klog/v2 v2.9.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
)
Loading

0 comments on commit 2fb5449

Please sign in to comment.