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

Add readme files for Backup and Restore #596

Merged
merged 33 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
562e67a
Started README for backup tool
akgalwas Jan 9, 2025
35d78b3
Fixes in backup plus README
akgalwas Jan 10, 2025
ac3ee3c
Merge branch 'main' into backup-restore-5
akgalwas Jan 10, 2025
6281980
Missing information added to backup README
akgalwas Jan 10, 2025
a7ba228
Add the first version for restore readme
akgalwas Jan 10, 2025
4ff26cc
Store backup on the disk in the dry run mode plus chanegs in README
akgalwas Jan 13, 2025
e096475
Backup folder renamed
akgalwas Jan 13, 2025
0041766
Readme for backup and restore updated plus minor fixes
akgalwas Jan 13, 2025
151d9dd
Update README-rb.md
akgalwas Jan 13, 2025
c0e46ed
Update README-rr.md
akgalwas Jan 13, 2025
6c1b9ce
Update README-rr.md
akgalwas Jan 13, 2025
7f9adba
Update README-rr.md
akgalwas Jan 13, 2025
9a532f2
Update README-rb.md
akgalwas Jan 13, 2025
610233f
Update README-rm.md
akgalwas Jan 13, 2025
7405052
Update README-rm.md
akgalwas Jan 13, 2025
af8c686
Update README-rr.md
akgalwas Jan 13, 2025
2682469
Readme for runtime restored
akgalwas Jan 13, 2025
0fe4b1b
forces server side apply for backup
Disper Jan 13, 2025
05e5aee
Merge pull request #2 from Disper/fix_force_ssa
akgalwas Jan 13, 2025
dc5f4b2
Restore sets kyma-project.io/controlled-by-provisioner to true
akgalwas Jan 14, 2025
cc002a8
Apply suggestions from code review
akgalwas Jan 14, 2025
d11cb2e
Updated restore README to make more clear what resources are updated
akgalwas Jan 14, 2025
20db9e8
Added information that the `kcp.provisioner.kyma-project.io/runtime-i…
akgalwas Jan 14, 2025
e993bc7
Minor fix to readme files
akgalwas Jan 14, 2025
6a1e1bf
Merge branch 'main' into backup-restore-5
akgalwas Jan 14, 2025
5e58fe4
Apply first wave of suggestions from code review
Disper Jan 15, 2025
a9a0b5d
Apply suggestions from code review
Disper Jan 15, 2025
f5df405
docs: moves example explanation above the snippet
Disper Jan 16, 2025
9ce2278
docs: moves example explanation above the snippet
Disper Jan 16, 2025
689b735
Apply suggestions from code review
Disper Jan 16, 2025
759c9ac
docs: make list intro sentence complete
Disper Jan 16, 2025
3004032
Apply suggestions from code review
Disper Jan 16, 2025
fddebc8
docs: moves example explanation above the snippet
Disper Jan 16, 2025
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
140 changes: 139 additions & 1 deletion hack/runtime-migrator/README-rb.md
Original file line number Diff line number Diff line change
@@ -1 +1,139 @@
# Runtime Backuper
# Runtime backup and switch
Disper marked this conversation as resolved.
Show resolved Hide resolved

The `runtime-backup-and-switch` application
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. connects to a Gardener project, and KCP cluster
Disper marked this conversation as resolved.
Show resolved Hide resolved
2. retrieves all existing shoot specifications
Disper marked this conversation as resolved.
Show resolved Hide resolved
3. for each runtime on input list that was created by provisioner (shoot is labelled with `kcp.provisioner.kyma-project.io/runtime-id`):
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. gets shoot, Cluster Role Bindings and OpenIDConnect resources
Disper marked this conversation as resolved.
Show resolved Hide resolved
2. saves the backup on a disk
Disper marked this conversation as resolved.
Show resolved Hide resolved
3. marks Cluster Role Bindings that were created by the Provisioner with `kyma-project.io/deprecation` label
Disper marked this conversation as resolved.
Show resolved Hide resolved
4. sets `kyma-project.io/controlled-by-provisioner` label with `false` value in order to make sure KIM will control the runtime
Disper marked this conversation as resolved.
Show resolved Hide resolved

## Build

In order to build the app, run the following command:
Disper marked this conversation as resolved.
Show resolved Hide resolved

```bash
go build -o ./bin/runtime-backup-and-switch ./cmd/backup-and-switch
```

## Usage

### Dry run
Disper marked this conversation as resolved.
Show resolved Hide resolved
```bash
NHingerl marked this conversation as resolved.
Show resolved Hide resolved
./bin/runtime-backup-and-switch \
-gardener-kubeconfig-path=/Users/myuser/gardener-kubeconfig.yml \
-gardener-project-name=kyma-dev \
-kcp-kubeconfig-path=/Users/myuser/kcp-kubeconfig.yml \
-output-path=/tmp/ \
-dry-run=true \
-input-file-path=input/runtimeIds.txt \
-input-type=txt
```

The above **execution example** will:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The above **execution example** will:
This execution example does the following:

Out of curiosity: Why did you format the execution example as bold? Is there some special meaning I'm missing that justifies highlighting it?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what is the reason of this highlighting (@akgalwas ?) without knowing that I've just applied your suggestion.

1. take the input from the `input/runtimeIds.txt` file (each raw contains single `RuntimeID`)
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. proceed only with fetching Shoot, Cluster Role Bindings and OpenIDConnect resources
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
1. proceed only with fetching Shoot, Cluster Role Bindings and OpenIDConnect resources
1. Proceed only with fetching the `Shoot`, `ClusterRoleBinding`, and `OpenIDConnect` resources.

What does the "only" mean here? Are there other resources that it doesn't fetch? Are there other steps it doesn't proceed with?

Copy link
Member

Choose a reason for hiding this comment

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

There are many more resources on the cluster but the backup app works only with those mentioned as they're only managed by KIM

1. save output files in the `/tmp/<generated name>` directory. The output directory contains the following:
Disper marked this conversation as resolved.
Show resolved Hide resolved
- `backup-and-switch-results.json` - the output file with the backup results
- `backup` - the directory with the backup files

### Backup and switch Runtime to be controlled by KIM
Disper marked this conversation as resolved.
Show resolved Hide resolved

Disper marked this conversation as resolved.
Show resolved Hide resolved
```bash
./bin/runtime-backup-and-switch \
-gardener-kubeconfig-path=/Users/myuser/gardener-kubeconfig.yml \
-gardener-project-name=kyma-dev \
-kcp-kubeconfig-path=/Users/myuser/kcp-kubeconfig.yml \
-output-path=/tmp/ \
-dry-run=false \
-input-file-path=input/runtimeIds.txt \
-set-controlled-by-kim=true \
-input-type=txt
```

The above **execution example** will:
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. take the input from the `input/runtimeIds.txt` file (each raw contains single RuntimeID)
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. proceed with fetching Shoot, Cluster Role Bindings and OpenIDConnect resource
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. save output files in the `/tmp/<generated name>` directory. The output directory contains the following:
Disper marked this conversation as resolved.
Show resolved Hide resolved
- `backup-and-switch-results.json` - the output file with the backup results
- `backup` - the directory with the backup files
1. label Cluster Role Bindings that were created by the Provisioner
Disper marked this conversation as resolved.
Show resolved Hide resolved
1. switch Runtime to be controlled by KIM
Disper marked this conversation as resolved.
Show resolved Hide resolved

### Output example

```
2025/01/10 09:27:49 INFO Starting runtime backup and switch
2025/01/10 09:27:49 gardener-kubeconfig-path: /Users/myuser/Downloads/kubeconfig-garden-kyma-stage.yaml
2025/01/10 09:27:49 kcp-kubeconfig-path: /Users/myuser/dev/config/sap
2025/01/10 09:27:49 gardener-project-name: kyma-stage
2025/01/10 09:27:49 output-path: /Users/myuser/backup/results
2025/01/10 09:27:49 dry-run: false
2025/01/10 09:27:49 input-type: txt
2025/01/10 09:27:49 input-file-path: /Users/myuser/dev/runtime-ids.txt
2025/01/10 09:27:49 set-controlled-by-kim: true
2025/01/10 09:27:49
2025/01/10 09:27:49
2025/01/10 09:27:49 INFO Reading runtimeIds from input file
2025/01/10 09:27:54 INFO Runtime backup created successfully runtimeID=a774bae2-ed8b-464e-85cc-ab8acd4461d5
2025/01/10 09:27:54 ERROR Failed to fetch shoot: shoot was deleted or the runtimeID is incorrect runtimeID=exxe4b14-7bc2-4947-931c-f8673793b02f
2025/01/10 09:27:54 INFO Backup completed. Successfully stored backups: 1, Failed backups: 1
2025/01/10 09:27:54 INFO Backup results saved in: backup/results/backup-2025-01-10T09:27:49+01:00/backup-and-switch-results.json
```

The backup results are saved in the `backup/results/backup-2025-01-10T09:27:49+01:00/backup-and-switch-results.json` file.

The `backup-and-switch-results.json` file contains the following content:
```json
[
{
"runtimeId": "a774bae2-ed8b-464e-85cc-ab8acd4461d5",
"shootName": "c-35a9898",
"status": "Success",
"backupDirPath": "backup/results/backup-2025-01-10T09:27:49+01:00/backup/a774bae2-ed8b-464e-85cc-ab8acd4461d5",
"deprecatedCRBs": [
"admin-cw4mz"
],
"setControlledByKIM": true
},
{
"runtimeId": "exxe4b14-7bc2-4947-931c-f8673793b02f",
"shootName": "",
"status": "Error",
"errorMessage": "Failed to fetch shoot: shoot was deleted or the runtimeID is incorrect",
"setControlledByKIM": false
}
]

