Home / How To / Static ski in Kuberentes

Static ski in Kuberentes



Static Pods are handled directly by the cube and the API server has no control over these pods. The cube is responsible for looking at each static pod and restarting it if it crashes. The static Pods running on a node are visible on the API server but cannot be controlled by the API server. Static Pod has no associated replication control, the cube service looks at it itself and restarts it when it crashes. There is no health check for static skis. The Kubelet process looks at the specific directory intended for static pods.

If you want to know more about the static podcasts, you can visit Kubernete’s official page here.

In this article we will see the steps to create a static pod from the file saved in the default location the cube reads manifest from and also we will change the default location to another directory and see how to get static pod created from there. We create static pods on the Worker node.

Conditions

  1. Kubernetes Cluster with at least 1 worker node.
    Click here to learn how to create a Kubernetes cluster. This guide will help you create a Kubernetes cluster with 1 master and 2 nodes on AWS Ubuntu 18.04 EC2 instances.

What should we do?

  1. Create static pods

Create static pods

Perform the following commands from the master node to obtain information about nodes and pods in the cluster.

$master kubectl  get nodes
$master kubectl  get pods

get-all-pods

You can check the containers that are running as part of the capsules

$worker docker ps
$worker docker ps -a

containers-on-workers-node

Now log in to the worker node and create a new file with the following content by the default path for static pods manifest.

$worker vim /etc/kubernetes/manifests/static-web.yaml
apiVersion: v1
kind: Pod
metadata:
  name: static-web
  labels:
    role: myrole
spec:
  containers:
    - name: web
      image: nginx
      ports:
        - name: web
          containerPort: 80
          protocol: TCP

static-pod-definition-at-default-location

As soon as you create a pod definition in the default location for static pods manifest, the pod is created that is not controlled by the API server.

You can control the newly created pod with the following command from the master node.

$master kubectl  get pods
$master kubectl  get pods --all-namespaces

static-pod-created

To check the containers created as part of the Pod, run the following command on the worker node

$worker docker ps
$worker docker ps -a

containers-on-workers-node

We can also change the default location from which the cube reads manifest.

Now create a new folder where we want to store manifest of Static Pods.

Here we create “/etc/kubelet.d/”.

$worker mkdir -p /etc/kubelet.d/

Create a pod definition file in the directory we created.

$worker vim /etc/kubelet.d/static-web.yaml
apiVersion: v1
kind: Pod
metadata:
  name: static-web-2
  labels:
    role: myrole
spec:
  containers:
    - name: web
      image: nginx
      ports:
        - name: web
          containerPort: 80
          protocol: TCP

To change the default path from which the Kubelets reads manifest for Static Pods, edit the /var/lib/kubelet/config.yaml file and change the value of “staticPodPath” to “staticPodPath = / etc / kubelet.d”.

change-static-pod path

Once the configuration is in place, restart the Kubelet service

$worker systemctl restart kubelet

As soon as the service is restarted, Kubelet discovers the new location and reads the manifesto from that location and creates the discs.

Check if the pod has been created or not.

$master kubectl  get pods

static pod

Check the container created as part of the Pod on the worker node using the following command.

$worker docker ps

containers-on-workers-node

Conclusion

In this article, we saw the steps for creating static pods and we also saw the configuration change required in Kubelet to change the default manifest directory of Static Pods.


Source link