简体   繁体   English

如何在领事(Hashicorp-consul)中将保险库(Hashicorp-vault)注册为服务,我使用的是kubernetes?

[英]How to register vault (Hashicorp-vault) as a service in consul (Hashicorp-consul), I am using kubernetes?

I'm running vault and consul as pods in kubernetes, while I'm checking consul catalog service it shows consul alone.我在 kubernetes 中将 vault 和 consul 作为 pod 运行,而我正在检查consul catalog service它仅显示consul

How can I register vault as a service ?如何将vault as a service注册vault as a service

I'd tried with the following link, but it didn't work.我曾尝试使用以下链接,但没有奏效。 https://learn.hashicorp.com/consul/getting-started/services https://learn.hashicorp.com/consul/getting-started/services

For registering vault as a service you will have to do the following steps要将保管库注册为服务,您必须执行以下步骤

  1. Create a file and write this {"service": {"name": "vault", "tags": ["vault-tag"], "port": 8200}} into it.创建一个文件并将此{"service": {"name": "vault", "tags": ["vault-tag"], "port": 8200}}写入其中。 Name it as vault.json将其命名为vault.json
  2. Now, enter this command consul services register vault.json现在,输入这个命令consul services register vault.json
  3. You can now see that vault is registered as a service您现在可以看到保管库已注册为服务Vault 注册和检查 consul 目录服务

Vault will automatically register with consul when using consul as a backend datastorage.当使用 consul 作为后端数据存储时,Vault 会自动向 consul 注册。 If you are using one of the other storage options you have 2 ways to do it:如果您使用其他存储选项之一,则有两种方法可以做到:

Vault >1.4保险库 >1.4

If you have vault 1.4 or newer, you can add the following to the vault config to automatically register the vault service in consul如果您有 vault 1.4 或更高版本,您可以将以下内容添加到 vault 配置中以在 consul 中自动注册 vault 服务

service_registration "consul" {
  address      = "127.0.0.1:8500"
}

Vault < 1.4保险库 < 1.4

Assuming you are running vault with https on port 8200假设您在端口 8200 上使用 https 运行保管库

{
  "service": {
    "checks": [
      {
        "http": "https://vault1.example.com:8200/v1/sys/health",
        "id": "port",
        "interval": "10s",
        "name": "vault running on port 8200",
        "timeout": "1s"
      }
    ],
    "enable_tag_override": false,
    "id": "vault",
    "meta": {
      "meta": "Vault"
    },
    "name": "vault",
    "port": 8200,
    "tags": []
  }
}

Note This won't provide the dynamic tags like active or standby that you get automatically with the other options.注意这不会提供动态标签,如使用其他选项自动获得的activestandby https://www.vaultproject.io/docs/configuration/service-registration/consul https://www.vaultproject.io/docs/configuration/service-registration/consul

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM