Giter Club home page Giter Club logo

sources-for-knative's Introduction

VMware Tanzu Sources for Knative

GoDoc Go Report Card Slack Status codecov

This repo is the home for VMware-related event sources compatible with the Knative project.

This repo is under active development to get a Knative compatible Event Source for VMware events, e.g. VMware vSphere incl. a Binding to easily access the vSphere API from Kubernetes objects, e.g. a Job.

⚠️ NOTE: To run these examples, you will need ko installed or use a release (preferred) and deploy it via kubectl.

Available Sources and Bindings

  • VSphereSource to create VMware vSphere (vCenter) event sources
  • VSphereBinding to inject VMware vSphere (vCenter) credentials
  • HorizonSource to create VMware Horizon event sources

Install Tanzu Sources CRDs for Knative

Install via Release (latest)

kubectl apply -f https://github.com/vmware-tanzu/sources-for-knative/releases/latest/download/release.yaml

Install from Source

Install the CRD providing the control / dataplane for the various Sources and Bindings:

# define environment variables accordingly, e.g. when using kind
export KIND_CLUSTER_NAME=vmware
export KO_DOCKER_REPO=kind.local

ko apply -BRf config

Examples

To see examples of the Sources and Bindings in action, check out our samples directory.

Basic VSphereSource Example

The VSphereSource provides a simple mechanism to enable users to react to vSphere events.

In order to receive events from vSphere (i.e. vCenter) these are the key parts in the configuration:

  1. The vCenter address and secret information.
  2. Where to send the events.
  3. Checkpoint behavior.
  4. Payload encoding scheme
apiVersion: sources.tanzu.vmware.com/v1alpha1
kind: VSphereSource
metadata:
  name: source
spec:
  # Where to fetch the events, and how to auth.
  address: https://vcenter.corp.local
  skipTLSVerify: true
  secretRef:
    name: vsphere-credentials

  # Where to send the events.
  sink:
    uri: http://where.to.send.stuff

  # Adjust checkpointing and event replay behavior
  checkpointConfig:
    maxAgeSeconds: 300
    periodSeconds: 10

  # Set the CloudEvent data encoding scheme to JSON
  payloadEncoding: application/json

Let's walk through each of these.

Authenticating with vSphere

Let's focus on this part of the sample source:

# Where to fetch the events, and how to auth.
address: https://vcenter.corp.local
skipTLSVerify: true
secretRef:
  name: vsphere-credentials
  • address is the URL of ESXi or vCenter instance to connect to (same as VC_URL).
  • skipTLSVerify disables certificate verification (same as VC_INSECURE).
  • secretRef holds the name of the Kubernetes secret with the following form:
apiVersion: v1
kind: Secret
metadata:
  name: vsphere-credentials
type: kubernetes.io/basic-auth
stringData:
  # Same as VC_USERNAME
  username: ...
  # Same as VC_PASSWORD
  password: ...

Delivering Events

Let's focus on this part of the sample source:

# Where to send the events.
sink:
  uri: http://where.to.send.stuff

The simplest way to deliver events is to simply send them to an accessible endpoint as above, but there are a few additional options to explore.

To deliver events to a Kubernetes Service in the same namespace you can use:

# Where to send the events.
sink:
  ref:
    apiVersion: v1
    kind: Service
    name: the-service-name

To deliver events to a Knative Service (scales to zero) in the same namespace you can use:

# Where to send the events.
sink:
  ref:
    apiVersion: serving.knative.dev/v1
    kind: Service
    name: the-knative-service-name

To deliver events to a Knative Broker in the same namespace (e.g. here the default) you can use:

# Where to send the events.
sink:
  ref:
    apiVersion: eventing.knative.dev/v1beta1
    kind: Broker
    name: default

Configuring Checkpoint and Event Replay

Let's focus on this section of the sample source:

# Adjust checkpointing and event replay behavior
checkpointConfig:
  maxAgeSeconds: 300
  periodSeconds: 10

