This topic describes how to use Velero to back up and restore a stateless application using the namespace feature with Velero.


The application we are going to use to test back up/restore with Velero is the standard Guestbook app (stateless app).


Install and configure Minio and Velero.

Download the Guestbook app YAML files to a local known directory:

  • redis-leader-deployment.yaml
  • redis-leader-service.yaml
  • redis-follower-deployment.yaml
  • redis-follower-service.yaml
  • frontend-deployment.yaml
  • frontend-service.yaml

Deploy Guestbook App

Create Guestbook namespace:

kubectl create ns guestbook
namespace/guestbook created

Deploy the Guestbook app:

kubectl apply -f . -n guestbook
deployment.apps/frontend created
service/frontend created
deployment.apps/redis-leader created
service/redis-leader created
deployment.apps/redis-follower created
service/redis-follower created


kubectl get pod -n guestbook
NAME                            READY   STATUS    RESTARTS   AGE
frontend-6cb7f8bd65-kqbf6       1/1     Running   0          38s
frontend-6cb7f8bd65-s7mk9       1/1     Running   0          38s
frontend-6cb7f8bd65-vtz4k       1/1     Running   0          38s
redis-leader-7b8487bf68-2mhcd   1/1     Running   0          38s
redis-follower-5bdcfd74c7-4hhqs 1/1  Running   0          37s
redis-follower-5bdcfd74c7-hl8hf 1/1     Running   0          37s
kubectl get svc -n guestbook
NAME           TYPE           CLUSTER-IP       EXTERNAL-IP    PORT(S)        AGE
frontend       LoadBalancer   80:32498/TCP   47s
redis-leader   ClusterIP   <none>         6379/TCP       47s
redis-follower ClusterIP   <none>         6379/TCP       46s

Access the Guestbook app at

Guestbook App

Back Up the Guestbook App using Namespace

This example shows how to back up and restore the Guestbook app using the --include namespace tag.

velero backup create guestbook-backup --include-namespaces guestbook

Back up request "guestbook-backup" submitted successfully.
Run `velero backup describe guestbook-backup` or `velero backup logs guestbook-backup` for more details.


velero backup describe guestbook-backup

Expect result:

Name:         guestbook-backup
Namespace:    velero

Phase:  Completed

Errors:    0
Warnings:  0

  Included:  guestbook
  Excluded:  <none>

  Included:        *
  Excluded:        <none>
  Cluster-scoped:  auto

Label selector:  <none>

Storage Location:  default

Velero-Native Snapshot PVs:  auto

TTL:  720h0m0s

Hooks:  <none>

Backup Format Version:  1

Started:    2020-07-21 14:45:51 -0700 PDT
Completed:  2020-07-21 14:45:52 -0700 PDT

Expiration:  2020-08-20 14:45:51 -0700 PDT

Total items to be backed up:  60
Items backed up:              60

Velero-Native Snapshots: <none included>

Verify the backup that was created.

velero backup get

guestbook-backup   Completed   0        0          2020-07-21 14:45:51 -0700 PDT   29d       default            <none>

Check the tkgi-velero bucket on the MinIO server.

Guestbook App

Velero writes some metadata in Kubernetes CustomResourceDefinition (CRD).

kubectl get crd

Expected result:

NAME                                CREATED AT                   2020-07-21T21:04:39Z    2020-07-21T21:04:39Z           2020-07-07T22:55:25Z        2020-07-07T22:55:26Z      2020-07-21T21:04:39Z          2020-07-21T21:04:39Z            2020-07-07T22:39:04Z                  2020-07-07T22:55:25Z               2020-07-07T22:55:26Z            2020-07-07T22:39:04Z            2020-07-07T22:39:05Z             2020-07-07T22:39:04Z          2020-07-21T21:04:39Z         2020-07-21T21:04:39Z        2020-07-21T21:04:39Z                  2020-07-21T21:04:39Z                 2020-07-21T21:04:40Z      2020-07-21T21:04:40Z   2020-07-21T21:04:40Z

The Velero CRDs let you run certain commands, such as the following:

kubectl get -n velero

NAME               AGE
guestbook-backup   4m58s
kubectl describe guestbook-backup -n velero

Name:         guestbook-backup
Namespace:    velero
Annotations: v1.17.8+vmware.1
API Version:
Kind:         Backup
  Creation Timestamp:  2020-07-21T21:45:51Z
  Generation:          5
  Resource Version:    3355027
  Self Link:           /apis/
  UID:                 9d71a2c4-6fdd-42a2-963d-e85a91926dac
  Included Namespaces:
  Storage Location:  default
  Ttl:               720h0m0s
  Completion Timestamp:  2020-07-21T21:45:52Z
  Expiration:            2020-08-20T21:45:51Z
  Format Version:        1.1.0
  Phase:                 Completed
    Items Backed Up:  60
    Total Items:      60
  Start Timestamp:    2020-07-21T21:45:51Z
  Version:            1
Events:               <none>

Restore the Guestbook App

To test the restoration of the Guestbook app, delete it.

Delete the namespace:

kubectl delete ns guestbook
namespace "guestbook" deleted

Restore the app:

velero restore create --from-backup guestbook-backup

Restore request "guestbook-backup-20200721145620" submitted successfully.
Run `velero restore describe guestbook-backup-20200721145620` or `velero restore logs guestbook-backup-20200721145620` for more details.

Verify that the app is restored:

velero restore describe guestbook-backup-20200721145620
Name:         guestbook-backup-20200721145620
Namespace:    velero
Labels:       <none>
Annotations:  <none>

Phase:  Completed

Backup:  guestbook-backup

  Included:  all namespaces found in the backup
  Excluded:  <none>

  Included:        *
  Excluded:        nodes, events,,,,
  Cluster-scoped:  auto

Namespace mappings:  <none>

Label selector:  <none>

Restore PVs:  auto

Run the following commands to verify:

velero restore get
NAME                              BACKUP             STATUS      ERRORS   WARNINGS   CREATED                         SELECTOR
guestbook-backup-20200721145620   guestbook-backup   Completed   0        0          2020-07-21 14:56:20 -0700 PDT   <none>
kubectl get ns

NAME              STATUS   AGE
default           Active   13d
guestbook         Active   19s
kube-node-lease   Active   13d
kube-public       Active   13d
kube-system       Active   13d
pks-system        Active   13d
velero            Active   50m
kubectl get pod -n guestbook

NAME                            READY   STATUS    RESTARTS   AGE
frontend-6cb7f8bd65-kqbf6       1/1     Running   0          29s
frontend-6cb7f8bd65-s7mk9       1/1     Running   0          29s
frontend-6cb7f8bd65-vtz4k       1/1     Running   0          29s
redis-leader-7b8487bf68-2mhcd   1/1     Running   0          29s
redis-follower-5bdcfd74c7-4hhqs 1/1     Running   0          29s
redis-follower-5bdcfd74c7-hl8hf 1/1     Running   0          29s
kubectl get svc -n guestbook

NAME           TYPE           CLUSTER-IP       EXTERNAL-IP    PORT(S)        AGE
frontend       LoadBalancer   80:32673/TCP   34s
redis-leader   ClusterIP    <none>         6379/TCP       34s
redis-follower ClusterIP   <none>         6379/TCP       34s

Access the Guestbook app at

Guestbook App


Note the following:

  • The namespace guestbook is automatically re-created.
  • The IP address for the Kubernetes service load balancer is changed from to .14.
check-circle-line exclamation-circle-line close-line
Scroll to top icon