【问题标题】:Add consul connect sidecar to pods of a kubernetes helm deployment将 consul connect sidecar 添加到 kubernetes helm 部署的 pod
【发布时间】:2020-03-27 18:00:22
【问题描述】:

我想将 Consul connect sidecar 添加到 kubernetes pod。

我已经在我的 Consul 集群中安装了 consul 注入器。我在文档中发现了这种添加注入注释的方法:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: static-server
---
apiVersion: v1
kind: Pod
metadata:
  name: static-server
  annotations:
    "consul.hashicorp.com/connect-inject": "true"
spec:
  containers:
    # This name will be the service name in Consul.
    - name: static-server
      image: hashicorp/http-echo:latest
      args:
        - -text="hello world"
        - -listen=:8080
      ports:
        - containerPort: 8080
          name: http
   # If ACLs are enabled, the serviceAccountName must match the Consul service name.
  serviceAccountName: static-server

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

有没有人尝试使用部署/状态集的 pod 建立 consul sidecar envoy?

【问题讨论】:

    标签: kubernetes consul service-discovery


    【解决方案1】:

    一个用于部署的示例。你也可以在 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-

    【讨论】:

      猜你喜欢
      • 2020-06-02
      • 2021-12-12
      • 2021-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 2020-07-20
      相关资源
      最近更新 更多