Consul Enterprise Namespaces

EnterpriseNamespaces - 图1Enterprise

This feature requires HashiCorp Cloud Platform (HCP) or self-managed Consul Enterprise. Refer to the enterprise feature matrix for additional information.

With Consul Enterprise 1.7.0+, data for different users or teams can be isolated from each other with the use of namespaces. Namespaces help reduce operational challenges by removing restrictions around uniqueness of resource names across distinct teams, and enable operators to provide self-service through delegation of administrative privileges.

For more information on how to use namespaces with Consul Enterprise please review the following tutorials:

Namespace Definition

Namespaces are managed exclusively through the HTTP API and the Consul CLI. The HTTP API accepts only JSON formatted definitions while the CLI will parse either JSON or HCL.

An example namespace definition looks like the following:

  1. {
  2. "Name": "team-1",
  3. "Description": "Namespace for Team 1",
  4. "ACLs": {
  5. "PolicyDefaults": [
  6. {
  7. "ID": "77117cf6-d976-79b0-d63b-5a36ac69c8f1"
  8. },
  9. {
  10. "Name": "node-read"
  11. }
  12. ],
  13. "RoleDefaults": [
  14. {
  15. "ID": "69748856-ae69-d620-3ec4-07844b3c6be7"
  16. },
  17. {
  18. "Name": "ns-team-2-read"
  19. }
  20. ]
  21. },
  22. "Meta": {
  23. "foo": "bar"
  24. }
  25. }
  1. Name = "team-1"
  2. Description = "Namespace for Team 1"
  3. ACLs {
  4. PolicyDefaults = [
  5. {
  6. ID = "77117cf6-d976-79b0-d63b-5a36ac69c8f1"
  7. },
  8. {
  9. Name = "node-read"
  10. }
  11. ]
  12. RoleDefaults = [
  13. {
  14. "ID": "69748856-ae69-d620-3ec4-07844b3c6be7"
  15. },
  16. {
  17. "Name": "ns-team-2-read"
  18. }
  19. ]
  20. }
  21. Meta {
  22. foo = "bar"
  23. }

Fields

  • Name (string: <required>) - The namespaces name must be a valid DNS hostname label.

  • Description (string: "") - This field is intended to be a human readable description of the namespace’s purpose. It is not used internally.

  • ACLs (object: <optional>) - This fields is a nested JSON/HCL object to contain the namespaces ACL configuration.

    • PolicyDefaults (array<ACLLink>) - A list of default policies to be applied to all tokens created in this namespace. The ACLLink object can contain an ID and/or Name field. When the policies ID is omitted Consul will resolve the name to an ID before writing the namespace definition internally. Note that all policies linked in a namespace definition must be defined within the default namespace, and the ACL token used to create or edit the namespace must have acl:write access to the linked policy.

    • RoleDefaults (array<ACLLink>) - A list of default roles to be applied to all tokens created in this namespace. The ACLLink object can contain an ID and/or Name field. When the roles’ ID is omitted Consul will resolve the name to an ID before writing the namespace definition internally. Note that all roles linked in a namespace definition must be defined within the default namespace, and the ACL token used to create or edit the namespace must have acl:write access to the linked role.

  • Meta (map<string|string>: <optional>) - Specifies arbitrary KV metadata to associate with this namespace.