I have a requirement where I need to mount 20+ azure blob containers on AKS. Manually if I do it can be achieved by me writing 40+ files for pv and pvc. I have created a DevOps pipeline where I will have all the pv and pvc details in multiple variable files and want to pass them to yaml files which create the pv and pvc.
variables:
volume_name: container1-pv
pvc_name: container1-pvc
config_map_name: container1-cm
deployment: log_container1
volume_handle: container1handle
I will create multiple sets of these variables to mount them.
now I want to pass these variable to the pv yaml file.
kind: PersistentVolume
apiVersion: v1
metadata:
name: container1-pv # this is where I want to substitute the variable
spec:
capacity:
storage: 100Gi
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Retain # If set as "Delete" container would be removed after pvc deletion
mountOptions:
- -o allow_other
- --file-cache-timeout-in-seconds=30
csi:
driver: blob.csi.azure.com
readOnly: false
# make sure this volumeid is unique in the cluster
# `#` is not allowed in self defined volumeHandle
volumeHandle: container1-hande # one more place to substitute
volumeAttributes:
containerName: container1 # one more place to substitute
nodeStageSecretRef:
name: azure-secret
namespace: logs
The command I am giving in ADO to create the pv.
kubectl create -f Pv/logs-pv.yml -n diag-logs
Please advise how to achieve this.
2
Answers
I added a sed command to replace as I was not able to get values.yaml to reference.
You can use the Helm template option to loop through the single file which stores your data and you can create the YAML file.
Helm template
values.yaml