Kubernetes
medium

Questão de Kubernetes #019e3a4f

Enunciado da Questão
Kubernetes
#kubectl
#explain
#deployment
#replicas
Médio

Which command provides information about the field replicas within the spec resource of a deployment object?

A

kubectl get deployment.spec.replicas

B

kubectl explain deployment.spec.replicas

Correta
C

kubectl describe deployment.spec.replicas

D

kubectl explain deployment --spec.replicas

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

The kubectl explain command is used to retrieve documentation and details about Kubernetes API resources, including fields within those resources. To get information about the replicas field inside the spec of a Deployment object, the correct syntax is kubectl explain deployment.spec.replicas. This command will display the description, type, and other metadata for that specific field.

How it works:
kubectl explain accesses the API server's OpenAPI schema to provide human-readable documentation for resource fields. It recursively resolves nested fields using dot notation (e.g., deployment.spec.replicas).

Why the correct value is right:
kubectl explain deployment.spec.replicas directly queries the API schema for the replicas field under spec of a Deployment. This is the intended use of kubectl explain.

Why the incorrect values are wrong:

  • kubectl get deployment.spec.replicas is invalid because kubectl get retrieves resources, not field documentation. It expects a resource type (e.g., deployment), not a field path.
  • kubectl describe deployment.spec.replicas is incorrect because kubectl describe shows detailed runtime information about a specific resource instance, not field documentation. It also expects a resource name after the type.
  • kubectl explain deployment --spec.replicas uses incorrect syntax. The --spec.replicas flag is not a valid option; the correct way to specify a nested field is with dot notation without a leading dash.