Skip to content

Kubernetes Manifest API

YAML manifest fields shared by every Kubernetes resource object.

1 class · 4 methods

Resource Fields

4 methods

Top-level fields every Kubernetes manifest exposes.

apiVersion: <group>/<version>

API group and version of the resource, e.g. apps/v1 or v1 for core resources.

Parameters

NameTypeDescription
groupstringAPI group; core resources omit the group prefix.
versionstringStable version such as v1, beta1.

Returns

void

Example

kubernetes
apiVersion: apps/v1
kind: <Kind>

The resource type, e.g. Pod, Deployment, Service, ConfigMap.

Parameters

NameTypeDescription
KindstringPascalCase resource kind.

Returns

void

Example

kubernetes
kind: Deployment
metadata: name: <string> namespace: <string> labels: <map>

Identifying and organizing data for the resource: name, namespace, labels, annotations.

Parameters

NameTypeDescription
namestringUnique name within the namespace.
namespacestringNamespace; defaults to 'default'.
labelsmap<string,string>Key/value pairs for selection and grouping.

Returns

void

Example

kubernetes
metadata:
  name: nginx
  namespace: web
  labels:
    app: nginx
spec: <resource-specific-schema>

Desired state of the resource. Schema depends on the kind.

Parameters

NameTypeDescription
schemaobjectKind-specific spec, e.g. containers for a Pod.

Returns

void

Example

kubernetes
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    spec:
      containers:
        - name: nginx
          image: nginx:1.27