open-nomad/website/content/docs/commands/namespace/apply.mdx
Tim Gross f4287c870d
cli: detect directory when applying namespace spec file (#12738)
The new `namespace apply` feature that allows for passing a namespace
specification file detects the difference between an empty namespace
and a namespace specification by checking if the file exists. For most
cases, the file will have an extension like `.hcl` and so there's
little danger that a user will apply a file spec when they intended to
apply a file name.

But because directory names typically don't include an extension,
you're much more likely to collide when trying to `namespace apply` by
name only, and then you get a confusing error message of the form:

   Failed to read file: read $namespace: is a directory

Detect the case where the namespace name collides with a directory in
the current working directory, and skip trying to load the directory.
2022-04-21 14:53:45 -04:00

74 lines
1.6 KiB
Plaintext

---
layout: docs
page_title: 'Commands: namespace apply'
description: |
The namespace apply command is used create or update a namespace.
---
# Command: namespace apply
The `namespace apply` command is used create or update a namespace.
~> Namespaces are open source in Nomad 1.0. Namespaces were Enterprise-only
when introduced in Nomad 0.7.
## Usage
```plaintext
nomad namespace apply [options] <input>
```
Apply is used to create or update a namespace. The HCL specification file
will be read from stdin by specifying "-", otherwise a path to the file is
expected.
Instead of a file, you may instead pass the namespace name to create
or update as the only argument.
If ACLs are enabled, this command requires a management ACL token.
## General Options
@include 'general_options_no_namespace.mdx'
## Apply Options
- `-quota` : An optional quota to apply to the namespace.
- `-description` : An optional human readable description for the namespace.
- `-json` : Parse the input as a JSON namespace specification.
## Examples
Create a namespace with a quota:
```shell-session
$ nomad namespace apply -description "Prod API servers" -quota prod api-prod
Successfully applied namespace "api-prod"!
```
Remove a quota from a namespace:
```shell-session
$ nomad namespace apply -quota= api-prod
```
Create a namespace from a file:
```shell-session
$ cat namespace.hcl
name = "dev"
description = "Namespace for developers"
capabilities {
enabled_task_drivers = ["docker", "exec"]
disabled_task_drivers = ["raw_exec"]
}
meta {
owner = "John Doe"
contact_mail = "john@mycompany.com"
}
$ nomad namespace apply namespace.hcl
```