Skip to content

Instantly share code, notes, and snippets.

@evankanderson
evankanderson / DoTheThing.java
Last active October 12, 2018 17:46
Knative simplest event source
import com.fasterxml.jackson.databind.ObjectMapper;
import io.streamzi.cloudevents.CloudEvent;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.enterprise.event.Event;
class DoTheThing implements Runnable {
// Set up class, etc
// ...
@evankanderson
evankanderson / 0-Description.md
Last active February 15, 2019 22:37
Auto-creation of black-box sources
  1. This is very high-level and half baked.
  2. This is intended to suggest one way that black-box sources could be auto-created in specific circumstances from a declaration of interest in events.
  3. This assumes a model somewhat similar to Broker and Trigger (called Broker and Rules here) with the following additions:
    1. The Rule has a filter expression which matches more than event types. I've used CEL here.
    2. There is a process which propagates "upstream" (i.e. from consumer to origin) the set of filters currently listening.
  4. We use an annotation, eventing.knative.dev/filter, as a way to copy filters from the Rules upstream through the components towards the event origin. Using an annotation allows non-filtering entities (such as Channel or Subscription) to propagate their filters upstream, even though they don't perform any filtering of their own.
  5. This assumes that the user has also made github-enabled secrets available to the default serv
@evankanderson
evankanderson / Command.
Created August 13, 2019 00:19
Knative 0.8 release notes from kubernetes release-notes tool
release-notes -start-sha=cb5c1810f2690efa0c434bc81aab3a1d45df497f \
-end-sha=3f73b117b61ee5d8fe5dcedd6cca2c96014329a9 \
-github-org=knative -github-repo=serving -requiredAuthor='' \
-output /tmp/serving-relnotes
@evankanderson
evankanderson / callback.go
Last active March 31, 2020 22:50
What I want with callbacks.
// Callback is a generic function to be called by a consumer of validation
type Callback struct {
callback func(ctx context.Context, unstructured *unstructured.Unstructured) error
supportedVerbs map[admissionv1beta1.Operation]bool
}
func (c Callback) Process(....) {
// Do some stuff
}
@evankanderson
evankanderson / policy.yaml
Last active April 7, 2020 17:03
Inbound access control alternatives
apiGroup: security.knative.dev/v1alpha1
kind: Policy
metadata:
name: green-policy
spec:
cloudEvent:
type: green
# Or
cloudEventExpressions:
- {key: type, operator: In, values: [green]}
apiGroup: security.knative.dev/v1alpha1
kind: PolicyBinding
metadata:
name: green-service
spec:
policy: green-policy
targets:
- apiGroup: serving.knative.dev/v1
kind: Service
selector:
{"client":"github","component":"unset","file":"prow/github/client.go:562","func":"k8s.io/test-infra/prow/github.(*client).log","level":"info","msg":"GetOrg(knative-sandbox)","time":"2020-05-20T06:26:35-07:00"}
{"client":"github","component":"unset","file":"prow/github/client.go:562","func":"k8s.io/test-infra/prow/github.(*client).log","level":"info","msg":"ListOrgInvitations(knative-sandbox)","time":"2020-05-20T06:26:35-07:00"}
{"client":"github","component":"unset","file":"prow/github/client.go:562","func":"k8s.io/test-infra/prow/github.(*client).log","level":"info","msg":"User()","time":"2020-05-20T06:26:36-07:00"}
{"client":"github","component":"unset","file":"prow/github/client.go:562","func":"k8s.io/test-infra/prow/github.(*client).log","level":"info","msg":"ListOrgMembers(knative-sandbox, admin)","time":"2020-05-20T06:26:37-07:00"}
{"client":"github","component":"unset","file":"prow/github/client.go:562","func":"k8s.io/test-infra/prow/github.(*client).log","level":"info","msg":"ListOrgMembers(knative-sa
kn service update hello \
--env TARGET="Knative from v2" \
--revision-name hello-v2 \
--tag hello-v2=v2 \
--tag $(kubectl get ksvc hello --template='{{.status.latestReadyRevisionName}}')=v1 \
--traffic v1=75,v2=25
@evankanderson
evankanderson / config.yaml
Last active December 17, 2020 22:47
Serving config for 3 ingress options
serving-istio:
primary:
github:
repo: "knative/serving"
include:
- ".*.yaml"
exclude:
- "monitoring.*"
- "serving.yaml"
- "serving-storage-version-migration.yaml"
@evankanderson
evankanderson / Func demo setup script
Last active February 28, 2022 20:06
Kn plugin func binary research install script
#!/bin/sh
# Assumes Docker desktop installed
#
VARIANT="$(uname -sm | tr 'A-Z ' 'a-z-' | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)"
FUNC_VARIANT="$(echo $VARIANT | tr '-' '_')"
curl -L -o kn https://github.com/knative/client/releases/download/knative-v1.2.0/kn-$VARIANT
curl -L -o kn-plugin-quickstart https://github.com/knative-sandbox/kn-plugin-quickstart/releases/download/knative-v1.2.0/kn-quickstart-$VARIANT