Skip to content

Commit

Permalink
Update document for v1.10 and replace the depracated package.
Browse files Browse the repository at this point in the history
1. Bump the plugin version in README.md
2. Add the un-documented configuration options in BSL and VSL.
3. Repalce io.ioutil with os.

Signed-off-by: Xun Jiang <blackpigletbruce@gmail.com>
  • Loading branch information
blackpiglet committed Apr 23, 2024
1 parent 778daa1 commit e90bf72
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ Below is a listing of plugin versions and respective Velero versions that are co

| Plugin Version | Velero Version |
|-----------------|----------------|
| v1.10.x | v1.14.x |
| v1.9.x | v1.13.x |
| v1.8.x | v1.12.x |
| v1.7.x | v1.11.x |
| v1.6.x | v1.10.x |
| v1.5.x | v1.9.x |
| v1.4.x | v1.8.x |
| v1.3.x | v1.7.x |

## Filing issues

Expand Down Expand Up @@ -222,7 +221,7 @@ Install Velero, including all prerequisites, into the cluster and start the depl
```bash
velero install \
--provider gcp \
--plugins velero/velero-plugin-for-gcp:v1.6.0 \
--plugins velero/velero-plugin-for-gcp:v1.10.0 \
--bucket $BUCKET \
--secret-file ./credentials-velero
```
Expand All @@ -234,7 +233,7 @@ You must add a service account annotation to the Kubernetes service account so t
```bash
velero install \
--provider gcp \
--plugins velero/velero-plugin-for-gcp:v1.6.0 \
--plugins velero/velero-plugin-for-gcp:v1.10.0 \
--bucket $BUCKET \
--no-secret \
--sa-annotations iam.gke.io/gcp-service-account=[$GSA_NAME]@[$PROJECT_ID].iam.gserviceaccount.com \
Expand All @@ -243,9 +242,9 @@ velero install \
Additionally, you can specify `--use-node-agent` to enable node agent support, and `--wait` to wait for the deployment to be ready.
(Optional) Specify [additional configurable parameters][7] for the `--backup-location-config` flag.
(Optional) Specify [additional configurable parameters](backupstoragelocation.md) for the `--backup-location-config` flag.
(Optional) Specify [additional configurable parameters][8] for the `--snapshot-location-config` flag.
(Optional) Specify [additional configurable parameters](volumesnapshotlocation.md) for the `--snapshot-location-config` flag.
(Optional) [Customize the Velero installation][9] further to meet your needs.
Expand Down Expand Up @@ -296,14 +295,21 @@ velero backup-location get
To use this new Backup Storage Location when performing a backup, use the flag `--storage-location <bsl-name>` when running `velero backup create`.
## Configure the GCP plugin
The Velero GCP plugin contains two plugins:
ObjectStore plugin: it's used to connect to the GCP Cloud Storage to manipulate the object files.
Please check the possible configuration options in the [BSL configuration document](backupstoragelocation.md).

VolumeSnapshotter plugin: it's used to manipulate the snapshots in GCP.
Please check the possible configuration options in the [VSL configuration document](volumesnapshotlocation.md).
[1]: #Create-an-GCS-bucket
[2]: #Set-permissions-for-Velero
[3]: #Install-and-start-Velero
[4]: https://velero.io/docs/install-overview/
[5]: https://cloud.google.com/sdk/docs/
[7]: backupstoragelocation.md
[8]: volumesnapshotlocation.md
[9]: https://velero.io/docs/customize-installation/
[10]: ./examples
[11]: https://velero.io/docs/faq/
Expand Down
5 changes: 5 additions & 0 deletions backupstoragelocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ spec:
#
# Optional (defaults to "false").
serviceAccount: my-service-account

# The preferred credentials to talk to the GCP cloud storage service.
#
# Optional.
credentialsFile: path/to/my/credential
```
11 changes: 8 additions & 3 deletions velero-plugin-for-gcp/object_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"encoding/base64"
"encoding/json"
"io"
"io/ioutil"
"os"
"time"

"cloud.google.com/go/storage"
Expand Down Expand Up @@ -96,7 +96,12 @@ func getSecretAccountTypeKey(secretByte []byte) (credAccountKeys, error) {
}

func (o *ObjectStore) Init(config map[string]string) error {
if err := veleroplugin.ValidateObjectStoreConfigKeys(config, kmsKeyNameConfigKey, serviceAccountConfig, credentialsFileConfigKey); err != nil {
if err := veleroplugin.ValidateObjectStoreConfigKeys(
config,
kmsKeyNameConfigKey,
serviceAccountConfig,
credentialsFileConfigKey,
); err != nil {
return err
}
// Find default token source to extract the GoogleAccessID
Expand All @@ -112,7 +117,7 @@ func (o *ObjectStore) Init(config map[string]string) error {

// Prioritize the credentials file path in config, if it exists
if credentialsFile, ok := config[credentialsFileConfigKey]; ok {
b, err := ioutil.ReadFile(credentialsFile)
b, err := os.ReadFile(credentialsFile)
if err != nil {
return errors.Wrapf(err, "error reading provided credentials file %v", credentialsFile)
}
Expand Down
14 changes: 10 additions & 4 deletions velero-plugin-for-gcp/volume_snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
"strings"

Expand Down Expand Up @@ -68,8 +68,14 @@ func newVolumeSnapshotter(logger logrus.FieldLogger) *VolumeSnapshotter {
}

func (b *VolumeSnapshotter) Init(config map[string]string) error {
if err := veleroplugin.ValidateVolumeSnapshotterConfigKeys(config,
snapshotLocationKey, snapshotTypeKey, projectKey, credentialsFileConfigKey, volumeProjectKey); err != nil {
if err := veleroplugin.ValidateVolumeSnapshotterConfigKeys(
config,
snapshotLocationKey,
snapshotTypeKey,
projectKey,
credentialsFileConfigKey,
volumeProjectKey,
); err != nil {
return err
}

Expand All @@ -83,7 +89,7 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error {

// If credential is provided for the VSL, use it instead of default credential.
if credentialsFile, ok := config[credentialsFileConfigKey]; ok {
b, err := ioutil.ReadFile(credentialsFile)
b, err := os.ReadFile(credentialsFile)
if err != nil {
return errors.Wrapf(err, "error reading provided credentials file %v", credentialsFile)
}
Expand Down
16 changes: 16 additions & 0 deletions volumesnapshotlocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,20 @@ spec:
#
# Optional (defaults to the project that the GCP IAM account is in).
project: my-alternate-project

# The preferred credentials to talk to the GCP snapshot service.
#
# Optional.
credentialsFile: path/to/my/credential

# The project to manipulate volumes.
# This is useful the backup and restore happens in different projects.
#
# Optional (default to be same the credential's project).
volumeProject: project-id

# The type of the created snapshot. Two types are supported: STANDARD and ARCHIVE.
#
# Optional (default to STANDARD).
snapshotType: snapshot-type
```

0 comments on commit e90bf72

Please sign in to comment.