Author : MD TAREQ HASSAN | Updated : 2023/07/19
What is manifest file?
- A definition file (
.yaml
or.josn
) that is used to create kubernetes resource by posting to API server - Kubernetes manifests (
.yaml
or.json
) are used to create, modify and delete Kubernetes resources such as pods, deployments, services or ingresses - It is very common to define manifests in form of .yaml files and send them to the Kubernetes API Server via commands such as:
kubectl apply -f my-file.yaml
kubectl delete -f my-file.yaml
- Manifest files define desired state of the cluster and the controllers ensure that the desired state is achieved
Structure Of manifest file
Required Fields
apiVersion
: Which version of the Kubernetes API you’re using to create this objectkind
: What kind of object you want to createmetadata
: Data that helps uniquely identify the object, including a name string, UID, and optional namespacespec
: What state you desire for the object
Example: deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
Kinds Of K8s objects
- Command to list resources:
kubectl api-resources -o wide
- https://stackoverflow.com/questions/53053888/where-is-the-complete-list-of-kubernetes-objects
- Some of the Kubernetes Objects:
- Pods
- Namespaces
- ReplicaSets
- StatefulSets
- Services
- ConfigMaps
- Secrets
- Volumes
Links
- Configuration Best Practices: https://kubernetes.io/docs/concepts/configuration/overview/
- https://github.com/kubernetes/examples