HashiCorp Consul

详细介绍了关于 HashiCorp Consul 状态存储 组件的信息

配置

要设置HashiCorp Vault状态存储,请创建一个类型为state.consul的组件。 请参阅本指南,了解如何创建和应用状态存储配置。

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Component
  3. metadata:
  4. name: <NAME>
  5. namespace: <NAMESPACE>
  6. spec:
  7. type: state.consul
  8. version: v1
  9. metadata:
  10. - name: datacenter
  11. value: <REPLACE-WITH-DATA-CENTER> # Required. Example: dc1
  12. - name: httpAddr
  13. value: <REPLACE-WITH-CONSUL-HTTP-ADDRESS> # Required. Example: "consul.default.svc.cluster.local:8500"
  14. - name: aclToken
  15. value: <REPLACE-WITH-ACL-TOKEN> # Optional. default: ""
  16. - name: scheme
  17. value: <REPLACE-WITH-SCHEME> # Optional. default: "http"
  18. - name: keyPrefixPath
  19. value: <REPLACE-WITH-TABLE> # Optional. default: ""

Warning

以上示例将密钥明文存储, It is recommended to use a secret store for the secrets as described here.

元数据字段规范

字段必填详情Example
datacenterYDatacenter“dc1”
httpAddrYConsul 服务器地址“consul.default.svc.cluster.local:8500”
aclTokenN请求 ACL 令牌。 默认值 “”“token”
schemeNScheme 是Consul服务器的 URI 方案。 默认值 “http”“http”
keyPrefixPathNConsul中的密钥前缀路径. 默认值 “”“dapr”

搭建 Hashicorp Consul

您可以使用 Docker 在本地运行Consul:

  1. docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 consul

然后您可以使用 localhost:8500 与服务器交互。

The easiest way to install Consul on Kubernetes is by using the Helm chart:

  1. helm install consul stable/consul

This installs Consul into the default namespace. To interact with Consul, find the service with: kubectl get svc consul.

For example, if installing using the example above, the Consul host address would be:

consul.default.svc.cluster.local:8500

相关链接