2019-12-06 16:14:56 +00:00
---
2020-04-07 18:55:19 +00:00
layout: docs
2022-09-09 18:46:33 +00:00
page_title: Namespaces (Enterprise)
description: >-
2022-09-16 15:28:32 +00:00
Namespaces reduce operational challenges in large deployments. Learn how to define a namespace so that multiple users or teams can access and use the same datacenter without impacting each other.
2019-12-06 16:14:56 +00:00
---
# Consul Enterprise Namespaces
2020-04-23 22:13:18 +00:00
<EnterpriseAlert>
2022-04-28 23:27:34 +00:00
This feature requires
2021-12-10 22:42:33 +00:00
HashiCorp Cloud Platform (HCP) or self-managed Consul Enterprise.
Refer to the{' '}
2022-04-27 16:25:16 +00:00
<a href="/docs/enterprise#consul-enterprise-feature-availability">enterprise feature matrix</a>
2022-04-27 16:45:30 +00:00
{' '}for additional information.
2020-04-23 22:13:18 +00:00
</EnterpriseAlert>
2021-12-10 22:42:33 +00:00
With Consul Enterprise 1.7.0+, data for different users or teams
2020-04-06 20:27:35 +00:00
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
2019-12-06 16:14:56 +00:00
to provide self-service through delegation of administrative privileges.
2022-08-26 06:05:08 +00:00
For more information on how to use namespaces with Consul Enterprise please review the following tutorials:
2020-02-11 19:31:47 +00:00
2022-09-06 15:35:01 +00:00
- [Register and Discover Services within Namespaces](https://learn.hashicorp.com/tutorials/consul/namespaces-share-datacenter-access?utm_source=docs) - Register multiple services within different namespaces in Consul.
- [Setup Secure Namespaces](https://learn.hashicorp.com/tutorials/consul/namespaces-secure-shared-access?utm_source=docs) - Secure resources within a namespace and delegate namespace ACL rights via ACL tokens.
2020-02-11 19:31:47 +00:00
2019-12-06 16:14:56 +00:00
## Namespace Definition
2022-03-30 21:16:26 +00:00
Namespaces are managed exclusively through the [HTTP API](/api-docs/namespaces) and the [Consul CLI](/commands/namespace).
2019-12-06 16:14:56 +00:00
The HTTP API accepts only JSON formatted definitions while the CLI will parse either JSON or HCL.
2020-03-24 20:06:20 +00:00
An example namespace definition looks like the following:
2019-12-06 16:14:56 +00:00
2021-07-31 01:37:33 +00:00
<CodeTabs>
2019-12-06 16:14:56 +00:00
```json
{
2020-04-06 20:27:35 +00:00
"Name": "team-1",
"Description": "Namespace for Team 1",
"ACLs": {
"PolicyDefaults": [
{
"ID": "77117cf6-d976-79b0-d63b-5a36ac69c8f1"
},
{
"Name": "node-read"
}
],
"RoleDefaults": [
{
"ID": "69748856-ae69-d620-3ec4-07844b3c6be7"
},
{
"Name": "ns-team-2-read"
}
]
},
"Meta": {
"foo": "bar"
}
2019-12-06 16:14:56 +00:00
}
```
```hcl
2020-02-06 12:33:07 +00:00
Name = "team-1"
Description = "Namespace for Team 1"
2019-12-06 16:14:56 +00:00
ACLs {
PolicyDefaults = [
{
ID = "77117cf6-d976-79b0-d63b-5a36ac69c8f1"
},
{
Name = "node-read"
}
]
RoleDefaults = [
{
"ID": "69748856-ae69-d620-3ec4-07844b3c6be7"
},
{
"Name": "ns-team-2-read"
}
]
}
Meta {
foo = "bar"
}
```
2021-07-31 01:37:33 +00:00
</CodeTabs>
2019-12-06 16:14:56 +00:00
### Fields
2020-03-24 20:06:20 +00:00
- `Name` `(string: <required>)` - The namespaces name must be a valid DNS hostname label.
2019-12-06 16:14:56 +00:00
- `Description` `(string: "")` - This field is intended to be a human readable description of the
namespace's purpose. It is not used internally.
2020-04-06 20:27:35 +00:00
2020-03-24 20:06:20 +00:00
- `ACLs` `(object: <optional>)` - This fields is a nested JSON/HCL object to contain the namespaces
2020-04-06 20:27:35 +00:00
ACL configuration.
2019-12-06 16:14:56 +00:00
- `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
2020-03-24 20:06:20 +00:00
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
2021-11-01 22:50:42 +00:00
within the `default` namespace, and the ACL token used to create or edit the
namespace must have [`acl:write` access](/docs/security/acl/acl-rules#acl-resource-rules) to the linked policy.
2020-04-06 20:27:35 +00:00
2019-12-06 16:14:56 +00:00
- `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
2020-03-24 20:06:20 +00:00
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
2021-11-01 22:50:42 +00:00
within the `default` namespace, and the ACL token used to create or edit the
namespace must have [`acl:write` access](/docs/security/acl/acl-rules#acl-resource-rules) to the linked role.
2020-04-06 20:27:35 +00:00
2019-12-06 16:14:56 +00:00
- `Meta` `(map<string|string>: <optional>)` - Specifies arbitrary KV metadata to associate with
this namespace.