Kubernetes Administration
medium

Questão de Kubernetes Administration #019e3a4f

Enunciado da Questão
Kubernetes Administration
#kubernetes
#api
#customresourcedefinition
#aggregation-layer
Médio

How can you extend the Kubernetes API?

A

Adding a CustomResourceDefinition or implementing an aggregation layer.

Correta
B

Adding a new version of a resource, for instance v4beta3.

C

With the command kubectl extend api, logged in as an administrator.

D

Adding the desired API object as a kubelet parameter

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

Summary

Extending the Kubernetes API is achieved by either adding a CustomResourceDefinition (CRD) or implementing the aggregation layer. These are the official and supported methods to introduce custom resources or extend the API surface.

How It Works

  • CustomResourceDefinition (CRD): Allows you to define a new custom resource type without writing a full API server. CRDs are built on top of the existing Kubernetes API machinery and automatically generate RESTful endpoints for the custom resource. They are the simplest way to extend the API.
  • Aggregation Layer: Enables you to extend the Kubernetes API by writing your own API server that is aggregated into the main API server. This is more complex but provides full control over the API behavior, including custom validation, storage, and business logic.

Why the Correct Answer is Right

Adding a CustomResourceDefinition or implementing an aggregation layer are the only two methods officially documented by Kubernetes for extending the API. CRDs are declarative and require no programming, while the aggregation layer is for advanced use cases requiring a custom API server.

Why the Incorrect Answers are Wrong

  • Adding a new version of a resource (e.g., v4beta3): This is not a method to extend the API; it is a versioning strategy for existing resources. New versions are added to built-in resources, not to extend the API with new functionality.
  • Using the command kubectl extend api: This command does not exist. kubectl does not have an extend api subcommand. Extending the API is done via YAML manifests (CRDs) or by deploying a separate API server (aggregation layer).
  • Adding the desired API object as a kubelet parameter: The kubelet is a node agent that manages pods and containers. It does not handle API extensions. API extensions are server-side concepts managed by the API server, not by kubelet parameters.

Key Takeaway

To extend the Kubernetes API, use CustomResourceDefinitions for simplicity or the aggregation layer for full control. Avoid non-existent commands or irrelevant node-level configurations.