将consul connect sidecar添加到kubernetes头盔部署的Pod中

时间:2020-03-27 18:00:22

标签: kubernetes consul service-discovery

我想将Consul connect sidecar添加到kubernetes容器中。

我已经在Consul集群中安装了Consul注射器。我在文档中找到了添加注射批注的这种方式:

Type your command:insert 4 5 6
Type your command:print
['4', '5', '6']
Type your command:insert 7 8 9
Type your command:print
['7', '8', '9']
Type your command:hello
Command is not supported.

但是,在我的K8s集群中,当前有全状态集和部署。我在文档中发现您无法注释部署。

有人尝试过用部署/状态全套的豆荚建立领事边车特使吗?

1 个答案:

答案 0 :(得分:3)

一个用于部署的示例。您也可以在StatefulSet中完成该操作。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: consul-example-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: consul-example
  template:
    metadata:
      labels:
        app: consul-example
      annotations:
        "consul.hashicorp.com/connect-inject": "true"
    spec:
      containers:
        - name: consul-example
          image: "nginx"
      serviceAccountName: consul-example

https://www.consul.io/docs/platform/k8s/connect.html#deployments-statefulsets-etc-