Skip to main content
Kubernetes FundamentalsMediumSingle Choice

Kubernetes Fundamentals Question

Statement

What fields must exist in any Kubernetes object (e.g. YAML) file?

#kubernetes#yaml#api-version#kind#metadata
A

apiVersion, kind, metadata

Correct
B

kind, namespace, data

C

apiVersion, metadata, namespace

D

kind, metadata, data

Resolution & Explanations

Every Kubernetes object definition in YAML or JSON must include three required fields: apiVersion, kind, and metadata. The apiVersion field specifies the API version used for the object (e.g., v1, apps/v1). The kind field identifies the type of object (e.g., Pod, Deployment, Service). The metadata field contains data that uniquely identifies the object, such as name, namespace, labels, and annotations. Without these three fields, the Kubernetes API server cannot process the object definition.

How it Works
When you submit a Kubernetes object manifest to the API server, the server validates the manifest against the expected schema. The apiVersion tells the server which API group and version to use for deserialization. The kind tells the server which resource type to create or modify. The metadata provides the identity and optional descriptive information. All other fields, such as spec or data, are specific to the object kind and are not universally required.

Why the Correct Value is Right
The combination apiVersion, kind, and metadata is the minimal set required by the Kubernetes API. For example, a simple Pod manifest must include:

YAML
apiVersion: v1
kind: Pod
metadata:
  name: my-pod

Without any of these, the API server returns an error.

Why the Incorrect Values are Wrong

  • The combination kind, namespace, data is incorrect because namespace is optional (it defaults to default if omitted) and data is not a required field for all objects (it is specific to objects like ConfigMaps and Secrets).
  • The combination apiVersion, metadata, namespace is incorrect because kind is missing; the API server cannot determine the object type without it.
  • The combination kind, metadata, data is incorrect because apiVersion is missing; the API server cannot determine which API version to use for deserialization, and data is not universally required.