Kubernetes Fundamentals
medium

Questão de Kubernetes Fundamentals #019e3a4f

Enunciado da Questão
Kubernetes Fundamentals
#kubernetes
#namespaces
#cluster
#default
Médio

Which of the following sentences is true about namespaces in Kubernetes?

A

You can create a namespace within another namespace in Kubernetes.

B

You can create two resources of the same kind and name in a namespace.

C

The default namespace exists when a new cluster is created.

Correta
D

All the objects in the cluster are namespaced by default.

Explicação Oficial / Explicações da Comunidade

Correct Answer: The default namespace exists when a new cluster is created.

In Kubernetes, when a new cluster is initialized, three namespaces are automatically created: default, kube-system, and kube-public. The default namespace is the one used for resources that do not specify a namespace. This is a fundamental aspect of Kubernetes namespace management.

How it Works

Namespaces in Kubernetes provide a mechanism for isolating groups of resources within a single cluster. They are logical partitions that help organize and manage cluster objects. The default namespace is created by the cluster bootstrap process (e.g., kubeadm init) and is the target for any resource creation command that does not include a --namespace flag or a namespace field in the YAML manifest.

Why the Correct Answer is Right

The statement "The default namespace exists when a new cluster is created" is correct because the Kubernetes API server automatically creates the default namespace during cluster initialization. This is verified by running kubectl get namespaces on a fresh cluster, which lists default along with other system namespaces.

Why the Incorrect Answers are Wrong

  • "You can create a namespace within another namespace in Kubernetes." This is false. Namespaces cannot be nested. Kubernetes namespaces are flat; you cannot create a namespace inside another namespace. Attempting to do so results in an error.
  • "You can create two resources of the same kind and name in a namespace." This is false. Within a single namespace, resource names must be unique per kind. For example, you cannot have two Pods with the same name in the same namespace. Duplicate names cause creation failures.
  • "All the objects in the cluster are namespaced by default." This is false. Some Kubernetes objects are cluster-scoped, meaning they exist outside of any namespace. Examples include Nodes, PersistentVolumes, ClusterRoles, and Namespaces themselves. These resources are not namespaced and are visible across the entire cluster.