From ab43ab0b2f06441fd8f6f9d0269d878122c019a3 Mon Sep 17 00:00:00 2001 From: Max! Date: Wed, 16 Oct 2024 19:39:02 +0200 Subject: [PATCH] update docs to work with v3.77 --- Kubernetes-Backups-and-Recovery-with-K8up.md | 210 +++++++++++++------ 1 file changed, 146 insertions(+), 64 deletions(-) diff --git a/Kubernetes-Backups-and-Recovery-with-K8up.md b/Kubernetes-Backups-and-Recovery-with-K8up.md index f9ccc42..332ee29 100644 --- a/Kubernetes-Backups-and-Recovery-with-K8up.md +++ b/Kubernetes-Backups-and-Recovery-with-K8up.md @@ -62,7 +62,7 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash helm repo add k8up-io https://k8up-io.github.io/k8up helm repo update - + kubectl apply -f https://github.com/k8up-io/k8up/releases/download/k8up-4.4.3/k8up-crd.yaml helm install k8up k8up-io/k8up ``` @@ -84,11 +84,12 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 export PATH=$PATH:$HOME/minio-binaries/ ``` -2. Clone repo and cd to the helm dir +2. Download SeaweedFS, unzip, then cd to the helm dir ```bash - git clone https://github.com/seaweedfs/seaweedfs - cd seaweedfs/k8s/charts/seaweedfs + wget https://github.com/seaweedfs/seaweedfs/archive/refs/tags/3.77.zip + unzip 3.77.zip + cd seaweedfs-3.77/k8s/charts/seaweedfs ``` 3. Create a minimal values file for the Seaweedfs deployment which adds annotations for K8up. @@ -96,84 +97,129 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash /bin/cat << EOF > test-values.yaml master: + enabled: true data: type: "persistentVolumeClaim" - size: "5Gi" + size: "10G" storageClass: "local-path" annotations: "k8up.io/backup": "true" + livenessProbe: + periodSeconds: 5 + readinessProbe: + periodSeconds: 5 + volume: + enabled: true + readMode: proxy + dataDirs: + - name: data + type: "persistentVolumeClaim" + size: "10G" + storageClass: "local-path" + annotations: + "k8up.io/backup": "true" + maxVolumes: 0 + idx: {} + livenessProbe: + periodSeconds: 5 + readinessProbe: + periodSeconds: 5 + + filer: + enabled: true + encryptVolumeData: true + enablePVC: true + storage: 10Gi + defaultReplicaPlacement: "000" data: type: "persistentVolumeClaim" - size: "5Gi" + size: "10G" storageClass: "local-path" annotations: "k8up.io/backup": "true" - filer: - enablePVC: true - storage: 5Gi - data: - type: "persistentVolumeClaim" - size: "5Gi" - storageClass: "local-path" - annotations: s3: enabled: true + enableAuth: true port: 8333 httpsPort: 0 allowEmptyFolder: false - domainName: "" - enableAuth: false - skipAuthSecretCreation: false - auditLogConfig: {} + createBuckets: + - name: shared + anonymousRead: false + livenessProbe: + periodSeconds: 5 + readinessProbe: + periodSeconds: 5 + + s3: + enabled: false + cosi: + enabled: false EOF ``` -4. Deploy via Helm +4. Deploy via Helm (takes longer on slow drives) ```bash helm install seaweedfs . -f test-values.yaml --wait ``` -5. Expose the S3 endpoint +5. Expose the filer service via a LoadBalancer (servicelb in k3s). This will let us view the admin UI as well as reach the S3 endpoint during the demo. ```bash /bin/cat << EOF > service.yaml apiVersion: v1 kind: Service metadata: - name: swfs-s3-nodeport labels: - "app.kubernetes.io/name": "seaweedfs" + app.kubernetes.io/component: filer + app.kubernetes.io/instance: seaweedfs + app.kubernetes.io/name: seaweedfs + name: seaweedfs-filer-lb spec: - type: NodePort ports: - - port: 8333 - nodePort: 30000 + - name: swfs-filer + port: 8888 protocol: TCP + targetPort: 8888 + - name: swfs-filer-grpc + port: 18888 + protocol: TCP + targetPort: 18888 + - name: swfs-s3 + port: 8333 + protocol: TCP + targetPort: 8333 + - name: metrics + port: 9327 + protocol: TCP + targetPort: 9327 selector: - "app.kubernetes.io/name": "seaweedfs" + app.kubernetes.io/component: filer + app.kubernetes.io/name: seaweedfs + type: LoadBalancer EOF ``` - -6. Export your NodeIP as an env var + +6. Export your LoadBalancer IP address as an env var ```bash export NODE_IP="" ``` 7. Create an alias for your server using your S3 CLI tool: - + - You can find the `admin_access_key_id` and `admin_secret_access_key` values in the secret `seaweedfs-s3-secret` ```bash - mc alias set seaweedfs http://$NODE_IP:30000 $admin_access_key_id $admin_secret_access_key + mc alias set seaweedfs http://$NODE_IP:8333 $admin_access_key_id $admin_secret_access_key ``` 8. Create a bucket that will hold our demo data ```bash - mc mb seaweedfs s3://backups + mc mb seaweedfs/backups ``` 8. Add some data to the bucket @@ -181,19 +227,27 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash mc cp ./some-file seaweedfs/backups/ ``` - + +9. Verify its there + + ```bash + mc ls seaweedfs/backups + ``` + +10. Open the Web UI at http://$NODE_IP:8888 in a browser to view or add more data. +

