DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Kubernetes Cluster Backups With Velero
  • Rapidly Develop Java Microservices on Kubernetes With Telepresence
  • Backup and Disaster Recovery in the Age of GitOps and CI/CD Deployments
  • Kafka on Kubernetes, the Strimzi Way (Part 3)

Trending

  • Microsoft Azure Synapse Analytics: Scaling Hurdles and Limitations
  • Docker Model Runner: Streamlining AI Deployment for Developers
  • A Guide to Developing Large Language Models Part 1: Pretraining
  • It’s Not About Control — It’s About Collaboration Between Architecture and Security
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Monitoring Velero Backup and Restore With BotKube

Monitoring Velero Backup and Restore With BotKube

How to monitor Velero backup and restore with BotKube by sending notifications and alerts on Slack, Discord, Mattermost, or Teams.

By 
Aashi Modi user avatar
Aashi Modi
·
Jul. 08, 21 · Tutorial
Likes (1)
Comment
Save
Tweet
Share
10.2K Views

Join the DZone community and get the full member experience.

Join For Free

One of the key challenges for Kubernetes Day 2 operations is observability, i.e. having a holistic view of your system’s health. This is where BotKube helps to improve your monitoring experience of your Kubernetes clusters by sending notifications to supported messaging platforms. BotKube helps you solve several interesting use cases, for example, monitoring Velero backup failure or certificate issue/expiry status by cert-manager, etc. In this blog, we will configure BotKube to monitor your Velero backups and restores.

What Is BotKube?

BotKube is a messaging tool for monitoring and debugging Kubernetes clusters. BotKube can be integrated with multiple messaging platforms like - Slack, Mattermost, or Microsoft Teams to help you monitor your Kubernetes cluster(s), debug critical deployments, and gives recommendations for standard practices by running checks on the Kubernetes resources. — BotKube website

What Is Velero?

Velero is an open source tool to safely backup and restore, perform disaster recovery, and migrate Kubernetes cluster resources. — Velero website

It supports snapshotting of your cluster’s persistent volumes using your cloud provider’s storage and restoring the persistent volumes from the snapshots.

While considering backup solutions for disaster recovery, we want to ensure backups for etcd — to restore our Master node and Cluster configs — and persistent volume for application data. With the help of Velero, you can create volume snapshots, on-demand backups, scheduled backups, or restore backups.

How to Monitor Velero Backups Using BotKube

With the release of BotKube v0.11.0+, monitoring of any Kubernetes resources, including custom resources, is supported. This allows us to configure alerts and notify of create, delete, and error events of Velero resources. BotKube can notify us about the events and updates in status.phase field in velero.io/v1/backups and velero.io/v1/restores resource.

Prerequisites

This post assumes that you already have a Kubernetes cluster with Velero and BotKube running on it. If you don’t have these things running, follow this section to get a minimal setup running on top of minikube. We will be configuring BotKube with Slack for this tutorial. You can use any other interface like Mattermost, MS Teams, Discord, etc., supported by BotKube as well.

How to Create a Kubernetes Cluster With Minikube

  1. Install minikube on your machine by following the instructions given here.
  2. To start the minikube cluster, run the following command:

    Java
     
     $ minikube start 
     minikube v1.20.0 on Ubuntu 20.04
     Using the docker driver based on existing profile
     Starting control plane node minikube in cluster minikube
     Pulling base image ...
     Restarting existing docker container for "minikube" ...
     Preparing Kubernetes v1.20.2 on Docker 20.10.6 ...
     Verifying Kubernetes components...
     Using image gcr.io/k8s-minikube/storage-provisioner:v5
     Enabled addons: storage-provisioner, default-storageclass
     Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default

Install and Set Up BotKube

  1. Install Helm on your machine by following the instructions given here.
  2. To add the infracloudio Helm chart repository, run the following command:

    Java
     
     $ helm repo add infracloudio https://infracloudio.github.io/charts
     "infracloudio" has been added to your repositories
     $ helm repo update
     ...Successfully got an update from the "infracloudio" chart repository
     Update Complete. ⎈Happy Helming!⎈
  3. Install the BotKube Slack app in your workspace by following the instructions given in this section of the documentation. You will be provided a Slack bot access token, be sure to save it.

  4. To create the Helm values file for BotKube, run the following command:

    Java
     
    cat <<EOF > botkube-values.yaml
     communications:
       slack:
         enabled: true
         channel: "test"
         token: "<TOKEN_FROM_3>"
            
     config:
       settings:
         clustername: "minikube"
         kubectl:
           enabled: true
     EOF
  5. To create a namespace and install BotKube, run the following command:

    Java
     
     $ helm install botkube infracloudio/botkube \
         --namespace botkube --create-namespace \
         -f botkube-values.yaml
  6. Verify that the pods are running.

    Java
     
     $ kubectl get pods -n botkube                              
     NAME                       READY   STATUS    RESTARTS   AGE
     botkube-84f95dd594-qrz28   1/1     Running   5          24h