The Source controller will periodically checkpoint its progress in the vCenter event stream ("history") by using a Kubernetes ConfigMap as storage backend. The name of the ConfigMap is <name_of_source>-configmap (see example below). By default, checkpoints will be created every 10 seconds. The minimum checkpoint frequency is 1s but be aware of potential load on the Kubernetes API this might cause.

Upon start, the controller will look for an existing checkpoint (ConfigMap). If a valid one is found, and if it is within the history replay window (maxAgeSeconds, see below), it will start replaying the vCenter event stream from the timestamp specified in the checkpoint's "lastEventKeyTimestamp" key. If the timestamp is older than maxAgeSeconds, the controller will start replaying from maxAgeSeconds before the current vCenter time (UTC). If there is no existing checkpoint, the controller will not replay any events, regardless of what value is in maxAgeSeconds. This is to ensure that when upgrading from an earlier version of the controller where checkpointing was not implemented, no events will be accidentally replayed.

Checkpointing is useful to guarantee at-least-once event delivery semantics, e.g. to guard against lost events due to controller downtime (maintenance, crash, etc.). To influence the checkpointing logic, these parameters are available in spec.checkpointConfig:

  • periodSeconds:
    • Description: how often to save a checkpoint (RPO, recovery point objective)
    • Minimum: 1
    • Default (when 0 or unspecified): 10
  • maxAgeSeconds:
    • Description: the history window when replaying the event history (RTO, recovery time objective)
    • Minimum: 0 (disables event replay, see below)
    • Default: 300

⚠️ IMPORTANT: Checkpointing itself cannot be disabled and there will be exactly zero or one checkpoint per controller. If at-most-once event delivery is desired, i.e. no event replay upon controller start, simply set maxAgeSeconds: 0.

To reduce load on the Kubernetes API, a new checkpoint will not be saved under the following conditions:

  • When all events in a batch could not be sent to the sink (note: partial success, i.e. successful events in a batch until the first failed event will be checkpointed though)
  • When the vCenter event polling logic does not return any new events (note: fixed backoff logic is applied to reduce load on vCenter)

⚠️ IMPORTANT: When a VSphereSource is deleted, the corresponding checkpoint (ConfigMap) will also be deleted! Make sure to backup any checkpoint before deleting the VSphereSource if this is required for auditing/compliance reasons.

Here is an example of a JSON-encoded checkpoint for a VSphereSource named vc-source:

kubectl get cm vc-source-configmap -o jsonpath='{.data}'

# output edited for better readability
{
  "checkpoint": {
    "vCenter": "10.161.153.226",
    "lastEventKey": 17208,
    "lastEventType": "UserLogoutSessionEvent",
    "lastEventKeyTimestamp": "2021-02-15T19:20:35.598999Z",
    "createdTimestamp": "2021-02-15T19:20:36.3326551Z"
  }
}

Configuring CloudEvent Payload Encoding

Let's focus on this section of the sample source:

# Set the CloudEvent data encoding scheme to JSON
payloadEncoding: application/json

The default CloudEvent payload encoding scheme, i.e. datacontenttype, produced by a VSphereSource in the v1alpha1 API is application/xml. Alternatively, this can be changed to application/json as shown in the sample above. Other encoding schemes are currently not implemented.

Example Event Structure

Events received by the VSphereSource adapter from a VMware vSphere environment are wrapped into a standardized event format using the CloudEvent specification.

Events are delivered over HTTP using binary encoding. Hence, CloudEvent metadata, such as subject, source, etc. are represented in HTTP headers. The actual data (payload), i.e. vSphere event, is encoded in the body, using the configured payload encoding in the VSphereSource spec field.

The following example shows a VmPoweredOffEvent encoded as CloudEvent using HTTP binary transport mode.

