starting steps of k8s

starting steps of k8s

container vs pod

In container orchestration platforms such as Kubernetes, a pod is the smallest deployable unit representing a single instance of a running process. A pod may contain one or more containers that share the same network namespace and can communicate with each other via localhost.

On the other hand, a container is a lightweight, standalone executable package of software that includes everything needed to run an application, including the code, runtime, system tools, libraries, and settings.

In summary, a pod is an abstraction layer that groups one or more containers and provides them with a shared context, such as a shared network namespace and shared storage volumes. Containers, on the other hand, are the actual units of software that run inside a pod, and provide the isolation and encapsulation of the application's environment.

Kubectl and its's installation

kubectl is a command-line interface tool used to interact with Kubernetes clusters. It allows users to deploy, inspect, and manage applications running on a Kubernetes cluster.

To install kubectl, follow these steps:

  1. Check the latest version of kubectl on the official Kubernetes documentation: kubernetes.io/docs/tasks/tools/install-kube...

  2. Download the binary for your platform using curl. For example, to download the Linux binary, use the following command:

     curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
    

    This downloads the binary to your current working directory.

  3. Make the binary executable:

     sudo mv kubectl /usr/local/bin/
    
  4. Move the binary to a directory in your system's PATH. For example, to move it to /usr/local/bin, use the following command:

     sudo mv kubectl /usr/local/bin/
    
  5. Verify that kubectl is installed by running the following command:

     kubectl version --client
    

    This should display the version of kubectl that you just installed.

That's it! You should now be able to use kubectl to manage your Kubernetes cluster.

Minikube

Minikube is a tool that allows you to run a Kubernetes cluster on your local machine. Here are the steps to install Minikube:

  1. Check the latest version of Minikube on the official GitHub releases page: github.com/kubernetes/minikube/releases.

  2. Download the binary for your platform using curl. For example, to download the Linux binary, use the following command:

     rubyCopy codecurl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    

    This downloads the binary to your current working directory.

  3. Make the binary executable:

     bashCopy codechmod +x minikube-linux-amd64
    
  4. Move the binary to a directory in your system's PATH. For example, to move it to /usr/local/bin, use the following command:

     bashCopy codesudo mv minikube-linux-amd64 /usr/local/bin/minikube
    
  5. Verify that Minikube is installed by running the following command:

     Copy codeminikube version
    

    This should display the version of Minikube that you just installed.

That's it! You should now be able to use Minikube to run a local Kubernetes cluster. You can start a cluster by running the command minikube start.

How to create a pod

To create a pod in Kubernetes, you need to define a pod manifest in a YAML file that describes the desired state of the pod. Here's an example of a simple pod manifest:

yamlCopy codeapiVersion: v1
kind: Pod
metadata:
  name: my-pod
spec:
  containers:
  - name: my-container
    image: nginx:latest

This manifest describes a pod named my-pod with a single container named my-container that runs the latest version of the Nginx web server.

To create the pod, save the above manifest to a file named my-pod.yaml, and then run the following command:

kubectl apply -f my-pod.yaml

This command will create the pod as described in the manifest file. You can then check the status of the pod by running:

kubectl get pods

This will show you a list of all the pods in your cluster, including the one you just created.

Advantages of Pods

Here are some of the advantages of using pods in Kubernetes:

  1. Grouping of containers: Pods provide a way to group one or more containers together and manage them as a single unit. This is useful for applications that require multiple containers to work together, such as a web application that requires a web server container and a database container.

  2. Shared resources: All containers in a pod share the same network namespace and can communicate with each other using localhost. They can also share the same storage volumes, which makes it easy to share data between containers.

  3. Atomic deployment and scaling: Pods provide an atomic unit of deployment and scaling. When you scale a pod, all the containers in the pod are scaled together. This ensures that your application remains consistent and all the containers are scaled proportionally.

  4. Efficient resource utilization: Since containers in a pod share the same resources, Kubernetes can optimize resource allocation and utilization. For example, if one container is using more CPU or memory, Kubernetes can allocate more resources to that container without affecting the other containers in the pod.

  5. Simplified management: Pods simplifies the management of containerized applications. With pods, you can manage all the containers in an application as a single unit, which makes it easier to deploy, manage, and monitor your application.

Did you find this article valuable?

Support Shivakrishna Addikicherla by becoming a sponsor. Any amount is appreciated!