Search⌘ K

Deploying Objects to Namespaces

Explore how to deploy Kubernetes objects into specific namespaces using both imperative command line flags and declarative YAML manifests. Understand how to target namespaces for resources like ServiceAccounts, Services, and Pods, and verify deployments. Learn how to connect to deployed applications and clean up namespaces when done. This lesson helps you manage cluster organization and resource isolation with namespaces.

As previously mentioned, most objects are Namespaced, and Kubernetes deploys new objects to the default Namespace unless we specify otherwise.

How to deploy objects to namespaces

There are two ways to deploy objects to specific Namespaces:

  • Imperatively

  • Declaratively

To do it imperatively, add the -n or --namespace flag to commands. To do it declaratively, we specify the Namespace in the objects YAML manifest. ...