generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Open
akgalwas
wants to merge
5
commits into
kyma-project:main
Choose a base branch
from
akgalwas:backup-restore-5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+277
−7
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
562e67a
Started README for backup tool
akgalwas 35d78b3
Fixes in backup plus README
akgalwas ac3ee3c
Merge branch 'main' into backup-restore-5
akgalwas 6281980
Missing information added to backup README
akgalwas a7ba228
Add the first version for restore readme
akgalwas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 |
---|---|---|
@@ -1 +1,132 @@ | ||
# Runtime Backuper | ||
# Runtime Backuper | ||
|
||
The `runtime-backup-and-switch` application | ||
1. connects to a Gardener project | ||
2. retrieves all existing shoot specifications | ||
3. for each runtime on input list: | ||
a) gets shoot, Cluster Role Bindings and OpenIDConnect resources | ||
b) saves the backup on a disk | ||
c) marks Cluster Role Bindings that were created by the Provisioner with `kyma-project.io/deprecation` label | ||
d) switches the runtime to be controlled by KIM by setting `kyma-project.io/controlled-by-provisioner` label with `false` value | ||
|
||
## Build | ||
|
||
In order to build the app, run the following command: | ||
|
||
```bash | ||
go build -o ./bin/runtime-backup-and-switch ./cmd/backup | ||
``` | ||
|
||
## Usage | ||
|
||
### Dry run | ||
```bash | ||
cat ./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: | ||
1. take the input from the `input/runtimeIds.txt` file (each raw contains single `RuntimeID`) | ||
1. proceed only with fetching `Shoot`, `Cluster Role Bindings` and `OpenIDConnect` resources | ||
1. save output files in the `/tmp/<generated name>` directory. The output directory contains the following: | ||
- `backup-results.json` - the output file with the backup results | ||
|
||
### Backup and switch Runtime to be controlled by KIM | ||
|
||
```bash | ||
cat ./bin/runtime-backup-and-switch \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it start with |
||
-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: | ||
1. take the input from the `input/runtimeIds.txt` file (each raw contains single `RuntimeID`) | ||
1. proceed with fetching `Shoot`, `Cluster Role Bindings` and `OpenIDConnect` resource | ||
1. save output files in the `/tmp/<generated name>` directory. The output directory contains the following: | ||
- `backup-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 | ||
1. switch Runtime to be controlled by KIM | ||
|
||
### Output example | ||
|
||
``` | ||
2025/01/10 09:27:49 INFO Starting runtime-backuper | ||
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: 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-oidc.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-results.json | ||
``` | ||
|
||
The backup results are saved in the `backup/results/backup-2025-01-10T09:27:49+01:00/backup-results.json` file. | ||
|
||
The `backup-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 | ||
} | ||
] | ||
|
||
``` | ||
The above example The runtime with the `exxe4b14-7bc2-4947-931c-f8673793b02f` identifier was not found ; the identifier may be incorrect, or the corresponding shoot was deleted for some reason. | ||
|
||
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-71da0f2.diff` file contains the differences between the original shoot and the shoot that will be created based on the new Runtime CR. The `converted-shoot.yaml` file contains the shoot that will be created based on the new Runtime CR. The `original-shoot.yaml` file contains the shoot fetched from the Gardener. | ||
|
||
## Configurable Parameters | ||
|
||
This table lists the configurable parameters, their descriptions, and default values: | ||
|
||
| Parameter | Description | Default value | | ||
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------| | ||
| **kcp-kubeconfig-path** | Path to the Kubeconfig file of KCP cluster. | `/path/to/kcp/kubeconfig` | | ||
| **gardener-kubeconfig-path** | Path to the Kubeconfig file of Gardener cluster. | `/path/to/gardener/kubeconfig` | | ||
| **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/` | | ||
| **dry-run** | Dry-run flag. Has to be set to **false**, otherwise migrator will not apply the CRs on the KCP cluster. | `true` | | ||
| **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` | | ||
| **input-file-path** | Path to the file containing Runtimes to be migrated. | `/path/to/input/file` | | ||
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it start with
cat
command?