Resource Fields
4 methodsTop-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
| Name | Type | Description |
|---|---|---|
| group | string | API group; core resources omit the group prefix. |
| version | string | Stable version such as v1, beta1. |
Returns
void
Example
kubernetes
apiVersion: apps/v1kind: <Kind>The resource type, e.g. Pod, Deployment, Service, ConfigMap.
Parameters
| Name | Type | Description |
|---|---|---|
| Kind | string | PascalCase resource kind. |
Returns
void
Example
kubernetes
kind: Deploymentmetadata:
name: <string>
namespace: <string>
labels: <map>Identifying and organizing data for the resource: name, namespace, labels, annotations.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | Unique name within the namespace. |
| namespace | string | Namespace; defaults to 'default'. |
| labels | map<string,string> | Key/value pairs for selection and grouping. |
Returns
void
Example
kubernetes
metadata:
name: nginx
namespace: web
labels:
app: nginxspec: <resource-specific-schema>Desired state of the resource. Schema depends on the kind.
Parameters
| Name | Type | Description |
|---|---|---|
| schema | object | Kind-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