将领事联系车连接到kubernetes头盔部署的吊舱中

问题描述 投票:0回答:1

我想将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集群中,目前有全状态集和部署。我在文档中发现您无法注释部署。

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

kubernetes consul service-discovery
1个回答
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-

© www.soinside.com 2019 - 2024. All rights reserved.