CloudEvent HTTP Headers
{
  "Accept-Encoding": [
    "gzip"
  ],
  "Ce-Eventclass": [
    "event"
  ],
  "Ce-Id": [
    "41"
  ],
  "Ce-Knativearrivaltime": [
    "2022-03-21T16:35:41.2552037Z"
  ],
  "Ce-Source": [
    "vcsim.default.svc.cluster.local"
  ],
  "Ce-Specversion": [
    "1.0"
  ],
  "Ce-Time": [
    "2022-03-21T16:35:39.3101747Z"
  ],
  "Ce-Type": [
    "com.vmware.vsphere.VmPoweredOffEvent.v0"
  ],
  "Ce-Vsphereapiversion": [
    "6.5"
  ],
  "Content-Length": [
    "560"
  ],
  "Content-Type": [
    "application/json"
  ],
  "Forwarded": [
    "for=10.244.0.6;proto=http"
  ],
  "K-Proxy-Request": [
    "activator"
  ],
  "Prefer": [
    "reply"
  ],
  "Traceparent": [
    "00-9a162bdbd2eeb4f551625dbaf38fc850-b0c91e957c0d55a4-00"
  ],
  "User-Agent": [
    "Go-http-client/1.1"
  ],
  "X-Forwarded-For": [
    "10.244.0.6, 10.244.0.2"
  ],
  "X-Forwarded-Proto": [
    "http"
  ],
  "X-Request-Id": [
    "111a8255-1dec-4495-9aff-6300c27e7154"
  ]
}
CloudEvent HTTP body (Payload) using JSON encoding
{
  "Key": 41,
  "ChainId": 41,
  "CreatedTime": "2022-03-21T16:35:39.3101747Z",
  "UserName": "user",
  "Datacenter": {
    "Name": "DC0",
    "Datacenter": {
      "Type": "Datacenter",
      "Value": "datacenter-2"
    }
  },
  "ComputeResource": {
    "Name": "DC0_H0",
    "ComputeResource": {
      "Type": "ComputeResource",
      "Value": "computeresource-23"
    }
  },
  "Host": {
    "Name": "DC0_H0",
    "Host": {
      "Type": "HostSystem",
      "Value": "host-21"
    }
  },
  "Vm": {
    "Name": "DC0_H0_VM0",
    "Vm": {
      "Type": "VirtualMachine",
      "Value": "vm-57"
    }
  },
  "Ds": null,
  "Net": null,
  "Dvs": null,
  "FullFormattedMessage": "DC0_H0_VM0 on DC0_H0 in DC0 is powered off",
  "ChangeTag": "",
  "Template": false
}

Basic VSphereBinding Example

The VSphereBinding provides a simple mechanism for a user application to call into the vSphere API. In your application code, simply write:

import "github.com/vmware-tanzu/sources-for-knative/pkg/vsphere"

// This returns a github.com/vmware/govmomi.Client
client, err := New(ctx)
if err != nil {
	log.Fatalf("Unable to create vSphere client: %v", err)
}

// This returns a github.com/vmware/govmomi/vapi/rest.Client
restclient, err := New(ctx)
if err != nil {
	log.Fatalf("Unable to create vSphere REST client: %v", err)
}

This will authenticate against the bound vSphere environment with the bound credentials. This same code can be moved to other environments and bound to different vSphere endpoints without being rebuilt or modified!

Now let's take a look at how VSphereBinding makes this possible.

In order to bind an application to a vSphere endpoint, there are two key parts:

  1. The vCenter address and secret information (identical to Source above!)
  2. The application that is being bound (aka the "subject").
apiVersion: sources.tanzu.vmware.com/v1alpha1
kind: VSphereBinding
metadata:
  name: binding
spec:
  # Where to fetch the events, and how to auth.
  address: https://my-vsphere-endpoint.local
  skipTLSVerify: true
  secretRef:
    name: vsphere-credentials

  # Where to bind the endpoint and credential data.
  subject:
    apiVersion: apps/v1
    kind: Deployment
    name: my-simple-app

Authentication is identical to source, so let's take a deeper look at subjects.

Binding applications (aka subjects)

Let's focus on this part of the sample binding:

# Where to bind the endpoint and credential data.
subject:
  apiVersion: apps/v1
  kind: Deployment
  name: my-simple-app

