100 lines
3.0 KiB
Plaintext
100 lines
3.0 KiB
Plaintext
---
|
|
layout: commands
|
|
page_title: 'Commands: Namespace Create'
|
|
---
|
|
|
|
# Consul Namespace Create
|
|
|
|
Command: `consul namespace create`
|
|
|
|
Corresponding HTTP API Endpoint: [\[PUT\] /v1/namespace](/api-docs/namespaces#create-a-namespace)
|
|
|
|
<EnterpriseAlert />
|
|
|
|
This `namespace create` command creates a namespaces using the CLI parameters provided.
|
|
This was added in Consul Enterprise 1.7.2.
|
|
|
|
The table below shows this command's [required ACLs](/api#authentication). Configuration of
|
|
[blocking queries](/api-docs/features/blocking) and [agent caching](/api-docs/features/caching)
|
|
are not supported from commands, but may be from the corresponding HTTP endpoint.
|
|
|
|
| ACL Required |
|
|
| ---------------- |
|
|
| `operator:write` |
|
|
|
|
## Usage
|
|
|
|
Usage: `consul namespace create -name <namespace name> [options]`
|
|
|
|
Request a namespace to be created. Construction of the namespace definition is handled by this command
|
|
from the CLI arguments.
|
|
|
|
#### Command Options
|
|
|
|
- `-default-policy-id=<value>` - ID of a policy from the default namespace to inject for all tokens
|
|
in this namespace. May be specified multiple times.
|
|
|
|
- `-default-policy-name=<value>` - Name of a policy from the default namespace to inject for all
|
|
tokens in this namespace. May be specified multiple times. The ACL token used with
|
|
this command must have [`acl:write` access](/docs/security/acl/acl-rules#acl-resource-rules) to the linked policy.
|
|
|
|
- `-default-role-id=<value>` - ID of a role from the default namespace to inject for all tokens in
|
|
this namespace. May be specified multiple times. The ACL token used with
|
|
this command must have [`acl:write` access](/docs/security/acl/acl-rules#acl-resource-rules) to the linked role.
|
|
|
|
- `-default-role-name=<value>` - Name of a role from the default namespace to inject for all tokens
|
|
in this namespace. May be specified multiple times.
|
|
|
|
- `-description=<string>` - A description of the namespace.
|
|
|
|
- `-format=<string>` - How to output the results. The choices are: pretty or json
|
|
|
|
- `-meta=<value>` - Metadata to set on the namespace, formatted as key=value. This flag
|
|
may be specified multiple times to set multiple meta fields
|
|
|
|
- `-name=<string>` - The namespace's name. This flag is required.
|
|
|
|
- `-show-meta` - Indicates that namespace metadata such as the raft indices should
|
|
be shown for the namespace
|
|
|
|
#### API Options
|
|
|
|
@include 'http_api_partition_options.mdx'
|
|
|
|
@include 'http_api_options_client.mdx'
|
|
|
|
@include 'http_api_options_server.mdx'
|
|
|
|
## Examples
|
|
|
|
Create a new Namespace:
|
|
|
|
```shell-session
|
|
$ consul namespace create -name "team-1"
|
|
Name: team-1
|
|
```
|
|
|
|
Showing Raft Metadata:
|
|
|
|
```shell-session
|
|
$ consul namespace create -name team-1 -show-meta
|
|
Name: team-1
|
|
Create Index: 339
|
|
Modify Index: 344
|
|
```
|
|
|
|
JSON Format:
|
|
|
|
```shell-session
|
|
$ consul namespace create -name team2 -description "Example Namespace" -meta "team-id=574407f3-8b26-4c84-8e51-028bb8cbdd37" -format=json
|
|
{
|
|
"Name": "team2",
|
|
"Description": "Example Namespace",
|
|
"Meta": {
|
|
"team-id": "574407f3-8b26-4c84-8e51-028bb8cbdd37"
|
|
},
|
|
"CreateIndex": 352,
|
|
"ModifyIndex": 352
|
|
}
|
|
```
|