Install & Start Using Kubernetes For Your Project or Product

Nirmesh Mashru
May 02, 2024
5 mins read Last Updated May 02, 2024

Kubernetes, often abbreviated as K8s, is an open-source container orchestration platform designed to automate deploying, scaling, and managing containerized applications. Created by Google, Kubernetes is now maintained by the Cloud Native Computing Foundation (CNCF). This blog will guide you through the basics of using Kubernetes, from installation to deploying your first application.

What is Kubernetes?

Kubernetes is a powerful platform that enables you to manage containerized applications across a cluster of machines. It handles the complexity of networking, storage, and lifecycle management of applications, making it easier for developers to focus on writing code rather than managing infrastructure.

Key Concepts in Kubernetes

Before diving into the practical steps, it's important to understand some key concepts in Kubernetes:

  • Cluster: A set of nodes (machines) that run containerized applications managed by Kubernetes.
  • Node: A single machine in a Kubernetes cluster, which can be either a physical or virtual machine.
  • Pod: The smallest and simplest Kubernetes object. A pod encapsulates one or more containers, storage resources, a unique network IP, and options for how the containers should run.
  • Deployment: A higher-level object that manages the rollout and scaling of a set of pods.
  • Service: An abstraction that defines a logical set of pods and a policy to access them, often used to expose applications to the outside world.

Installing Kubernetes

There are several ways to install Kubernetes, depending on your operating system and whether you're setting up a local development environment or a production cluster.

Minikube (For Local Development)

Minikube is a tool that lets you run a single-node Kubernetes cluster locally. It's a great way to get started with Kubernetes.

  1. Install Minikube:

    On macOS:

    brew install minikube

    On Linux:

    curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
    sudo install minikube-linux-amd64 /usr/local/bin/minikube
    
  2. Start Minikube:

    minikube start
  3. Verify the Installation:

    kubectl get nodes

    This command should show a single node with the status "Ready".

Kubernetes CLI (kubectl)

kubectl is the command-line tool for interacting with your Kubernetes cluster. You can use it to deploy applications, inspect and manage cluster resources, and view logs.

  1. Install kubectl:

    On macOS:

    brew install kubectl

    On Linux:

    curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
    chmod +x ./kubectl
    sudo mv ./kubectl /usr/local/bin/kubectl
    
  2. Configure kubectl to Use Minikube:

    kubectl config use-context minikube

Deploying Your First Application

Let's deploy a simple Nginx web server to your Kubernetes cluster.

  1. Create a Deployment:

    # nginx-deployment.yaml
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      replicas: 3
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:latest
            ports:
            - containerPort: 80

    Apply the deployment:

    kubectl apply -f nginx-deployment.yaml
  2. Expose the Deployment as a Service:

    kubectl expose deployment nginx-deployment --type=NodePort --port=80

    This command creates a Service that makes your Nginx pods accessible on a network port.

  3. Get the Service Details:

    kubectl get services

    Look for the nginx-deployment service and note the NodePort. You can access the Nginx server by navigating to http://<minikube-ip>:<node-port>, where <minikube-ip> is the IP address of your Minikube instance, and <node-port> is the port number listed in the service details.

Managing Kubernetes Resources

Scaling a Deployment

You can easily scale your deployment up or down:

kubectl scale deployment nginx-deployment --replicas=5

This command scales the number of replicas to 5.

Updating a Deployment

To update the image version for your deployment:

kubectl set image deployment/nginx-deployment nginx=nginx:1.19.0
 
Kubernetes will perform a rolling update, ensuring zero downtime.

Deleting Resources

To delete the deployment and service:

kubectl delete deployment nginx-deployment
kubectl delete service nginx-deployment 

Conclusion

Kubernetes is a powerful tool for managing containerized applications, offering features like automated deployment, scaling, and self-healing capabilities. By following this guide, you’ve taken the first steps towards mastering Kubernetes. As you become more familiar with its concepts and commands, you'll be able to leverage its full potential to streamline your development and operations workflows. Happy orchestrating!

Contact QuickDIV for Kubernetes Implementation in Your Product

Are you looking to leverage Kubernetes for efficient container orchestration and management in your product? QuickDiv specializes in implementing Kubernetes solutions tailored to your needs. Our team of experts will help you deploy, scale, and manage your applications seamlessly, ensuring high availability and reliability.

Why Choose QuickDIV:

  • Expertise in Kubernetes: Deep knowledge and extensive experience in Kubernetes deployments.
  • Customized Solutions: Tailored implementation strategies to fit your specific requirements.
  • Comprehensive Support: End-to-end support from planning to deployment and beyond.

Contact QuickDIV today to discuss how we can enhance your product with a robust Kubernetes infrastructure.

Image placeholder

Nirmesh Mashru

Nirmesh is Founder & CEO at QuickDIV, a leading IT solutions provider renowned for its cutting-edge technology and customer-centric approach. With over 8+ years of experience in the tech industry.

Subcribe to our Newsletter

Supplying companies with cutting-edge IT solutions to enable a smooth digital transition.