Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Edit backuprestore content initial #21

Merged
merged 13 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions content/docs/reference/backuprestore/README.md

This file was deleted.

62 changes: 62 additions & 0 deletions content/docs/reference/backuprestore/backup-restore.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Backup and Restore

>MKE 4 backup is enabled by default.

MKE 4 supports backup and restore of cluster data through the use of the
[Velero](https://velero.io/) addon.

## Configuration

The `backup` section of the MKE4 configuration file renders as follows:

```yaml
backup:
enabled: true
storage_provider:
type: InCluster
in_cluster_options:
exposed: true
distributed: false
```
By default, MKE 4 supports backups that use the in-cluster storage
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
provider, as indicated in the ``type`` option setting of ``InCluster``. MKE 4
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
in-cluster backups are implemented using the [MinIO
addon](https://microk8s.io/docs/addon-minio).

The `exposed` option setting of ``true`` indicates that the MinIO service is
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
exposed through NodePort, which Velero requires to function correctly. Core
backup functionality should work, however, even if
the service is not exposed.

The `distributed` option configures MinIO storage to run in distributed mode.

Refer to the following table for detail on all of the conifguration file
``backup`` fields:

| Field | Description | Valid values | Default |
tppolkow marked this conversation as resolved.
Show resolved Hide resolved
|------------------------------------------------------------|--------------------------------------------------------------------------------------|---------------------|:---------:|
| enabled | Indicates whether backup/restore functionality is enabled. | true, false | true |
| storage_provider.type | Indicates whether the storage type in use is in-cluster or external. | InCluster, External | InCluster |
| storage_provider.in_cluster_options.exposed | Indicates whether to expose InCluster (MinIO) storage through NodePort. | true, false | true |
| storage_provider.in_cluster_options.distributed | Indicates whether to run MinIO in distributed mode. | true, false | false |
| storage_provider.external_options.provider | Name of the external storage provider. Note that AWS is currently the only available option. | aws | aws |
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
| storage_provider.external_options.bucket | Name of the pre-created bucket to use for backup storage. | "" | "" |
| storage_provider.external_options.region | Region in which the bucket exists. | "" | "" |
| storage_provider.external_options.credentials_file_path | Path to Credentials File. | "" | "" |
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
| storage_provider.external_options.credentials_file_profile | Profile in the Credentials file to use. | "" | "" |

## Create backups and restores
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create backups and perform restorations

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed the word 'restore' in this context with @tppolkow, and he informed me that restore is the name of the underlying Kubernetes object. Alongside that, I did a bit of Internet searching and found the use of restore as a verb in reference to software systems is quite common. So all of that said, I suggest we meet in the middle and insert perform but keep restores.


For information on how to create backups and run restores for both storage
provider types, refer to:

- In-cluster storage provider: [in_cluster.md](./in_cluster.md)
- External storage provider: [external.md](./external.md)

## Existing Limitations

- Scheduled backups, an MKE 3 feature that is planned for integration to MKE 4, have not yet been implemented.

- Backups must currently be restored in the same cluster in which
the backup was taken, and thus restoring a backup to a
new set of nodes is not yet supported for the in-cluster storage provider.
89 changes: 53 additions & 36 deletions content/docs/reference/backuprestore/external.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,67 @@
# Backup and Restore Using External Storage Providers

It is possible to configure MKE to store backups and restores externally, for example in object storage provided by a public cloud provider. Currently only AWS S3 is supported as an external backup store.
You can configure MKE 4 to store backups and restores externally, for example
in object storage provided by a public cloud provider.

>AWS S3 is currently the only supported external backup store
>that MKE 4 supports.

## Configuration

Prior to modifying the MKE configuration file, create an IAM credentials file. This file should look like below
```
[386383511305_docker-testing]
aws_access_key_id=key
aws_secret_access_key=secret
aws_session_token=token
```
1. Copy the credentials information from the AWS console to create an IAM
credentials file.

This can be easily copied from AWS console below:
![img.png](img.png)

![img.png](img.png)
2. Edit the `storage_provider` section of the mke configuration file to point
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
to the IAM credentials file, including the profile name.

Once the Credentials file is created, update the `storage_provider` section of the mke config file to point to the created creds file including the profile name. Additionally, you need to create an S3 bucket and point the configuration to the correct bucket and region.
3. Create an S3 bucket and configure the IAM configuration file to point to the
bucket and region.

```yaml
storage_provider:
type: External
external_options:
provider: aws
bucket: bucket_name
region: us-west-2
credentials_file_path: "/path/to/iamcredentials"
credentials_file_profile: "386383511305_docker-testing"
```
Example configuration:

## Usage
```yaml
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
storage_provider:
type: External
external_options:
provider: aws
bucket: bucket_name
region: us-west-2
credentials_file_path: "/path/to/iamcredentials"
credentials_file_profile: "386383511305_docker-testing"
```

Once AWS backup storage has been configured and the mke config file applied, check that the `BackupStorageLocation` CR exists and is ready. This may take a few minutes after `mkectl apply` is run.
Once you have configured AWS backup storage and the mke configuration file has
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
been applied, verify that the `BackupStorageLocation` CR exists.

```shell
kubectl get backupstoragelocation -n mke
```

Output:
> After you run `mkectl apply` the output may require a few minutes to display.

Example output:

```shell
NAME PHASE LAST VALIDATED AGE DEFAULT
default Available 20s 32s true
```

We can now create backups as usual and restore them. After creating a restore, the Kubernetes cluster state should resemble what it was when the backup was taken.
You can now create backups and restore from those backups. After you have run a
restore operation from a backup, the Kubernetes cluster state should resemble
what it was at the time you created that backup.

## Create an external backup

To create an external backup, run:

```shell
mkectl backup create --name aws-backup
```

Output:
Example Output:
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved

```shell
INFO[0000] Creating backup aws-backup...
Backup request "aws-backup" submitted successfully.
Expand All @@ -63,23 +75,25 @@ INFO[0015] Waiting for backup to complete. Current phase: Completed
INFO[0015] Backup aws-backup completed successfully
```

List the backups:
```shell
mkectl backup list
```
You can list the backups by running the `mkectl backup list` command:
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved

Example output:

Output:
```shell
NAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTOR
aws-backup Completed 0 0 2024-05-08 16:17:18 -0400 EDT 29d default <none>
```

Create the restore:
## Restore from an external backup

To create a restore using an external backup, run:

```shell
mkectl restore create --name aws-backup
```

Output:
Example output:

```shell
INFO[0000] Waiting for restore aws-backup-20240508161811 to complete...
INFO[0000] Waiting for restore to complete. Current phase: InProgress
Expand All @@ -94,17 +108,20 @@ INFO[0024] Waiting for restore to complete. Current phase: Completed
INFO[0024] Restore aws-backup-20240508161811 completed successfully
```

List the restores:
To list the restores, run:

```shell
mkectl restore list
```

Output:
Example output:

```shell
NAME BACKUP STATUS STARTED COMPLETED ERRORS WARNINGS CREATED SELECTOR
aws-backup-20240508161811 aws-backup Completed 2024-05-08 16:18:11 -0400 EDT 2024-05-08 16:18:34 -0400 EDT 0 108 2024-05-08 16:18:11 -0400 EDT <none>
```

We can also see that both the backup and restore are created in our S3 bucket:
From your AWS console, you can see that both the backup and restore are created
in the S3 bucket:

![img_1.png](img_1.png)
49 changes: 40 additions & 9 deletions content/docs/reference/backuprestore/in_cluster.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
# Backup and Restore Using In Cluster Storage Provider
By default, MKE will store backups and restores using the in cluster storage provider (MinIO). The below instructions assume you have created a cluster and applied a blueprint with the default MKE backup configuration.
# Backup and Restore using the In-Cluster Storage Provider
By default, MKE 4 stores backups and restores using the in-cluster storage
provider, the [MinIO addon](https://microk8s.io/docs/addon-minio).

## Usage
Backups can be created using `mkectl backup create --name <name>`.
>The offered instructions assume that you have created a cluster and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be commented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, yes, this type of content should usually be set apart from the main textual flow in some manner.

applied a blueprint with the default MKE backup configuration.


## Create an In-Cluster backup
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved

To create an In-Cluster backup, run:
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved

```shell
mkectl backup create --name <name>
```

Example output:

```shell
mkectl backup create --name test
Expand All @@ -17,17 +29,29 @@ INFO[0012] Waiting for backup to complete. Current phase: InProgress
INFO[0015] Waiting for backup to complete. Current phase: Completed
```

The backup should now be present in the MinIO bucket. You can list the backups using `mkectl backup list`.
The backup should be present in the MinIO bucket. You can list the backups by
KoryKessel-Mirantis marked this conversation as resolved.
Show resolved Hide resolved
running the `mkectl backup list` command:

Example output:

```shell
mkectl backup list
NAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTOR
test Completed 0 0 2024-05-07 17:29:18 -0400 EDT 29d default <none>
```

Optionally, detailed logs of a backup can be viewed via `mkectl backup logs --name test`
Optionally, you can view detailed logs of a backup by running the `mkectl
backup logs --name test` command.

## Restore from an In-Cluster backup

To create a restore off the backup we created we can run `mkectl restore create --name test`
To create a restore using an In-Cluster backup, run:

```shell
mkectl restore create --name test
```

Example output:

```shell
mkectl restore create --name test
Expand All @@ -45,14 +69,21 @@ INFO[0027] Waiting for restore to complete. Current phase: Completed
INFO[0027] Restore test-20240507173309 completed successfully
```

We can list the restores using `mkectl restore list`
To list the restores, run:

```shell
mkectl restore list
```

Example output:

```shell
mkectl restore list
NAME BACKUP STATUS STARTED COMPLETED ERRORS WARNINGS CREATED SELECTOR
test-20240507173309 test Completed 2024-05-07 17:33:09 -0400 EDT 2024-05-07 17:33:34 -0400 EDT 0 121 2024-05-07 17:33:09 -0400 EDT <none>
```

We can optionally view detailed logs similar to the backup logs using `mkectl restore logs --name test-20240507173309`.
Optionally, you can view detailed logs by running the `mkectl restore logs
--name test-20240507173309` command.