Questão de Kubernetes #019e3a4f
Which command provides information about the field replicas within the spec resource of a deployment object?
kubectl get deployment.spec.replicas
kubectl explain deployment.spec.replicas
kubectl describe deployment.spec.replicas
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.replicasis invalid becausekubectl getretrieves resources, not field documentation. It expects a resource type (e.g.,deployment), not a field path.kubectl describe deployment.spec.replicasis incorrect becausekubectl describeshows detailed runtime information about a specific resource instance, not field documentation. It also expects a resource name after the type.kubectl explain deployment --spec.replicasuses incorrect syntax. The--spec.replicasflag is not a valid option; the correct way to specify a nested field is with dot notation without a leading dash.