This repository has been archived by the owner on Mar 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
*: add Alibaba Cloud Object Storage Service (OSS) backend for etcd-ba…
…ckup/restore-operators (#2065)
- Loading branch information
Showing
13 changed files
with
650 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Backups using Alibaba Cloud Object Storage Service (OSS) | ||
|
||
## Cluster configured with OSS backup | ||
|
||
To create a backup in OSS, set `backup.storageType` to `"OSS"`, supply the path (in the format `<oss-bucket-name>/<path-to-backup-object>`) in `oss.path` and provide the Kubernetes secret storing the Alibaba Cloud account credentials to `oss.ossSecret`. The secret must exist prior to backup creation. Etcd backup operator will create the bucket and object if not found. The field `oss.endpoint` is the target OSS service endpoint where the data is backed up. By default, `http://oss-cn-hangzhou.aliyuncs.com` will be used. If you want to back up the data to other regions, please specify another endpoint from [the list of region endpoints](https://www.alibabacloud.com/help/doc-detail/31837.htm). | ||
|
||
|
||
An example backup manifest would look like: | ||
|
||
```yaml | ||
apiVersion: etcd.database.coreos.com/v1beta2 | ||
kind: EtcdBackup | ||
metadata: | ||
name: etcd-cluster-with-oss-backup | ||
namespace: my-namespace | ||
spec: | ||
backupPolicy: | ||
... | ||
etcdEndpoints: | ||
- "http://example-etcd-cluster-client:2379" | ||
storageType: OSS | ||
oss: | ||
endpoint: http://oss-cn-hangzhou.aliyuncs.com | ||
ossSecret: my-oss-credentials | ||
path: my-etcd-backups-bucket/etcd.backup | ||
``` | ||
### In Detail: | ||
- `"ossSecret"` represents the name of the Kubernetes secret object that stores the credentials needed for Alibaba Cloud authorization, namely an authorization token. | ||
The Kubernetes secret manifest must have the following format: | ||
```yaml | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: my-oss-credentials | ||
type: Opaque | ||
data: | ||
accessKeyID: <my-access-key-id> | ||
accessKeySecret: <my-access-key-secret> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Backups using Alibaba Cloud Object Storage Service (OSS) | ||
|
||
Etcd backup operator backs up the data of an etcd cluster running on Kubernetes to a remote storage such as Alibaba Cloud Object Storage Service (OSS). If it is not deployed yet, please follow the [instructions](walkthrough/backup-operator.md#deploy-etcd-backup-operator) to deploy it, e.g. by running | ||
|
||
```sh | ||
kubectl apply -f example/etcd-backup-operator/deployment.yaml | ||
``` | ||
|
||
## Setup Alibaba Cloud backup account, OSS bucket, and Secret | ||
|
||
1. Login [Alibaba Cloud Console](https://www.alibabacloud.com) (or [Aliyun Console](https://www.aliyun.com/) if you are in China) and create your own [AccessKey](https://www.alibabacloud.com/help/doc-detail/29009.htm) which gives you the AccessKeyID (AKID) and AccessKeySecret (AKS). You can optionally create an Object Storage Service ([OSS](https://www.alibabacloud.com/help/doc-detail/31947.htm)) bucket for backups. | ||
2. Create a secret storing your AKID and AKS in Kubernetes. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: my-oss-credentials | ||
type: Opaque | ||
data: | ||
accessKeyID: <my-access-key-id> | ||
accessKeySecret: <my-access-key-secret> | ||
``` | ||
3. Create an `EtcdBackup` CR file `etcdbackup.yaml` which uses secret `my-oss-credentials` from the previous step. | ||
```yaml | ||
apiVersion: etcd.database.coreos.com/v1beta2 | ||
kind: EtcdBackup | ||
metadata: | ||
name: etcd-cluster-with-oss-backup | ||
spec: | ||
backupPolicy: | ||
... | ||
etcdEndpoints: | ||
- "http://example-etcd-cluster-client:2379" | ||
storageType: OSS | ||
oss: | ||
endpoint: http://oss-cn-hangzhou.aliyuncs.com | ||
ossSecret: my-oss-credentials | ||
path: my-etcd-backups-bucket/etcd.backup | ||
``` | ||
|
||
4. Apply yaml file to kubernetes cluster. | ||
```sh | ||
kubectl apply -f etcdbackup.yaml | ||
``` | ||
5. Check the `status` section of the `EtcdBackup` CR. | ||
```console | ||
$ kubectl get EtcdBackup etcd-cluster-with-oss-backup -o yaml | ||
apiVersion: etcd.database.coreos.com/v1beta2 | ||
kind: EtcdBackup | ||
... | ||
spec: | ||
oss: | ||
ossSecret: my-oss-credentials | ||
path: my-etcd-backups-bucket/etcd.backup | ||
endpoint: http://oss-cn-hangzhou.aliyuncs.com | ||
etcdEndpoints: | ||
- http://example-etcd-cluster-client:2379 | ||
storageType: OSS | ||
status: | ||
etcdRevision: 1 | ||
etcdVersion: 3.2.13 | ||
succeeded: true | ||
``` | ||
|
||
6. We should see the backup files from Alibaba Cloud OSS Console. | ||
|
||
|
||
## Restore etcd based on data from OSS. | ||
|
||
Etcd restore operator is in charge of restoring etcd cluster from backup. If it is not deployed, please deploy by following command: | ||
|
||
```sh | ||
kubectl apply -f example/etcd-restore-operator/deployment.yaml | ||
``` | ||
|
||
Now kill all the etcd pods to simulate a cluster failure: | ||
|
||
```sh | ||
kubectl delete pod -l app=etcd,etcd_cluster=example-etcd-cluster --force --grace-period=0 | ||
``` | ||
|
||
1. Create an EtcdRestore CR. | ||
```yaml | ||
apiVersion: "etcd.database.coreos.com/v1beta2" | ||
kind: "EtcdRestore" | ||
metadata: | ||
# The restore CR name must be the same as spec.etcdCluster.name | ||
name: example-etcd-cluster | ||
spec: | ||
etcdCluster: | ||
# The namespace is the same as this EtcdRestore CR | ||
name: example-etcd-cluster | ||
backupStorageType: OSS | ||
oss: | ||
# The format of the path must be: "<oss-bucket-name>/<path-to-backup-file>" | ||
path: my-etcd-backups-bucket/etcd.backup | ||
ossSecret: my-oss-credentials | ||
endpoint: http://oss-cn-hangzhou.aliyuncs.com | ||
``` | ||
|
||
2. Check the `status` section of the `EtcdRestore` CR. | ||
```sh | ||
$ kubectl get etcdrestore example-etcd-cluster -o yaml | ||
apiVersion: etcd.database.coreos.com/v1beta2 | ||
kind: EtcdRestore | ||
... | ||
spec: | ||
oss: | ||
ossSecret: my-oss-credentials | ||
path: my-etcd-backups-bucket/etcd.backup | ||
endpoint: http://oss-cn-hangzhou.aliyuncs.com | ||
backupStorageType: OSS | ||
etcdCluster: | ||
name: example-etcd-cluster | ||
status: | ||
succeeded: true | ||
``` | ||
|
||
3. Verify the `EtcdCluster` CR and restored pods for the restored cluster. | ||
```sh | ||
$ kubectl get etcdcluster | ||
$ kubectl get pods -l app=etcd,etcd_cluster=example-etcd-cluster | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.