```
In the above example the runtime with the `exxe4b14-7bc2-4947-931c-f8673793b02f` identifier was not found. In such a case verify whether:
Disper marked this conversation as resolved.
Show resolved Hide resolved
- identifier is correct
Disper marked this conversation as resolved.
Show resolved Hide resolved
- the corresponding shoot exists, and has `kcp.provisioner.kyma-project.io/runtime-id` label set
Disper marked this conversation as resolved.
Show resolved Hide resolved

The runtime with the `a774bae2-ed8b-464e-85cc-ab8acd4461d5` was successfully processed and the backup was stored in the `backup/results/backup-2025-01-10T09:27:49+01:00/backup/a774bae2-ed8b-464e-85cc-ab8acd4461d5` folder. The `admin-cw4mz` Cluster Role Binding was marked as deprecated, and will be cleaned up at some point.
Disper marked this conversation as resolved.
Show resolved Hide resolved

The `backup/results/backup-2025-01-10T09:27:49+01:00/backup/a774bae2-ed8b-464e-85cc-ab8acd4461d5` directory contains the following:
- `c-35a9898-original.yaml` file
- `c-35a9898-to-restore.yaml` file
- `crb` folder
- `oidc` folder

The `c-35a9898-original.yaml` file contains the shoot fetched from the Gardener. The `c-35a9898-to-restore.yaml` file contains the shoot that will be used by restore operation for patching.
Disper marked this conversation as resolved.
Show resolved Hide resolved
The `crb` directory contains the yaml files with Cluster Role Bindings that refer to `cluster-admin` role. The `oidc` folder contains yaml files with OpenIDConnect resources.
Disper marked this conversation as resolved.
Show resolved Hide resolved

## Configurable Parameters

This table lists the configurable parameters, their descriptions, and default values:
Disper marked this conversation as resolved.
Show resolved Hide resolved

| Parameter | Description | Default value |
|------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
| **kcp-kubeconfig-path** | Path to the Kubeconfig file of KCP cluster. | `/path/to/kcp/kubeconfig` |
Disper marked this conversation as resolved.
Show resolved Hide resolved
| **gardener-kubeconfig-path** | Path to the Kubeconfig file of Gardener cluster. | `/path/to/gardener/kubeconfig` |
Disper marked this conversation as resolved.
Show resolved Hide resolved
| **gardener-project-name** | Name of the Gardener project. | `gardener-project-name` |
| **output-path** | Path where generated report, and yamls will be saved. Directory has to exist. | `/tmp/` |
Disper marked this conversation as resolved.
Show resolved Hide resolved
| **dry-run** | Dry-run flag. Has to be set to **false**, otherwise migrator will not apply the CRs on the KCP cluster. | `true` |
Disper marked this conversation as resolved.
Show resolved Hide resolved
| **input-type** | Type of input to be used. Possible values: **txt** (will expect text file with one runtime identifier per line, [see the example](input/runtimeids_sample.txt)), and **json** (will expect `json` array with runtime identifiers, [see the example](input/runtimeids_sample.json)). | `json` |
Disper marked this conversation as resolved.
Show resolved Hide resolved
| **input-file-path** | Path to the file containing Runtimes to be migrated. | `/path/to/input/file` |
Disper marked this conversation as resolved.
Show resolved Hide resolved
| **set-controlled-by-kim** | Flag determining whether Runtime CR should be modified to be controlled by KIM | `false` |
Disper marked this conversation as resolved.
Show resolved Hide resolved

13 changes: 6 additions & 7 deletions hack/runtime-migrator/README-rm.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ The `runtime-migrator` application
1. connects to a Gardener project
Copy link
Contributor

Choose a reason for hiding this comment

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

Intro sentences to lists should be complete sentences and not embedded. Because of that, I'd suggest changing the phrasing like we did in the other two README document.
However, this is probably not scope of review you asked for :D , so I'm not going to add it to my suggestions. Feel free to align this doc with the other READMES if you like consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Applied in 759c9ac

2. retrieves all existing shoot specifications
3. migrates the shoot specs to the new Runtime custom resource (Runtime CRs created with this migrator have the `operator.kyma-project.io/created-by-migrator=true` label)
4. marks Cluster Role Bindings that were created by the Provisioner with `kyma-project.io/deprecation` label
5. saves the new Runtime custom resources to files
6. checks if the new Runtime custom resource will not cause update on the Gardener
7. saves the results of the comparison between the original shoot and the shoot KIM produces based on the new Runtime CR
8. applies the new Runtime CRs to the designated KCP cluster
9. saves the migration results in the output json file
4. saves the new Runtime custom resources to files
Disper marked this conversation as resolved.
Show resolved Hide resolved
5. checks if the new Runtime custom resource will not cause update on the Gardener
Disper marked this conversation as resolved.
Show resolved Hide resolved
6. saves the results of the comparison between the original shoot and the shoot KIM produces based on the new Runtime CR
7. applies the new Runtime CRs to the designated KCP cluster
8. saves the migration results in the output json file

## Build

Expand Down Expand Up @@ -130,7 +129,7 @@ The following problems were detected in the above example:
- The runtime with the `99a38a99-e8d7-4b98-a6f2-5a54ed389c4d` identifier may cause an unwanted update in the Gardener. The comparison results are saved in the `/tmp/migration-2024-11-22T17:05:33+01:00/comparison-results/99a38a99-e8d7-4b98-a6f2-5a54ed389c4d` directory.


The `/tmp/migration-2024-11-21T14:53:24+01:00/comparison-results/99a38a99-e8d7-4b98-a6f2-5a54ed389c4d"` directory contains the following files:
The `/tmp/migration-2024-11-21T14:53:24+01:00/comparison-results/99a38a99-e8d7-4b98-a6f2-5a54ed389c4d` directory contains the following files:
- `c-71da0f2.diff`
- `converted-shoot.yaml`
- `original-shoot.yaml`
Expand Down
Loading
Loading