Configure scheduled backups of SeaweedFS to B2

1. Create a secret containing your external S3 credentials - You will need to get these from your provider (Backblaze, Wasabi etc..): - + ```bash export ACCESS_KEY_ID=$(echo -n "" | base64) - + export ACCESS_SECRET_KEY=$(echo -n "" |base64) ``` - + ```bash /bin/cat << EOF > backblaze-secret.yaml apiVersion: v1 @@ -208,15 +262,15 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 kubectl apply -f backblaze-secret.yaml ``` - + 2. Create a secret containing a random password for restic - - Generate a password and base64 encode it. - + - Generate a password. + ```bash - export RESTIC_PASS=$(openssl rand -base64 32) + export RESTIC_PASS="" ``` - + - Create a secret manifest ```bash @@ -226,11 +280,11 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 metadata: name: restic-repo type: Opaque - data: + stringData: "password": "$RESTIC_PASS" EOF ``` - + - Create the secret ```bash @@ -244,9 +298,9 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash export BACKUP_S3_URL="" export BACKUP_S3_BUCKET="" - ``` + ``` - - Create a manifest for the backup + - Create a manifest for the backup ```bash /bin/cat << EOF > backup.yaml @@ -281,7 +335,7 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 EOF ``` - - Create the backup + - Create the backup and let it run ```bash kubectl apply -f backup.yaml @@ -289,12 +343,14 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034

Restore SeaweedFS from B2 backups

-1. Uninstall SeaweedFS and delete your scheduled backup +1. Uninstall SeaweedFS, delete the PVCs, secrets, and scheduled backup ```bash - k delete -f manifests.yaml - kubectl delete -f backup.yaml + helm uninstall seaweedfs + kubectl delete pvc data-default-seaweedfs-master-0 + kubectl delete pvc data-filer-seaweedfs-filer-0 + kubectl delete pvc data-seaweedfs-volume-0 ``` 2. Create PVCs to hold our restored data @@ -344,7 +400,7 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 storage: 10Gi EOF ``` - + - Create the PVCs ```bash @@ -356,7 +412,7 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash # the password used in your restic-repo secret export RESTIC_PASSWORD="" - + # Your S3 credentials export AWS_ACCESS_KEY_ID="" export AWS_SECRET_ACCESS_KEY="" @@ -378,9 +434,9 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 3 snapshots ``` -4. Use the K8up CLI or a declarative setup to restore data to the PVC. You will need to do this for each PVC that needs to be restored - - - Example manifest for a S3-to-PVC restore job which uses the restic snapshots shown above. +4. Use the K8up CLI or a declarative setup to restore data to the PVC. You will need to do this for each PVC that needs to be restored + + - Example manifest for a S3-to-PVC restore job which uses the restic snapshots shown above. ```bash /bin/cat << EOF > s3-to-pvc.yaml @@ -460,7 +516,7 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash kubectl apply -f s3-to-pvc.yaml ``` - + 5. Re-deploy Seaweedfs from the existing PVCs - Create a manifest that targets the PVCs we created @@ -468,44 +524,70 @@ PR ref: https://github.com/seaweedfs/seaweedfs/pull/5034 ```bash /bin/cat << EOF > restore-values.yaml master: + enabled: true data: type: "existingClaim" claimName: "swfs-master-data" + livenessProbe: + periodSeconds: 5 + readinessProbe: + periodSeconds: 5 + volume: - data: - type: "existingClaim" - claimName: "swfs-volume-data" + enabled: true + readMode: proxy + dataDirs: + - name: data + type: "existingClaim" + claimName: "swfs-volume-data" + maxVolumes: 0 + idx: {} + livenessProbe: + periodSeconds: 5 + readinessProbe: + periodSeconds: 5 + filer: + enabled: true + encryptVolumeData: true enablePVC: true + storage: 10Gi + defaultReplicaPlacement: "000" data: type: "existingClaim" claimName: "swfs-filer-data" s3: enabled: true + enableAuth: false port: 8333 httpsPort: 0 allowEmptyFolder: false - domainName: "" - enableAuth: false - skipAuthSecretCreation: false - auditLogConfig: {} + livenessProbe: + periodSeconds: 5 + readinessProbe: + periodSeconds: 5 + + s3: + enabled: false + cosi: + enabled: false EOF ``` - Deploy via Helm - + ```bash helm install seaweedfs . -f restore-values.yaml --wait ``` 7. Update your alias for your server: - + - get the `admin_access_key_id` and `admin_secret_access_key` from the secret `seaweedfs-s3-secret` ```bash mc alias set seaweedfs http://$NODE_IP:30000 $admin_access_key_id $admin_secret_access_key ``` - + - View for your data: ```bash