首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SinkBinding未能注入K_SINK环境变量

SinkBinding未能注入K_SINK环境变量
EN

Stack Overflow用户
提问于 2021-05-26 08:59:26
回答 1查看 125关注 0票数 1

我正在尝试设置一个K本机事件管道,其中存在一个容器,该容器接受外部gRPC请求,并将事件激发到代理中以供进一步处理。

在我的玩具示例中,我未能使用SinkBinding注入K_SINK环境变量。这是我的配置的相关部分:

代码语言:javascript
复制
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

由于缺少环境变量,我的容器陷入了无限崩溃循环。

SinkBinding对象似乎没有问题:

代码语言:javascript
复制
$ 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    

系统信息:

代码语言:javascript
复制
$ 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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-26 10:40:15

SinkBinding对象具有使用标签选择器配置的主题:

代码语言:javascript
复制
subject:
  apiVersion: apps/v1
  kind: Deployment
  selector:
    matchLabels:
      app: ease-pipeline-server

但是,在Deployment对象上没有设置这样的标签:

代码语言:javascript
复制
metadata:
  name: ease-pipeline-server
  # no labels

这里的解决办法是:

  • 向部署的metadata添加相应的标签 元数据:名称:轻松管道-服务器标签: app:轻松-管道-服务器
  • 在部署的name (API文档)上使用主题匹配 主题: apiVersion: app/v1类:部署名称:轻松管道服务器
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67701721

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档