In this simple example, the binding is going to inject several environment variables and secret volumes into the containers in this exact Deployment resource.

If you would like to target a selection of resources you can also write:

# Where to bind the endpoint and credential data.
subject:
  apiVersion: batch/v1
  kind: Job
  selector:
    matchLabels:
      foo: bar

Here the binding will apply to every Job in the same namespace labeled foo: bar, so this can be used to bind every Job stamped out by a CronJob resource.

At this point, you might be wondering: what kinds of resources does this support? We support binding all resources that embed a Kubernetes PodSpec in the following way (standard Kubernetes shape):

spec:
  template:
    spec: # This is a Kubernetes PodSpec.
      containers:
      - image: ...
      ...

This has been tested with:

  • Knative Service and Configuration
  • Deployment
  • Job
  • DaemonSet
  • StatefulSet

Changing Log Levels

All components follow Knative logging convention and use the zap structured logging library. The log level (debug, info, error, etc.) is configurable per component, e.g. vsphere-source-webhook, VSphereSource adapter, etc.

The default logging level is info. The following sections describe how to change the individual component log levels.

Source Adapter Log Level

The log level for adapters, e.g. a particular VSphereSource deployment can be changed at runtime via the config-logging ConfigMap which is created when deploying the Tanzu Sources for Knative manifests in this repository.

⚠️ Note: These settings will affect all adapter deployments. Changes to a particular adapter deployment are currently not possible.

kubectl -n vmware-sources edit cm config-logging

An interactive editor opens. Change the settings in the JSON object under the zap-logger-config key. For example, to change the log level from info to debug use this configuration in the editor:

apiVersion: v1
data:
  # details omitted
  zap-logger-config: |
    {
      "level": "debug"
      "development": false,
      "outputPaths": ["stdout"],
      "errorOutputPaths": ["stderr"],
      "encoding": "json",
      "encoderConfig": {
        "timeKey": "ts",
        "levelKey": "level",
        "nameKey": "logger",
        "callerKey": "caller",
        "messageKey": "msg",
        "stacktraceKey": "stacktrace",
        "lineEnding": "",
        "levelEncoder": "",
        "timeEncoder": "iso8601",
        "durationEncoder": "",
        "callerEncoder": ""
      }
    }

Save and leave the interactive editor to apply the ConfigMap changes. Kubernetes will validate and confirm the changes:

configmap/config-logging edited

To verify that the Source adapter owners (e.g. vsphere-source-webhook for a VSphereSource) have noticed the desired change, inspect the log messages of the owner (here: vsphere-source-webhook) Pod:

