Kubectl apply: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 17: Line 17:


Also see: {{Internal|kubectl create|kubectl create}}
Also see: {{Internal|kubectl create|kubectl create}}
=Namespace Handling=
The resources specified by the manifest can be deployed in an arbitrary namespace with the -n <namespace> option, unless the manifest already specifies a different namespace in the metadata section. In that case, an error will ensue:
<syntaxhighlight lang='text'>
error: the namespace from the provided object "default" does not match the namespace "prometheus". You must pass '--namespace=default' to perform this operation.
</syntaxhighlight>


=Options=
=Options=

Revision as of 03:44, 14 October 2020

Internal

Overview

Apply a configuration to a resource by filename or stdin:

kubectl apply -f <manifest.yaml>
cat <manifest.yaml> | kubectl apply -f -

The command can be used to both create a new resource or update the state of an existing resource. When updating the state, the command supports strategic merge patch.

Also see:

kubectl create

Namespace Handling

The resources specified by the manifest can be deployed in an arbitrary namespace with the -n <namespace> option, unless the manifest already specifies a different namespace in the metadata section. In that case, an error will ensue:

error: the namespace from the provided object "default" does not match the namespace "prometheus". You must pass '--namespace=default' to perform this operation.

Options

-f|--filename

The filename that contains the configuration to apply.

-k|--kustomize

Process a kustomization directory.

-k