Skip to content

Commit

Permalink
Add support to label a storage class. Simply demo logic conditions (#…
Browse files Browse the repository at this point in the history
…8794)

Co-authored-by: Wolfgang Kulhanek <WolfgangKulhanek@gmail.com>
  • Loading branch information
wkulhanek and Wolfgang Kulhanek authored Nov 12, 2024
1 parent bf3a4d6 commit c3a5bda
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ ocp4_workload_kasten_k10_authentication_type: openshift
# - Set up authorization for normal users to use K10
ocp4_workload_kasten_k10_setup_demo: false

# Annotate storage classes to support block mode
# k10.kasten.io/sc-supports-block-mode-exports=true
# Set to empty array to not annotate any
ocp4_workload_kasten_k10_storageclasses:
- ocs-external-storagecluster-ceph-rbd

# Annotate volumesnapshotclasses as backup targets
# k10.kasten.io/is-snapshot-class=true
# Set to empty array to not annotate any
ocp4_workload_kasten_k10_volumesnapshotclasses:
- ocs-external-storagecluster-rbdplugin-snapclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,57 +57,67 @@
# Jinja templates handle single/multi-user deployment
- name: Set up Demo environment
when: ocp4_workload_kasten_k10_setup_demo | bool
kubernetes.core.k8s:
state: present
definition: "{{ lookup('template', resource | from_yaml) }}"
loop:
- namespace.yaml.j2
- objectbucketclaim.yaml.j2
- clusterrolebinding.yaml.j2
- rolebinding.yaml.j2
- rolebinding-namespace.yaml.j2
loop_control:
loop_var: resource
block:
- name: Set up ObjectBucketClaims and permissions
kubernetes.core.k8s:
state: present
definition: "{{ lookup('template', resource | from_yaml) }}"
loop:
- namespace.yaml.j2
- objectbucketclaim.yaml.j2
- clusterrolebinding.yaml.j2
- rolebinding.yaml.j2
- rolebinding-namespace.yaml.j2
loop_control:
loop_var: resource

- name: Annotate VolumeSnapshotClasses as backup targets
when:
- ocp4_workload_kasten_k10_setup_demo | bool
- ocp4_workload_kasten_k10_volumesnapshotclasses | default([]) | length > 0
kubernetes.core.k8s:
state: patched
api_version: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
name: "{{ volumesnapshotclass }}"
definition:
annotations:
k10.kasten.io/is-snapshot-class: "true"
loop: "{{ ocp4_workload_kasten_k10_volumesnapshotclasses }}"
loop_control:
loop_var: volumesnapshotclass
- name: Annotate VolumeSnapshotClasses as backup targets
when: ocp4_workload_kasten_k10_volumesnapshotclasses | default([]) | length > 0
kubernetes.core.k8s:
state: patched
api_version: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
name: "{{ volumesnapshotclass }}"
definition:
annotations:
k10.kasten.io/is-snapshot-class: "true"
loop: "{{ ocp4_workload_kasten_k10_volumesnapshotclasses }}"
loop_control:
loop_var: volumesnapshotclass

- name: Save AgnosticD user information for single user
when:
- ocp4_workload_kasten_k10_setup_demo | bool
- not ocp4_workload_kasten_k10_multi_user | bool
agnosticd_user_info:
data:
kasten_backup_bucket_name: "{{ ocp4_workload_kasten_k10_objectbucket_name }}"
kasten_backup_bucket_namespace: "{{ ocp4_workload_kasten_k10_objectbucket_namespace }}"
kasten_backup_bucket_host: s3.openshift-storage.svc
kasten_backup_bucket_port: 443
- name: Annotate StorageClasses as block storage
when: ocp4_workload_kasten_k10_storageclasses | default([]) | length > 0
kubernetes.core.k8s:
state: patched
api_version: storage.k8s.io/v1
kind: StorageClass
name: "{{ storageclass }}"
definition:
annotations:
k10.kasten.io/sc-supports-block-mode-exports=true
loop: "{{ ocp4_workload_kasten_k10_storageclasses }}"
loop_control:
loop_var: storageclass

- name: Save AgnosticD user information for multi user
when:
- ocp4_workload_kasten_k10_setup_demo | bool
- ocp4_workload_kasten_k10_multi_user | bool
agnosticd_user_info:
user: "{{ ocp4_workload_kasten_k10_objectbucket_user_base }}{{ user_number }}"
data:
kasten_dashboard: "https://{{ r_kasten_route.resources[0].spec.host }}/k10/"
kasten_backup_bucket_name: "{{ ocp4_workload_kasten_k10_objectbucket_name }}"
kasten_backup_bucket_namespace: "{{ ocp4_workload_kasten_k10_objectbucket_namespace_base }}{{ user_number }}"
kasten_backup_bucket_host: s3.openshift-storage.svc
kasten_backup_bucket_port: 443
loop: "{{ range(1, ocp4_workload_kasten_k10_num_users | int + 1) | list }}"
loop_control:
loop_var: user_number
- name: Save AgnosticD user information for single user
when: not ocp4_workload_kasten_k10_multi_user | bool
agnosticd_user_info:
data:
kasten_backup_bucket_name: "{{ ocp4_workload_kasten_k10_objectbucket_name }}"
kasten_backup_bucket_namespace: "{{ ocp4_workload_kasten_k10_objectbucket_namespace }}"
kasten_backup_bucket_host: s3.openshift-storage.svc
kasten_backup_bucket_port: 443

- name: Save AgnosticD user information for multi user
when: ocp4_workload_kasten_k10_multi_user | bool
agnosticd_user_info:
user: "{{ ocp4_workload_kasten_k10_objectbucket_user_base }}{{ user_number }}"
data:
kasten_dashboard: "https://{{ r_kasten_route.resources[0].spec.host }}/k10/"
kasten_backup_bucket_name: "{{ ocp4_workload_kasten_k10_objectbucket_name }}"
kasten_backup_bucket_namespace: "{{ ocp4_workload_kasten_k10_objectbucket_namespace_base }}{{ user_number }}"
kasten_backup_bucket_host: s3.openshift-storage.svc
kasten_backup_bucket_port: 443
loop: "{{ range(1, ocp4_workload_kasten_k10_num_users | int + 1) | list }}"
loop_control:
loop_var: user_number

0 comments on commit c3a5bda

Please sign in to comment.