When deploying Vault and Consul as pods in a Kubernetes cluster, you may notice that only the Consul service appears when you run the command consul catalog services. To ensure that Vault is also registered as a service, follow these steps:

  1. Service Definition: Create a service definition for Vault. This can be done by defining a service configuration file in JSON or HCL format. Here’s an example of a simple service definition in HCL:

    service "vault" {
      port = 8200
      tags = ["vault"]
    }
  2. Configuring Consul: Ensure that your Consul agent is configured to discover services in your Kubernetes environment. You may need to set the service block in your Consul configuration to include the Vault service definition.

  3. Deploying the Configuration: After creating the service definition, apply it to your Consul agent. You can do this by placing the configuration file in the appropriate directory or using the Consul API to register the service dynamically.

  4. Verification: Once the configuration is applied, run the command consul catalog services again. You should now see both consul and vault listed as services.

For more detailed instructions, you can refer to the official HashiCorp documentation on registering services with Consul.