Pages

Tuesday, August 7, 2018

Kubernetes Manifest file

Share it Please
Kubernetes Resources or Objects
K8 objects are persistent entities in the kubernetes system. K8 uses these entities to represent the state of the cluster. We can use these to describe
Creation of pods & other resources
Resources available to applications
Policies on how pods should run etc

To Work with kubernetes objects like to create , modify or delete we will need to access the Api. For this k8 provides us with a command line utility called “kubectl”.

Kubectl make the necessary calls to the Api server for all creating, updating and modifying of the components.

Manifest file
Resources in kubernetes are defined in a  manifest which is a simple text file. this manifest represents the kubernetes API object. The manifest is defined declarative format.

Declarative configuration means that you write down the desired state of the world in a
configuration and then submit that configuration to a service that takes actions to ensure the desired state becomes  the actual state.

Kubernetes API server accepts and processes pod manifest before storing them in persistent storage ( etcd) . The scheduler also use k8 api to find pods that haven’t been scheduled to a node. The scheduler then places the pods on the node based on the resource availability.

The manifest file will be either in yml or Json format. A format for json would like this,
[root@manja17-I13330 kubenetes-config]# cat nginx.json
{
  "apiVersion": "v1",
  "kind": "Pod",
  "metadata": {
       "name": "my-nginx",
       "labels": {
              "env": "dev"
       }
  },
  "spec": {
    "containers": [
      {
        "name": "my-nginx",
        "image": "nginx",
        "ports": [
          {
            "containerPort": 80
          }
        ]
      }
    ]
  }
}

A simple format for yml looks like,
[root@manja17-I13330 kubenetes-config]# cat basic-pod-in-namespace.yml
apiVersion: v1
kind: Pod
metadata:
  name: sample-testing
spec:
  containers:
  - name: test-ser
    image: docker.io/jagadesh1982/testing-service
    ports:
    - containerPort: 9876

No comments :

Post a Comment