K8s 上的 IotEdge:创建选项以添加 Pod/Deployment 注释(例如 dapr)

IotEdge on K8s: createOptions to add Pod/Deployment annotations (e.g. dapr)

我们在 kubernetes 上使用 iotedge,我正在寻找一种方法将 dapr sidecars 添加到已部署的 iothub 模块。

是否有任何其他自定义 createOptions 可用于绕过 iothub 抽象?

更具体地说:在 Pod/Deployment 清单中需要特殊的 dapr 注释,以便 Dapr Sidecar Injector 可以工作。

  annotations:
    dapr.io/enabled: "true"
    dapr.io/app-id: "nodeapp"
    dapr.io/app-port: "3000"
    there would need to be some  

我发现的可能的 createOptions 的快速摘要:

"createOptions": {
   "Env": [
      "storageFolder=/storage"
   ],
    "HostConfig": {
      "PortBindings": {
        "5671/tcp": [{
          "HostPort": "5671"
        }],
        "8883/tcp": [{
          "HostPort": "8883"
        }],
        "443/tcp": [{
          "HostPort": "443"
        }]
      }
    },
    "Labels": {
        "cqTargetPort": "80",
        "cqTargetRoute": "machine-api",
        "skipMiddleware": "false"
   }
   "k8s-experimental": {
     "volumes": [{
       "volume": {
         "name": "pvcvol",
         "persistentVolumeClaim": {
           "claimName": "azurefile"
         }
       },
       "volumeMounts": [{
         "name": "pvcvol",
         "mountPath": "/storage"
       }]
     }]
   }
}

iotedge on k8s

createOptions.Labelstranslated into pod annotations。所以你可以把需要的Dapr注解作为模块的标签:

metadata

name = Name will be the module name, sanitized to be a K8s identifier. namespace = The given namespace. labels = Default label set. annotations = The pod's metadata will have one fixed annotation: net.azure-devices.edge.original-moduleid = unsanitized module id from edge deployment specification. then settings.createOptions.Labels will be added to the pod's annotations.

无法“选择退出”注入 iotedge 代理,但它应该是良性的,即使它与 Dapr 的注入边车共同存在。我还没有测试过这个,所以如果它适合你,请告诉我们!