If any of the above instructions don’t work, please refer to BotKube’s official documentation page for an updated version of these instructions.

How to Install Velero

Velero consists of:

  • A command-line client that runs locally
  • A server that runs on your cluster

To install the CLI client locally, download and extract the latest release’s tarball for your client platform. Move the extracted Velero binary to somewhere in your $PATH. 

Install Velero in your cluster:

  1. To add vmware-tanzu Helm repository, run the following command:

    Java
     
     $ helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
     $ helm repo update
  2. Configure provider credentials. Follow the Velero plugin setup instructions for your cloud provider. For example, if you are using AWS (as this guide does), follow the AWS plugin setup instructions to create an IAM user and S3 bucket and obtain a credentials file.
  3. Install Velero. Add below in velero-values.yaml for configuring values.

    Java
     
     cat <<EOF > velero-values.yaml
     credentials:
       secretContents:
         cloud: credentials-velero
     configuration:
       provider: aws
       backupStorageLocation:  
         bucket: <bucket-name>
         config:
           region: <region>
     EOF
    Java
     
     helm install velero vmware-tanzu/velero --namespace velero -f velero-values.yaml
    
  4. Verify that the pods are running.

    Java
     
     $ kubectl get pods -n velero 
     NAME                      READY   STATUS    RESTARTS   AGE
     velero-65656995d6-59c6r   1/1     Running   2          44h

If any of the above instructions don’t work, please take a look at Velero’s official documentation page for an updated version of these instructions.

Let’s Configure BotKube for Monitoring

We will now configure BotKube to monitor the backups and restores custom resources of Velero.

Add the following snippet under config in the botkube-values.yaml file.

Java
 
#config:
## Resources you want to watch
  resources:
    - name: velero.io/v1/backups
      namespaces:
        include:
          - all
      events:
        - all
      updateSetting:
        includeDiff: true
        fields:
          - status.phase
    - name: velero.io/v1/restores
      namespaces:
        include:
          - all
      events:
        - all
      updateSetting:
        includeDiff: true
        fields:
          - status.phase

This configures BotKube to start monitoring velero.io/v1/backups and velero.io/v1/restores resource. It monitors all the operations like create, update, delete, and error from all the namespaces.

We are also monitoring the status.phase field of the Velero custom resources. This will create a notification when an operation is triggered.

To update BotKube deployment, run the following Helm command:

Java
 
helm upgrade botkube infracloudio/botkube -n botkube -f botkube-values.yaml

You can read more about this configuration in the resource_config.yaml syntax documentation section.

Let’s Test Our BotKube Setup

We will deploy the example NGINX application, present in the Velero folder which was extracted from velero-x.y.z.tar.gz during installation.

Java
 
$ cd velero-v1.6.0-linux-amd64 
$ kubectl apply -f examples/nginx-app/base.yaml
namespace/nginx-example created
deployment.apps/nginx-deployment created
service/my-nginx created

$ kubectl get pods -n nginx-example            
NAME                               READY   STATUS    RESTARTS   AGE
nginx-deployment-57d5dcb68-xn8xc   1/1     Running   0          97s
nginx-deployment-57d5dcb68-zl26q   1/1     Running   0          97s

Velero can back up or restore all objects in your cluster, or you can filter objects by type, namespace, and/or label. We are creating a backup nginx-backup to include all resources from the nginx-example namespace.

Java
 
velero backup create nginx-backup --include-namespaces nginx-example


BotKube backups

Wreak havoc! Let’s delete the example NGINX application using the below command:

Java
 
$ cd velero-v1.6.0-linux-amd64
$ kubectl delete -f examples/nginx-app/base.yaml
namespace "nginx-example" deleted
deployment.apps "nginx-deployment" deleted
service "my-nginx" deleted

$ kubectl get pods -n nginx-example
No resources found in nginx-example namespace.

We will now restore the nginx-backup backup. We need to provide a backup name in the --from-backup parameter to identify which backup we want to restore.

Java
 
$ velero restore create nginx-backup --from-backup nginx-backup
Restore request "nginx-backup" submitted successfully.
Run `velero restore describe nginx-backup` or `velero restore logs nginx-backup` for more details.


Conclusion

In this post, we discussed what BotKube and Velero are. We also looked at how you can configure BotKube to monitor Velero backups for your Kubernetes clusters. Similarly, we can use BotKube to monitor any custom resources by updating the resource configurations.

Hope you found this blog post informative and engaging. If you have any questions, feel free to reach out to me on LinkedIn. 

Backup Kubernetes Backup and Restore cluster Java (programming language)

Published at DZone with permission of Aashi Modi. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Kubernetes Cluster Backups With Velero
  • Rapidly Develop Java Microservices on Kubernetes With Telepresence
  • Backup and Disaster Recovery in the Age of GitOps and CI/CD Deployments
  • Kafka on Kubernetes, the Strimzi Way (Part 3)

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!