Every Kubernetes resource specification requires four fundamental fields:
apiVersion
- Specifies which version of the Kubernetes API you're using to create the resource. Different resources might be available in different API groups and versions. For example:
v1
for core resources like Pods, Services, ConfigMaps
apps/v1
for Deployments, StatefulSets, DaemonSets
networking.k8s.io/v1
for Ingress resources
kind
- Defines what type of resource you're creating. Common kinds include Pod, Deployment, Service, ConfigMap, Secret, and many others.
metadata
- Contains data that helps uniquely identify the resource, including:
name
(required) - The name of the resource, which must be unique within a namespace
namespace
(optional) - The namespace where the resource will be created; defaults to "default" if not specified
labels
(optional) - Key-value pairs for organizing and selecting subsets of resources
annotations
(optional) - Non-identifying metadata for resources
spec
- Contains the actual configuration of the resource, with fields that vary based on the resource type.