vsphere-source-webhook-f7d8ffbc9-4xfwl vsphere-source-webhook {"level":"info","ts":"2022-03-29T12:25:20.622Z","logger":"vsphere-source-webhook","caller":"vspheresource/vsphere.go:250","msg":"update from logging ConfigMap{snip...}

⚠️ Note: To avoid unwanted disruption during event retrieval/delivery, the changes are not applied automatically to deployed adapters, i.e. VSphereSource adapter, etc. The operator is in full control over the lifecycle (downtime) of the affected Deployment(s).

To make the changes take affect for existing adapter Deployment, an operator needs to manually perform a rolling upgrade. The existing adapter Pod will be terminated and a new instanced created with the desired log level changes.

kubectl get vspheresource
NAME                SOURCE                     SINK                                                                              READY   REASON
example-vc-source   https://my-vc.corp.local   http://broker-ingress.knative-eventing.svc.cluster.local/default/example-broker   True

kubectl rollout restart deployment/example-vc-source-adapter
deployment.apps/example-vc-source-adapter restarted

⚠️ Note: To avoid losing events due to this (brief) downtime, consider enabling the Checkpointing capability.

Controller and Webhook Log Level

Each of the available Tanzu Sources for Knative is backed by at least a particular webhook, e.g. vsphere-source-webhook and optionally a controller.

💡 Note: The VSphereSource and VSphereBinding implementation uses a combined deployment vsphere-source-webhook for the webhook and controller

Just like with the adapter Deployment, the log level for webhook and controller instances can be changed at runtime.

kubectl -n vmware-sources edit cm config-logging

An interactive editor opens. Change the corresponding component log level under the respective component key. The following example shows how to change the log level for the combined VSphereSource webhook and controller component from info to debug:

apiVersion: v1
data:
  loglevel.controller: info # generic knative settings, ignore this
  loglevel.webhook: info # generic knative settings, ignore this
  loglevel.vsphere-source-webhook: debug # <- changed from info to debug
  zap-logger-config: |
    {
      "level": "info",
      "development": false,
      "outputPaths": ["stdout"],
      "errorOutputPaths": ["stderr"],
    # details omitted

Save and leave the interactive editor to apply the ConfigMap changes. Kubernetes will validate and confirm the changes:

configmap/config-logging edited

To verify the changes, inspect the log messages of the vsphere-source-webhook Pod:

vsphere-source-webhook-f7d8ffbc9-4xfwl vsphere-source-webhook {"level":"info","ts":"2022-03-29T12:22:25.630Z","logger":"vsphere-source-webhook","caller":"logging/config.go:209","msg":"Updating logging level for vsphere-source-webhook from info to debug.","commit":"26d67c5"}

sources-for-knative's People

Contributors

benmoss avatar dependabot[bot] avatar dprotaso avatar embano1 avatar evankanderson avatar fbiville avatar gab-satchi avatar gabo1208 avatar joeeltgroth avatar kauzclay avatar knative-automation avatar mattmoor avatar n3wscott avatar rguske avatar vaikas avatar xtreme-sameer-vohra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sources-for-knative's Issues

Improve the VSphereBinding experience with PowerCLI

Right now the PowerCLI sample requires the following lines to set up the injected authentication:

# Log into the VI Server
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null
Connect-VIServer -Server ([System.Uri]$env:GOVC_URL).Host -User $env:GOVC_USERNAME -Password $env:GOVC_PASSWORD

I believe that in our goal state, the Binding will have configured the environment such that these lines can simply be dropped.

Update CRDs to v1 APIs

Issue: Warning: apiextensions.k8s.io/v1beta1 CustomResourceDefinition is deprecated in v1.16+, unavailable in v1.22+; use apiextensions.k8s.io/v1 CustomResourceDefinition

Consider using EventHistoryCollector instead of event manager

Event manager in govmomi has certain limitations and defaults which can lead to undesirable effects on the end user side, e.g. hardcoded duplication of lastPage events after start, no support for event replays, unordered event page delivery, etc.

The EventHistoryCollector does not have these limitations and provides the following advantages:

  • granular control over event stream, including support for (manual) backoff to reduce polling frequency/API calls
  • server-side event filtering
  • ordered event key delivery (monotonically increasing)
  • event replay via BeginTime in EventFilterSpecByTime

Unfortunately, vcsim has an incorrect implementation of the event stream leading to issues when using this API, see 2134. This leads to test drift when running against vcsim vs. vcenter.

Related: #118

Support event replay (at-least-once semantics)

Currently there is no support for redelivering events in case of cloud events send fails after retries (no ACK), the vsphere source crashes/reboots, etc. Supporting at-least-once event delivery semantics would be desirable so that we don't skip/lose vsphere events in these scenarios.

A simple approach could be local file checkpointing (with optional strong persistence) to capture the last successfully ACK-ed event. E.g. in VEBA we use this file structure:

{
  "vCenter": "10.0.0.1",
  "lastEventUUID": "f8d71cb0-fd66-4e3b-aae1-b62d4576bf40",
  "lastEventKey": 26071,
  "lastEventType": "UserLogoutSessionEvent",
  "lastEventKeyTimestamp": "2020-10-13T08:05:36.792Z",
  "createdTimestamp": "2020-10-13T08:05:55.534638Z"
}

This file is read after startup and the event stream is started from lastEventKeyTimestamp (starting from key/offset is not supported in the public API). A time limit range can be set to have an upper bound for the starting point, e.g. t.Now()-1h.

Related: #119

Add subject to Cloud Event

As mentioned in the comment the cloud events subject is currently not set for vSphere events.

// TODO(mattmoor): Consider setting the subject

Since vSphere events can be arbitrary (Alerts, VM related events, 3rd party, etc.), i.e. there is not a standard/stable definition of subject, the question is whether subject can (should) be set on a vCenter cloud event. There are definitely valid use cases, e.g. setting the VM moRef for a VmPoweredOnEvent or host moRef for a EnteredMaintenanceModeEvent.

Since moRef is composed of a type and value, a composite key for subject might be useful, e.g. VirtualMachine/vm-56.

Update the test.TLegacy since it was deprecated upstream.

Lint started to fail with this:

  Running [/home/runner/golangci-lint-1.30.0-linux-amd64/golangci-lint run --out-format=github-actions] in [] ...
  Error: SA1019: test.TLegacy is deprecated: Do not use this. Define your own interface.  (staticcheck)

Add `version` field to spec

Is your feature request related to a problem? Please describe.
The currently produced events (CE envelop schema) by VSphereSources might break in the future (event types indicate this via .v0), e.g. once we gained enough user feedback.

Describe the solution you'd like
Give users control over CE envelop schema changes via a .spec field, e.g. .spec.version to control events produced as .v0 or stable .v1 contract.

Describe alternatives you've considered

  • Keep as is
  • Document and break
  • VSphereSource API change, e.g. v1beta1

Additional context
This is future-looking since we currently don't produce .v1 versions.

PowerCLI sample

We should make a sample that uses a containerized PowerCLI to script against the API.

This article makes me think we should have our binding setting up the equivalent of: %APPDATA%\VMware\credstore\vicredentials.xml

Add option to verify vsphere credentials

When creating the vsphere login credentials with the kn-vsphere plugin user might want to optionally verify the passed credentials against vsphere before creating the secret and running into crash-loop backoff at a later stage.

Error on send: extension:EventEx: invalid CloudEvents value

Cloud event validation fails for EventEx types:

metrics reporter error: invalid value: only ASCII characters accepted; max length must be 255 characters

{
  "level": "error",
  "ts": "2020-10-27T10:30:38.018Z",
  "logger": "vspheresource",
  "caller": "vsphere/adapter.go:109",
  "msg": "failed to send cloudevent",
  "commit": "0162051",
  "error": "extension:EventEx: invalid CloudEvents value: types.EventEx{Event:types.Event{DynamicData:types.DynamicData{}, Key:36795, ChainId:36795, CreatedTime:time.Time{wall:0x2d8c2800, ext:63739391436, loc:(*time.Location)(nil)}, UserName:\"[email protected]\", Datacenter:(*types.DatacenterEventArgument)(nil), ComputeResource:(*types.ComputeResourceEventArgument)(nil), Host:(*types.HostEventArgument)(nil), Vm:(*types.VmEventArgument)(nil), Ds:(*types.DatastoreEventArgument)(nil), Net:(*types.NetworkEventArgument)(nil), Dvs:(*types.DvsEventArgument)(nil), FullFormattedMessage:\"Successful login [email protected] from 10.93.149.239 at 10/27/2020 10:28:22 UTC in SSO\", ChangeTag:\"\"}, EventTypeId:\"com.vmware.sso.LoginSuccess\", Severity:\"info\", Message:\"\", Arguments:[]types.KeyAnyValue{types.KeyAnyValue{DynamicData:types.DynamicData{}, Key:\"description\", Value:\"User [email protected]@10.93.149.239 logged in with response code 200\"}, types.KeyAnyValue{DynamicData:types.DynamicData{}, Key:\"timestamp\", Value:\"10/27/2020 10:28:22 UTC\"}, types.KeyAnyValue{DynamicData:types.DynamicData{}, Key:\"userName\", Value:\"[email protected]\"}, types.KeyAnyValue{DynamicData:types.DynamicData{}, Key:\"userIp\", Value:\"10.93.149.239\"}, types.KeyAnyValue{DynamicData:types.DynamicData{}, Key:\"_sourcehost_\", Value:\"sc2-10-186-34-28.eng.vmware.com\"}}, ObjectId:\"\", ObjectType:\"\", ObjectName:\"\", Fault:(*types.LocalizedMethodFault)(nil)}\n\nmetrics reporter error: invalid value: only ASCII characters accepted; max length must be 255 characters",
  "stacktrace": "github.com/vmware-tanzu/sources-for-knative/pkg/vsphere.(*vAdapter).sendEvents.func1\n\tgithub.com/vmware-tanzu/sources-for-knative/pkg/vsphere/adapter.go:109\ngithub.com/vmware/govmomi/event.(*eventProcessor).process\n\tgithub.com/vmware/[email protected]/event/processor.go:148\ngithub.com/vmware/govmomi/event.(*eventProcessor).run.func1\n\tgithub.com/vmware/[email protected]/event/processor.go:102\ngithub.com/vmware/govmomi/property.Wait.func1\n\tgithub.com/vmware/[email protected]/property/wait.go:64\ngithub.com/vmware/govmomi/property.WaitForUpdates\n\tgithub.com/vmware/[email protected]/property/wait.go:146\ngithub.com/vmware/govmomi/property.Wait\n\tgithub.com/vmware/[email protected]/property/wait.go:62\ngithub.com/vmware/govmomi/event.(*eventProcessor).run\n\tgithub.com/vmware/[email protected]/event/processor.go:101\ngithub.com/vmware/govmomi/event.Manager.Events\n\tgithub.com/vmware/[email protected]/event/manager.go:188\ngithub.com/vmware-tanzu/sources-for-knative/pkg/vsphere.(*vAdapter).Start\n\tgithub.com/vmware-tanzu/sources-for-knative/pkg/vsphere/adapter.go:82\nknative.dev/eventing/pkg/adapter/v2.MainWithInformers\n\tknative.dev/[email protected]/pkg/adapter/v2/main.go:198\nknative.dev/eventing/pkg/adapter/v2.MainWithEnv\n\tknative.dev/[email protected]/pkg/adapter/v2/main.go:105\nknative.dev/eventing/pkg/adapter/v2.MainWithContext\n\tknative.dev/[email protected]/pkg/adapter/v2/main.go:80\nmain.main\n\tgithub.com/vmware-tanzu/sources-for-knative/cmd/sources-for-knative-adapter/main.go:27\nruntime.main\n\truntime/proc.go:204"
}

Note: Using an updated go.mod to fix a nil pointer issue:

diff --git a/go.mod b/go.mod
index 93348e2..524f941 100644
--- a/go.mod
+++ b/go.mod
@@ -18,15 +18,15 @@ require (
        github.com/yudai/hcl v0.0.0-20151013225006-5fa2393b3552 // indirect
        github.com/yudai/umutex v0.0.0-20150817080136-18216d265c6b // indirect
        go.uber.org/zap v1.15.0
-       golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de
+       golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
        gotest.tools v2.2.0+incompatible
        k8s.io/api v0.18.8
        k8s.io/apimachinery v0.18.8
        k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
        k8s.io/code-generator v0.18.8
        k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
-       knative.dev/eventing v0.18.1-0.20201022155237-554e4b306de4
-       knative.dev/pkg v0.0.0-20201023012137-324e49bc7fe1
+       knative.dev/eventing v0.18.1-0.20201027101233-960e26bf754a
+       knative.dev/pkg v0.0.0-20201026232541-37583c54bfc3
 )

Webhook Crashloop backoff with K8s <1.18

Webhook controller fails on older K8s versions:

{"severity":"EMERGENCY","timestamp":"2021-04-06T09:36:06.8368222Z","logger":"webhook","caller":"sharedmain/main.go:287","message":"Version check failed","commit":"ff4e0e5","error":"kubernetes version \"1.17.0\" is not compatible, need at least \"1.18.0-\" (this can be overridden with the env var \"KUBERNETES_MIN_VERSION\")","stacktrace":"knative.dev/pkg/injection/sharedmain.CheckK8sClientMinimumVersionOrDie\n\tknative.dev/[email protected]/injection/sharedmain/main.go:287\nknative.dev/pkg/injection/sharedmain.MainWithConfig\n\tknative.dev/[email protected]/injection/sharedmain/main.go:184\nmain.main\n\tgithub.com/vmware-tanzu/sources-for-knative/cmd/sources-for-knative-controller/main.go:139\nruntime.main\n\truntime/proc.go:225"}

Can't get/list brokers.eventing.knative.dev

Tried to deploy this VSphereSource:

apiVersion: sources.tanzu.vmware.com/v1alpha1
kind: VSphereSource
metadata:
  name: vcsimsource
spec:
 sink:
   ref:
    apiVersion: eventing.knative.dev/v1
    kind: Broker
    name: potato
    namespace: default
 address: https://vcsim.default.svc.cluster.local
 skipTLSVerify: true
 secretRef:
   name: vsphere-credentials

and saw the error brokers.eventing.knative.dev "Lister" not found in the events of the object.

It seems like this controller should have a binding to the addressable-resolver ClusterRole so that it can resolve any ref that's participating in the addressable duck type.

Wasn't sure if this means that the podspecable binding that we have today is in error or if we need both of them.

`kn` plugin

We should build and release a kn plugin for the VMware sources and bindings.

I'd propose a surface like:

  1. login: create the vsphere-credentials Secret with the appropriate shape,
  2. vspheresource(?): create the source from an address + credentials and sink,
  3. vspherebinding(?): create the binding from an address + credentials and subject.

This should:

Bump versions up

Bump some versions on the e2e workflows or at least update the description to match the version:
here

Use envconfig

We should use envconfig from "github.com/kelseyhightower/envconfig"

Originally posted by @n3wscott in #4

Refactor `kn vsphere` plugin to add list commands

Is your feature request related to a problem? Please describe.
kn vsphere does not support list operations and certain commands, like login can be improved in wording/usability for the target persona.

Describe the solution you'd like
Allow for equivalent kn broker [list|create|delete] usage.

Describe alternatives you've considered
Keep as is.

Additional context
Add any other context or screenshots about the feature request here.

Add `vsphereapiversion` CE attribute

Even though not explicitly stated, event schemas for vSphere are tied to a particular vSphere release, i.e. could break between major releases (even minor). Currently there is no way to detect the vSphere version that generated a particular event. This could lead to decoding errors in functions if a schema breaks in a non-compatible way between vSphere releases.

Ideally, vSphere events should carry a version indicating the schema version/contract consumers can rely on. Providing OpenAPI schemas would be neat to but seems not feasible as an implementation in vSphere currently.

The short-term solution would be to use a custom context attribute vsphereapiversion to reflect the vSphere API version an adapter is connected to.

SHELLCHECK issues

shellcheck reports these issues on upload_test_images.sh:

  • Double quote to prevent globbing and word splitting.
  • This redirection overrides piped input. To use both, merge or pass filenames.

Also, the script hangs in a local terminal due to the second shellchec issue reported.

Save the planet

Don't create multi-arch images in workflows unless needed :)

Use DEBUG logging

Certain logs should be DEBUG, e.g. when no new events are received, backoff, etc.

Update docs / samples with CLI

  • How to install the plugin? We have a tab under optional stuff here, but not sure what the best-practice is for CLI plugins (ask Roland?).
  • Show using the plugin in samples/

cc @fbiville

Populate vms.Status.CloudEventAttributes

See:

	// CloudEventAttributes are the specific attributes that the Source uses
	// as part of its CloudEvents.
	// +optional
	CloudEventAttributes []CloudEventAttributes `json:"ceAttributes,omitempty"`

We don't populate this in our VSphereSource, but perhaps we should?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.