Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ To install OADP operator and the essential Velero components follow the steps gi
```
oc project oadp-operator
```
- Create secret for the cloud provider credentials to be used. Also, the credentials file present at `CREDENTIALS_FILE_PATH` shoud be in proper format, for instance if the provider is AWS it should follow this AWS credentials [template](https://github.com/konveyor/velero-examples/blob/master/velero-install/aws-credentials)
- Create secret for the cloud provider credentials to be used. Also, the credentials file present at `CREDENTIALS_FILE_PATH` shoud be in proper format, for instance if the provider is AWS it should follow this AWS credentials [template](https://github.com/konveyor/velero-examples/blob/master/velero-install/aws-credentials). Also, not that if you have different cloud providers for `BackupStorageLocation` and `VolumeSnapshotLocation`, make sure you create secrets for each of these cloud providers.
```
oc create secret generic <SECRET_NAME> --namespace oadp-operator --from-file cloud=<CREDENTIALS_FILE_PATH>
```
Expand Down
4 changes: 3 additions & 1 deletion deploy/crds/konveyor.openshift.io_v1alpha1_velero_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ spec:
config:
region: us-west-2
profile: "default"
credentials_secret_ref:
name: cloud-credentials
namespace: oadp-operator
enable_restic: true
velero_feature_flags: EnableCSI
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ metadata:
"profile": "default",
"region": "us-west-1"
},
"credentials_secret_ref": {
"name": "cloud-credentials",
"namespace": "oadp-operator"
},
"name": "default",
"provider": "aws"
}
Expand Down
5 changes: 4 additions & 1 deletion docs/bsl_and_vsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ spec:
config:
region: us-west-2
profile: "default"
credentials_secret_ref:
name: cloud-credentials
namespace: oadp-operator
```
<b>Note:</b>
- Be sure to use the same `secret` name you used while creating the cloud credentials secret in step 3 of Operator installation section.
- Be sure to use the same `secret` name you used while creating the cloud credentials secret in step 3 of Operator installation section.
- Another thing to consider are the CR file specs, they should be tailored in accordance to your own cloud provider accounts, for instance `bucket` spec value should be according to your own bucket name and so on.
- Do not configure more than one `backupStorageLocations` per cloud provider, the velero installation will fail.
- bsl/vsl parameters in the OADP Velero CR must be specified using `snake_case` rather than `camelCase`.
Expand Down
3 changes: 0 additions & 3 deletions roles/velero/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ registry: "{{ lookup( 'env', 'REGISTRY') }}"
project: "{{ lookup( 'env', 'PROJECT') }}"
velero_namespace: "{{ lookup( 'env', 'WATCH_NAMESPACE') | default('oadp-operator') }}"
velero_state: "present"
velero_aws_bsl_configs: 0
velero_gcp_bsl_configs: 0
velero_azure_bsl_configs: 0
velero_aws_secret_name: cloud-credentials
velero_gcp_secret_name: gcp-cloud-credentials
velero_azure_secret_name: azure-cloud-credentials
Expand Down
8 changes: 4 additions & 4 deletions roles/velero/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- name: "Check if the AWS credentials secret exists or not"
fail:
msg: "AWS credentials secret does not exist, Please create the secret {{ velero_aws_secret_name }} in order to proceed further with Velero installation"
when: '"aws" in default_velero_plugins and secret_status.resources | length == 0 and not noobaa'
when: '"aws" in default_velero_plugins and secret_status is defined and secret_status.resources | length == 0 and not noobaa and (velero_aws_bsl or velero_aws_vsl)'

- name: "Discover GCP credentials secret"
k8s_info:
Expand All @@ -31,7 +31,7 @@
- name: "Check if the GCP credentials secret exists or not"
fail:
msg: "GCP credentials secret does not exist, Please create the secret {{ velero_gcp_secret_name }} in order to proceed further with velero installation"
when: '"gcp" in default_velero_plugins and gcp_secret_status.resources | length == 0 and not noobaa'
when: '"gcp" in default_velero_plugins and gcp_secret_status is defined and gcp_secret_status.resources | length == 0 and not noobaa and (velero_gcp_bsl or velero_gcp_vsl)'

- name: "Discover Azure credentials secret"
k8s_info:
Expand All @@ -45,9 +45,9 @@
- name: "Check if the Azure credentials secret exists or not"
fail:
msg: "Azure credentials secret does not exist, Please create the secret {{ velero_azure_secret_name }} in order to proceed further with velero installation"
when: '"azure" in default_velero_plugins and azure_secret_status.resources | length == 0 and not noobaa'
when: '"azure" in default_velero_plugins and azure_secret_status is defined and azure_secret_status.resources | length == 0 and not noobaa and (velero_azure_bsl or velero_azure_vsl)'

- when: '"aws" in default_velero_plugins and secret_status.resources | length > 0 and not noobaa'
- when: '"aws" in default_velero_plugins and secret_status is defined and secret_status.resources | length > 0 and not noobaa and velero_aws_bsl'
block:
- name: Discover AWS credentials
k8s_info:
Expand Down
42 changes: 42 additions & 0 deletions roles/velero/tasks/preflight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set_fact:
velero_aws_secret_name: "{{ item.credentials_secret_ref.name }}"
velero_aws_bsl_configs: "{{ velero_aws_bsl_configs | int + 1 }}"
velero_aws_bsl: true
aws_bsl_res: "{{ item }}"
loop: "{{ backup_storage_locations }}"
when: item.provider == 'aws'
Expand All @@ -26,6 +27,7 @@
velero_gcp_secret_name: "{{ item.credentials_secret_ref.name }}"
velero_gcp_bsl_configs: "{{ velero_gcp_bsl_configs | int + 1 }}"
gcp_bsl_res: "{{ item }}"
velero_gcp_bsl: true
loop: "{{ backup_storage_locations }}"
when: item.provider == 'gcp'

Expand All @@ -48,6 +50,7 @@
velero_azure_secret_name: "{{ item.credentials_secret_ref.name }}"
velero_azure_bsl_configs: "{{ velero_azure_bsl_configs | int + 1 }}"
azure_bsl_res: "{{ item }}"
velero_azure_bsl: true
loop: "{{ backup_storage_locations }}"
when: item.provider == 'azure'

Expand All @@ -64,3 +67,42 @@
- fail:
msg: "The provided caCert for azure is not in valid base64 format"
when: azure_bsl_res.object_storage.ca_cert is defined

- name: "Discover aws as provider in Volume Snapshot Locations and associate aws secret name"
set_fact:
velero_aws_secret_name: "{{ item.credentials_secret_ref.name }}"
velero_aws_vsl_configs: "{{ velero_aws_vsl_configs | int + 1 }}"
velero_aws_vsl: true
loop: "{{ volume_snapshot_locations }}"
when: item.provider == 'aws'

- name: "Validate that there is only one aws VSL config"
fail:
msg: "More than one VolumeSnapshotLocations are configured for aws"
when: velero_aws_vsl_configs | int > 1

- name: "Discover gcp as provider in Volume Snapshot Locations and associate gcp secret name"
set_fact:
velero_gcp_secret_name: "{{ item.credentials_secret_ref.name }}"
velero_gcp_vsl_configs: "{{ velero_gcp_vsl_configs | int + 1 }}"
velero_gcp_vsl: true
loop: "{{ volume_snapshot_locations }}"
when: item.provider == 'gcp'

- name: "Validate that there is only one gcp VSL config"
fail:
msg: "More than one VolumeSnapshotLocations are configured for gcp"
when: velero_gcp_vsl_configs | int > 1

- name: "Discover azure as provider in Volume Snapshot Locations and associate azure secret name"
set_fact:
velero_azure_secret_name: "{{ item.credentials_secret_ref.name }}"
velero_azure_vsl_configs: "{{ velero_azure_vsl_configs | int + 1 }}"
velero_azure_vsl: true
loop: "{{ volume_snapshot_locations }}"
when: item.provider == 'azure'

- name: "Validate that there is only one azure VSL config"
fail:
msg: "More than one VolumeSnapshotLocations are configured for azure"
when: velero_azure_vsl_configs | int > 1
28 changes: 18 additions & 10 deletions roles/velero/templates/restic.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ spec:
runAsUser: 0
supplementalGroups: {{ restic_supplemental_groups }}
volumes:
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: {{ velero_aws_secret_name }}
secret:
secretName: {{ velero_aws_secret_name }}
{% endif %}
{% if 'gcp' in default_velero_plugins %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: {{ velero_gcp_secret_name }}
secret:
secretName: {{ velero_gcp_secret_name }}
{% endif %}
{% if 'azure' in default_velero_plugins %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: {{ velero_azure_secret_name }}
secret:
secretName: {{ velero_azure_secret_name }}
Expand Down Expand Up @@ -100,15 +100,15 @@ spec:
- restic
- server
volumeMounts:
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: {{ velero_aws_secret_name }}
mountPath: /credentials
{% endif %}
{% if 'gcp' in default_velero_plugins %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: {{ velero_gcp_secret_name }}
mountPath: /credentials-gcp
{% endif %}
{% if 'azure' in default_velero_plugins %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: {{ velero_azure_secret_name }}
mountPath: /credentials-azure
{% endif %}
Expand Down Expand Up @@ -144,15 +144,15 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
{% endif %}
{% if 'gcp' in default_velero_plugins %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /credentials-gcp/cloud
{% endif %}
{% if 'azure' in default_velero_plugins %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: AZURE_CREDENTIALS_FILE
value: /credentials-azure/cloud
{% endif %}
Expand All @@ -174,8 +174,16 @@ spec:
volumeMounts:
- name: certs
mountPath: /certs
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: {{ velero_aws_secret_name }}
mountPath: /credentials
{% endif %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: {{ velero_gcp_secret_name }}
mountPath: /credentials-gcp
{% endif %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: {{ velero_azure_secret_name }}
mountPath: /credentials-azure
{% endif %}

28 changes: 18 additions & 10 deletions roles/velero/templates/velero.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ spec:
- debug
{% endif %}
volumeMounts:
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: {{ velero_aws_secret_name }}
mountPath: /credentials
{% endif %}
{% if 'gcp' in default_velero_plugins %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: {{ velero_gcp_secret_name }}
mountPath: /credentials-gcp
{% endif %}
{% if 'azure' in default_velero_plugins %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: {{ velero_azure_secret_name }}
mountPath: /credentials-azure
{% endif %}
Expand All @@ -120,15 +120,15 @@ spec:
env:
- name: LD_LIBRARY_PATH
value: /plugins
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: AWS_SHARED_CREDENTIALS_FILE
value: /credentials/cloud
{% endif %}
{% if 'gcp' in default_velero_plugins %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /credentials-gcp/cloud
{% endif %}
{% if 'azure' in default_velero_plugins %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: AZURE_CREDENTIALS_FILE
value: /credentials-azure/cloud
{% endif %}
Expand All @@ -149,17 +149,17 @@ spec:
value: {{ no_proxy }}
{% endif %}
volumes:
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- name: {{ velero_aws_secret_name }}
secret:
secretName: {{ velero_aws_secret_name }}
{% endif %}
{% if 'gcp' in default_velero_plugins %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: {{ velero_gcp_secret_name }}
secret:
secretName: {{ velero_gcp_secret_name }}
{% endif %}
{% if 'azure' in default_velero_plugins %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: {{ velero_azure_secret_name }}
secret:
secretName: {{ velero_azure_secret_name }}
Expand Down Expand Up @@ -252,10 +252,18 @@ spec:
volumeMounts:
- mountPath: /certs
name: certs
{% if 'aws' in default_velero_plugins %}
{% if 'aws' in default_velero_plugins and (velero_aws_bsl or velero_aws_vsl) %}
- mountPath: /credentials
name: {{ velero_aws_secret_name }}
{% endif %}
{% if 'gcp' in default_velero_plugins and (velero_gcp_bsl or velero_gcp_vsl) %}
- name: {{ velero_gcp_secret_name }}
mountPath: /credentials-gcp
{% endif %}
{% if 'azure' in default_velero_plugins and (velero_azure_bsl or velero_azure_vsl) %}
- name: {{ velero_azure_secret_name }}
mountPath: /credentials-azure
{% endif %}
{% for plugin in custom_velero_plugins %}
- image: {{ plugin.image }}
imagePullPolicy: "{{ image_pull_policy }}"
Expand Down
6 changes: 6 additions & 0 deletions roles/velero/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
# vars file for velero
velero_aws_bsl_configs: 0
velero_gcp_bsl_configs: 0
velero_azure_bsl_configs: 0
velero_aws_vsl_configs: 0
velero_gcp_vsl_configs: 0
velero_azure_vsl_configs: 0