Skip to main content

Command Palette

Search for a command to run...

Kubernetes Cluster Maintenance

Updated
2 min read
Kubernetes Cluster Maintenance
O

Hi there! I'm Ojas Jawale, a passionate Cloud, DevOps and Cyber Security enthusiast. I love to dive into the latest new technologies and sharing my journey through blog. I'm always eager to learn and grow in this ever-evolving field of DevOps and Cyber Security. You'll find me writing about CI/CD pipelines, automation, containerization with Docker, and other exciting tech topics related to software quality and deployment. My goal is to demystify complex DevOps and Cyber Security concepts, provide practical tips on automation and testing, and inspire others in the developer and operations community. Let's connect, learn, and build amazing, high-quality software together!

  1. Upgrading the Kubernetes Cluster

Upgrading a Kubernetes cluster is crucial to ensure it remains secure, stable, and up-to-date with the latest features. Follow these steps to upgrade your Minikube cluster,

  • Check Current Version,

    • First, verify the current version of your Minikube and Kubernetes using the following commands,
minikube version
kubectl version

  • Stop Minikube,

    • Before upgrading, stop the Minikube cluster,
minikube stop

  • Upgrade Minikube,

    • Upgrade Minikube to the latest version,
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

  • Start Minikube with a New Kubernetes Version,

    • Start Minikube with a specific or latest Kubernetes version,
minikube start --kubernetes-version=<Put_Latest_Version>
  • verify upgrade status,
minikube version
kubectl version
  • As we already on latest version of minikube, hence not able to upgrade to latest.

  1. Backing Up and Restoring Data

Backing up and restoring data ensures that your cluster's state can be preserved and recovered in case of failure or migration.

Backup

  1. Backup Kubernetes Resources:

    • Use kubectl to export all resources in a namespace (e.g., notes-app) to YAML files:

        kubectl get all --n notes-app -o yaml > notes-app-backup.yml
      

  1. Backup Persistent Volumes:

    • Back up the data stored in Persistent Volumes. If you’re using hostPath, copy the data to a secure location:

        # Example: assuming the data is stored in /mnt/data
        tar czvf pv-backup.tar.gz /mnt/data
      
  2. Store Backups Securely:

    • Ensure that your backups are stored securely, either on a remote server or cloud storage.

Restore

  1. Restore Kubernetes Resources:

    • Restore the Kubernetes resources from the YAML backup:

        kubectl apply -f notes-app-backup.yaml
      
  2. Restore Persistent Volumes:

    • Restore the data to the Persistent Volumes:

        tar xzvf pv-backup.tar.gz -C /mnt/data
      
  3. Verify Restoration:

    • Ensure that the restored resources and data are functioning correctly by checking the status of the pods and services:

        kubectl get pods --namespace=notes-app
        kubectl get services --namespace=notes-app
      

  1. Scaling the Kubernetes Cluster

Scaling your Kubernetes cluster involves adjusting the number of nodes and replicas of your deployments to meet demand.

  • Scale Out the Cluster

  • Scale Deployment Replicas

  • Auto-scaling

  • Verify Scaling

For detailed overview of Autoscaling of k8s cluster, refer -> HPA

Search for Horizontal Pod Autoscaling.


Connect With Me

Thank you for reading. I hope you were able to understand and learn something new from my blog.

Happy Learning!

LinkedIn | GitHub

More from this blog

Untitled Publication

52 posts