Skip to content

Instantly share code, notes, and snippets.

@ikurni
Last active July 7, 2020 15:59
Show Gist options
  • Save ikurni/1d0e7e3e4371540ed88a29d11d7dd317 to your computer and use it in GitHub Desktop.
Save ikurni/1d0e7e3e4371540ed88a29d11d7dd317 to your computer and use it in GitHub Desktop.
Use Velero for Openshift 3 to Openshift 4 Migration
##Download Velero from Source repo :
wget https://github.com/vmware-tanzu/velero/releases/download/v1.4.0/velero-v1.4.0-linux-amd64.tar.gz
##Pull required image from docker.io
podman pull docker.io/minio/mc
podman pull docker.io/minio/minio
podman pull docker.io/velero/velero:v1.4.0
podman pull docker.io/velero/velero-plugin-for-aws:v1.0.0
##Push all images to docker-registry.default.svc:5000 (internal docker registry)
##Extract :
tar zxf velero-v1.4.0-linux-amd64.tar.gz
##Move to the folder :
cd velero-v1.4.0-linux-amd64/
##Edit Minio deployment :
vi examples/minio/00-minio-deployment.yaml
##Edit as required, below are the example with PV, PVC and Minio Image (minio and mc) has been prepared before
---
apiVersion: v1
kind: Namespace
metadata:
name: velero
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: velero
name: minio
labels:
component: minio
spec:
strategy:
type: Recreate
selector:
matchLabels:
component: minio
template:
metadata:
labels:
component: minio
spec:
volumes:
- name: storage
persistentVolumeClaim:
claimName: miniostoragepvc
- name: config
persistentVolumeClaim:
claimName: minioconfigpvc
containers:
- name: minio
image: docker-registry.default.svc:5000/openshift/minio:latest
imagePullPolicy: IfNotPresent
args:
- server
- /storage
- --config-dir=/config
env:
- name: MINIO_ACCESS_KEY
value: "minio"
- name: MINIO_SECRET_KEY
value: "minio123"
ports:
- containerPort: 9000
volumeMounts:
- name: storage
mountPath: "/storage"
- name: config
mountPath: "/config"
---
apiVersion: v1
kind: Service
metadata:
namespace: velero
name: minio
labels:
component: minio
spec:
type: ClusterIP
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
component: minio
---
apiVersion: batch/v1
kind: Job
metadata:
namespace: velero
name: minio-setup
labels:
component: minio
spec:
template:
metadata:
name: minio-setup
spec:
restartPolicy: OnFailure
volumes:
- name: config
emptyDir: {}
containers:
- name: mc
image: docker-registry.default.svc:5000/openshift/mc:latest
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- "mc --config-dir=/config config host add velero http://minio:9000 minio minio123 && mc --config-dir=/config mb -p velero/velero"
volumeMounts:
- name: config
mountPath: "/config"
##Create Minio object
oc create -f 00-minio-deployment.yaml
##Check the running pod, and make sure all resources running well. Expose minio service, default will use HTTP traffic
oc expose svc minio
##Try to access the URL, login with minio/minio123, make sure can login properly
##Copy Velero binary from the downloaded folder to usr bin folder
cp /home/user/velero-v1.4.0-linux-amd64/velero /usr/bin/
##Create Minio Creds file for Velero
vi /home/user/minio-creds
[default]
aws_access_key_id = minio
aws_secret_access_key = minio123
##Save
##Install velero to Velero Namespace in openshift (create if it hasn't created), run this command from the linux machine
##It will automatically create deployment of Velero in Velero Project, assume velero image also has been pushed to internal docker registry (velero and velero-plugin-for-aws)
velero install --provider aws --bucket velero --secret-file /home/user/minio-creds --use-volume-snapshots=false --backup-location-config \
region=minio,s3ForcePathStyle="true",s3Url=http://minio-velero.apps.example.com --plugins docker-registry.default.svc:5000/velero/velero-plugin-for-aws:v1.0.0
##Below is the additional api resources added by velero install
----------------------------
CustomResourceDefinition/backups.velero.io: attempting to create resource
CustomResourceDefinition/backups.velero.io: already exists, proceeding
CustomResourceDefinition/backups.velero.io: created
CustomResourceDefinition/backupstoragelocations.velero.io: attempting to create resource
CustomResourceDefinition/backupstoragelocations.velero.io: already exists, proceeding
CustomResourceDefinition/backupstoragelocations.velero.io: created
CustomResourceDefinition/deletebackuprequests.velero.io: attempting to create resource
CustomResourceDefinition/deletebackuprequests.velero.io: already exists, proceeding
CustomResourceDefinition/deletebackuprequests.velero.io: created
CustomResourceDefinition/downloadrequests.velero.io: attempting to create resource
CustomResourceDefinition/downloadrequests.velero.io: already exists, proceeding
CustomResourceDefinition/downloadrequests.velero.io: created
CustomResourceDefinition/podvolumebackups.velero.io: attempting to create resource
CustomResourceDefinition/podvolumebackups.velero.io: already exists, proceeding
CustomResourceDefinition/podvolumebackups.velero.io: created
CustomResourceDefinition/podvolumerestores.velero.io: attempting to create resource
CustomResourceDefinition/podvolumerestores.velero.io: already exists, proceeding
CustomResourceDefinition/podvolumerestores.velero.io: created
CustomResourceDefinition/resticrepositories.velero.io: attempting to create resource
CustomResourceDefinition/resticrepositories.velero.io: already exists, proceeding
CustomResourceDefinition/resticrepositories.velero.io: created
CustomResourceDefinition/restores.velero.io: attempting to create resource
CustomResourceDefinition/restores.velero.io: already exists, proceeding
CustomResourceDefinition/restores.velero.io: created
CustomResourceDefinition/schedules.velero.io: attempting to create resource
CustomResourceDefinition/schedules.velero.io: already exists, proceeding
CustomResourceDefinition/schedules.velero.io: created
CustomResourceDefinition/serverstatusrequests.velero.io: attempting to create resource
CustomResourceDefinition/serverstatusrequests.velero.io: already exists, proceeding
CustomResourceDefinition/serverstatusrequests.velero.io: created
CustomResourceDefinition/volumesnapshotlocations.velero.io: attempting to create resource
CustomResourceDefinition/volumesnapshotlocations.velero.io: already exists, proceeding
CustomResourceDefinition/volumesnapshotlocations.velero.io: created
Waiting for resources to be ready in cluster...
Namespace/velero: attempting to create resource
Namespace/velero: already exists, proceeding
Namespace/velero: created
ClusterRoleBinding/velero: attempting to create resource
ClusterRoleBinding/velero: created
ServiceAccount/velero: attempting to create resource
ServiceAccount/velero: created
Secret/cloud-credentials: attempting to create resource
Secret/cloud-credentials: created
BackupStorageLocation/default: attempting to create resource
BackupStorageLocation/default: created
Deployment/velero: attempting to create resource
Deployment/velero: created
Velero is installed! ⛵ Use 'kubectl logs deployment/velero -n velero' to view the status.
----------------------------
##Make sure all velero resources are running properly
##Run backup, excluded resource is depend on requirement
velero backup create {backup-name} --include-namespaces {namespaces-which-want-to-backup} --exclude-resources build.build.openshift.io,replicationcontroller,pods,images,pvc,pv
##Check backup progress
velero backup describe {backup-name}
##Check backup logs
velero backup logs {backup-name}
##If backup is successful, the backup-name will show up in the minio bucket
##To restore in the destination, make sure velero is installed with the same step above, and run below command in the target machine, and target openshift
velero restore create {restore-name} --from-backup {backup-name}
##Check restore progress
velero restore describe {restore-name}
##Check restore logs
velero restore logs {restore-name}
##Check restore result in the target openshift cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment