i have created a storage class in my aks cluster and i have mounted it with my 2 pvc of sonarqube "data and extention" volumes , and every thing works. i have created the storage class in a diffrent resource groupe so when i destroy my cluster the storage class will remain and not deleted.
Now what i want is when creating the cluster again i want to mount the volumes "data and extentions" with the existing storage class but it keeps getting errors and i didnt found any good documentation of how to do it.
any ideas ?
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sonarqube-data
namespace: inf-core
spec:
accessModes:
- ReadWriteMany
storageClassName: sonar-azurefile
resources:
requests:
storage: 5Gi
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: sonarqube-extensions namespace: inf-core spec: accessModes: - ReadWriteMany storageClassName: sonar-azurefile resources: requests: storage: 5Gi
apiVersion: apps/v1
kind: Deployment
metadata:
name: sonarqube-deployment
namespace: inf-core
spec:
replicas: 1
selector:
matchLabels:
app: sonarqube
tier: web
template:
metadata:
labels:
app: sonarqube
tier: web
spec:
initContainers:
- name: init-sonarqube-permissions
image: busybox
command: ['sh', '-c', 'chown -R 999:999 /opt/sonarqube']
volumeMounts:
- name: sonarqube-data
mountPath: /opt/sonarqube/data
- name: sonarqube-extensions
mountPath: /opt/sonarqube/lib/extensions
- name: init-sysctl
image: busybox
command: ['sysctl', '-w', 'vm.max_map_count=262144']
securityContext:
privileged: true
containers:
- name: sonarqube
image: sonarqube:latest
ports:
- containerPort: 9000
env:
- name: SONAR_JDBC_USERNAME
valueFrom:
secretKeyRef:
name: sonarqube-secret
key: SONAR_JDBC_USERNAME
- name: SONAR_JDBC_PASSWORD
valueFrom:
secretKeyRef:
name: sonarqube-secret
key: SONAR_JDBC_PASSWORD
- name: SONAR_JDBC_URL
value: jdbc:postgresql://postgres-service:5432/sonarqube
volumeMounts:
- name: sonarqube-data
mountPath: /opt/sonarqube/data
- name: sonarqube-extensions
mountPath: /opt/sonarqube/lib/extensions
volumes:
- name: sonarqube-data
persistentVolumeClaim:
claimName: sonarqube-data
- name: sonarqube-extensions
persistentVolumeClaim:
claimName: sonarqube-extensions
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: sonar-azurefile
provisioner: file.csi.azure.com
allowVolumeExpansion: true
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
mountOptions:
- dir_mode=0777
- file_mode=0777
- uid=1000
- gid=1000
- mfsymlinks
- cache=strict
- actimeo=30
parameters:
skuName: Standard_LRS
resourceGroup: AKS-STORAGECLASS