I am trying to set up a Knative eventing pipeline, where exists a container that accepts external gRPC requests and fires events into a broker for further processing.
In my toy example, I am failing to use SinkBinding to inject K_SINK
environment variable. This is the relevant section of my configuration:
apiVersion: v1
kind: Namespace
metadata:
name: bora-namespace
labels:
eventing.knative.dev/injection: enabled
---
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
name: my-broker
namespace: bora-namespace
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ease-pipeline-server
namespace: bora-namespace
spec:
replicas: 1
selector:
matchLabels:
app: ease-pipeline-server
template:
metadata:
labels:
app: ease-pipeline-server
spec:
containers:
- name: ease-pipeline-server
image: docker.io/boramalper/ease-pipeline-server:latest
imagePullPolicy: Always
---
apiVersion: sources.knative.dev/v1
kind: SinkBinding
metadata:
name: bind-ease-pipeline-server
namespace: bora-namespace
spec:
subject:
apiVersion: apps/v1
kind: Deployment
selector:
matchLabels:
app: ease-pipeline-server
sink:
ref:
apiVersion: eventing.knative.dev/v1
kind: Broker
name: my-broker
---
kind: Service
apiVersion: v1
metadata:
name: ease-pipeline-server
namespace: bora-namespace
spec:
type: NodePort
selector:
app: ease-pipeline-server
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30002
My container gets stuck in an infinite crash loop due to missing environment variable.
The SinkBinding object seems to have no issues:
$ kubectl --namespace bora-namespace get sinkbinding
NAME SINK AGE READY REASON
bind-ease-pipeline-server http://broker-ingress.knative-eventing.svc.cluster.local/bora-namespace/my-broker 22m True
System information:
$ kn version
Version: v20210526-local-0c6ef82
Build Date: 2021-05-26 06:34:50
Git Revision: 0c6ef82
Supported APIs:
* Serving
- serving.knative.dev/v1 (knative-serving v0.23.0)
* Eventing
- sources.knative.dev/v1 (knative-eventing v0.23.0)
- eventing.knative.dev/v1 (knative-eventing v0.23.0)
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.6", GitCommit:"8a62859e515889f07e3e3be6a1080413f17cf2c3", GitTreeState:"clean", BuildDate:"2021-04-15T03:28:42Z", GoVersion:"go1.15.10", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.7", GitCommit:"132a687512d7fb058d0f5890f07d4121b3f0a2e2", GitTreeState:"clean", BuildDate:"2021-05-12T12:32:49Z", GoVersion:"go1.15.12", Compiler:"gc", Platform:"linux/amd64"}
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
$ uname -a
Linux REDACTED 4.15.0-137-generic #141-Ubuntu SMP Fri Feb 19 13:46:27 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
The
SinkBinding
object has a subject configured using a label selector:However, there is no such label set on the
Deployment
object:The solution here would be to either:
add the corresponding label(s) to the Deployment's
metadata
use a subject matching on the Deployment's
name
(API documentation)