From e9745c8a7a7ecd95ac4eae2ab622edca174d497d Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 19 Aug 2024 12:27:39 +0200 Subject: [PATCH 01/23] add a staging site for the DDF people to test on and give canary back to developers and operators --- infrastructure/environments/dplplat01/sites.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/infrastructure/environments/dplplat01/sites.yaml b/infrastructure/environments/dplplat01/sites.yaml index eccd2a09..208701d8 100644 --- a/infrastructure/environments/dplplat01/sites.yaml +++ b/infrastructure/environments/dplplat01/sites.yaml @@ -14,13 +14,21 @@ sites: # Testing and instructional sites canary: name: "Canary" - description: "A site to test new releases on" + description: "A site for developers and operators to test on" releaseImageRepository: ghcr.io/danskernesdigitalebibliotek releaseImageName: dpl-cms-source dpl-cms-release: "2024.36.0" plan: webmaster moduletest-dpl-cms-release: "2024.36.0" deploy_key: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIhuA0K7CNvRoe+Xx7RaXG4+a8KcSpzuWn+G4sUPzNWx" + staging: + name: "Staging" + description: "A site to test new releases on" + releaseImageRepository: ghcr.io/danskernesdigitalebibliotek + releaseImageName: dpl-cms-source + dpl-cms-release: "2024.33.0" + plan: webmaster + deploy_key: cms-school: name: "CMS-skole" description: "Et site til undervisning i CMSet" From 4680b1d27b64381d8bb601b15157de7e12fcf8b9 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 10:49:15 +0200 Subject: [PATCH 02/23] Intermediary SC for the new CSI pluging --- infrastructure/new-bulk.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 infrastructure/new-bulk.yaml diff --git a/infrastructure/new-bulk.yaml b/infrastructure/new-bulk.yaml new file mode 100644 index 00000000..5685e0b4 --- /dev/null +++ b/infrastructure/new-bulk.yaml @@ -0,0 +1,12 @@ +kind: StorageClass +apiVersion: storage.k8s.io/v1 +metadata: + name: new-bulk +provisioner: file.csi.azure.com +reclaimPolicy: Retain +volumeBindingMode: Immediate +allowVolumeExpansion: true +parameters: + resourcegroup: rg-env-dplplat01 + skuName: Standard_LRS + storageAccount: stdpldplplat01585708af From e6048559fdc52fade4efe76545ac45b73ca2e15c Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 10:49:49 +0200 Subject: [PATCH 03/23] new PV for using with CSI --- infrastructure/pv.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 infrastructure/pv.yaml diff --git a/infrastructure/pv.yaml b/infrastructure/pv.yaml new file mode 100644 index 00000000..cfd60ec2 --- /dev/null +++ b/infrastructure/pv.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + pv.kubernetes.io/provisioned-by: file.csi.azure.com + name: new-pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 +spec: + capacity: + storage: 5Gi + accessModes: + - ReadWriteMany + persistentVolumeReclaimPolicy: Retain + storageClassName: new-bulk + csi: + driver: file.csi.azure.com + readOnly: false + volumeHandle: /subscriptions/8ac8a259-5bb3-4799-bd1e-455145b12550/resourceGroups/rg-env-dplplat01/providers/Microsoft.Storage/storageAccounts/stdpldplplat01585708af/ # make sure volumeid is unique for every identical share in the cluster + volumeAttributes: + resourceGroup: rg-env-dplplat01 # optional, only set this when storage account is not in the same resource group as the cluster nodes + shareName: new-pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 + nodeStageSecretRef: + name: azure-storage-account-stdpldplplat01585708af-secret + namespace: canary-main + mountOptions: + - dir_mode=0777 + - file_mode=0777 + - uid=0 + - gid=0 + - mfsymlinks + - nosharesock + - nobrl # disable sending byte range lock requests to the server and for applications which have challenges with posix locks From 8e044b2bee245ea350eac9c7ed4a7bed84cbaecf Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 10:50:12 +0200 Subject: [PATCH 04/23] new PVC for using with CSI --- infrastructure/pvc.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 infrastructure/pvc.yaml diff --git a/infrastructure/pvc.yaml b/infrastructure/pvc.yaml new file mode 100644 index 00000000..22a35b41 --- /dev/null +++ b/infrastructure/pvc.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.syn.tools/backup: "true" + lagoon.sh/branch: main + lagoon.sh/version: 23.12.0 + finalizers: + - kubernetes.io/pvc-protection + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nginx-php-persistent + helm.sh/chart: nginx-php-persistent-0.1.0 + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: canary + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + name: new-nginx + namespace: "canary-main" +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: new-bulk + volumeMode: Filesystem + volumeName: "new-pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3" From 42f5a7839997dac96b61e1aea24a93c2888fcf88 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 10:51:13 +0200 Subject: [PATCH 05/23] script that creates new PV and PVC, using CSI, for a namespace and patches the nginx deployment to use it --- .../create-pv-and-pvc-for-namespace.sh | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 infrastructure/create-pv-and-pvc-for-namespace.sh diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh new file mode 100755 index 00000000..b867b615 --- /dev/null +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# This script creates new PersistentVolumeClaims and PersistentVolumes for a namespace +# + +set -euo pipefail + +echo "Adding new PVC and PV to $1" + +#Get the volume name of the PV +VOLUME_NAME=$(kubectl get pvc -n $1 nginx | grep pvc | awk '{print $3}') +# Change it's name slighty so we can recognize it from the old ones +NEW="new-" +NEW_VOLUME_NAME=${NEW}${VOLUME_NAME} +echo $NEW_VOLUME_NAME + +# Set the PVC's volumeName to the new volume name +volumeName=$NEW_VOLUME_NAME yq -i '.spec.volumeName = strenv(volumeName)' pvc.yaml +namespace=$1 yq -i '.metadata.namespace = strenv(namespace)' pvc.yaml + +# Set the PV's name and sharename to the new volume name +volumeName=$NEW_VOLUME_NAME yq -i ' + .metadata.name = strenv(volumeName) | + .spec.csi.volumeAttributes.shareName = strenv(volumeName) + ' pv.yaml + +# Apply the new PV and PVC to the cluster +kubectl apply -f pv.yaml +kubectl apply -f pvc.yaml + +# Switch the nginx deployments nginx volume to use the new PVC +kubectl patch deployments.apps -n $1 nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "new-nginx"}}]}}}}' + +echo "$1 is now using the intermediary SC via it's new PVC and PV. The Nginx has been patched and new pods spun up" + + + +echo ######## Done ######## From 2e37cabfcfdfff4366e4d0b6141eb12f1a93eb03 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 23:05:08 +0200 Subject: [PATCH 06/23] patch the deployment to use the new PVC --- infrastructure/create-pv-and-pvc-for-namespace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index b867b615..efc3e220 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -29,7 +29,7 @@ kubectl apply -f pv.yaml kubectl apply -f pvc.yaml # Switch the nginx deployments nginx volume to use the new PVC -kubectl patch deployments.apps -n $1 nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "new-nginx"}}]}}}}' +kubectl patch deployments.apps -n $1 nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "nginx"}}]}}}}' echo "$1 is now using the intermediary SC via it's new PVC and PV. The Nginx has been patched and new pods spun up" From 153813a5fe08e29ae8a4e758f4e2cd1cea688f70 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 23:05:36 +0200 Subject: [PATCH 07/23] check that the namespace exists before doing anything --- infrastructure/create-pv-and-pvc-for-namespace.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index efc3e220..0e27a65c 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -5,6 +5,11 @@ set -euo pipefail +source ./deleteOldPvAndPvc.sh + +# Test the entered namespace for good measure +kubectl get ns $1 + echo "Adding new PVC and PV to $1" #Get the volume name of the PV From 896a4fd1ef6c99d086ed13af7329ad9349327916 Mon Sep 17 00:00:00 2001 From: Philip Date: Thu, 22 Aug 2024 23:05:52 +0200 Subject: [PATCH 08/23] clean up the old pvc and pv --- .../create-pv-and-pvc-for-namespace.sh | 2 ++ infrastructure/deleteOldPvAndPvc.sh | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 infrastructure/deleteOldPvAndPvc.sh diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index 0e27a65c..e97cc764 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -38,6 +38,8 @@ kubectl patch deployments.apps -n $1 nginx -p '{"spec":{"template":{"spec": {"vo echo "$1 is now using the intermediary SC via it's new PVC and PV. The Nginx has been patched and new pods spun up" +echo "Proceeding to remove the now obsolete PV and PVC from the namespace $1" +deleteOldPvAndPvc $1 $NEW_VOLUME_NAME "new-nginx" echo ######## Done ######## diff --git a/infrastructure/deleteOldPvAndPvc.sh b/infrastructure/deleteOldPvAndPvc.sh new file mode 100644 index 00000000..3f816398 --- /dev/null +++ b/infrastructure/deleteOldPvAndPvc.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# This script creates new PersistentVolumeClaims and PersistentVolumes for a namespace +# + +set -euo pipefail + +function deleteOldPvAndPvc() { + local NAMESPACE=$1 + local VOLUME_NAME=$2 + local PVC_NAME=$3 + # Delete old PVC from namespace + kubectl delete pvc -n $NAMESPACE $PVC_NAME --wait=false + kubectl patch pvc -n $NAMESPACE $PVC_NAME -p '{"metadata":{"finalizers":null}}' + # Mark old PV as up for deletion + kubectl delete pv $VOLUME_NAME --grace-period=0 --wait=false + kubectl patch pv $VOLUME_NAME -p '{"metadata":{"finalizers":null}}' +} From 8e5965dded3c1643dd8b9413dd5d0047fae92ae3 Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 23 Aug 2024 09:34:32 +0200 Subject: [PATCH 09/23] make a backup before deletion --- infrastructure/create-pv-and-pvc-for-namespace.sh | 2 +- infrastructure/deleteOldPvAndPvc.sh | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index e97cc764..d30c96cd 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -40,6 +40,6 @@ echo "$1 is now using the intermediary SC via it's new PVC and PV. The Nginx has echo "Proceeding to remove the now obsolete PV and PVC from the namespace $1" -deleteOldPvAndPvc $1 $NEW_VOLUME_NAME "new-nginx" +backupAndDeleteOldPvAndPvc $1 $NEW_VOLUME_NAME "new-nginx" echo ######## Done ######## diff --git a/infrastructure/deleteOldPvAndPvc.sh b/infrastructure/deleteOldPvAndPvc.sh index 3f816398..eec25cc7 100644 --- a/infrastructure/deleteOldPvAndPvc.sh +++ b/infrastructure/deleteOldPvAndPvc.sh @@ -5,10 +5,14 @@ set -euo pipefail -function deleteOldPvAndPvc() { +function backupAndDeleteOldPvAndPvc() { local NAMESPACE=$1 local VOLUME_NAME=$2 local PVC_NAME=$3 + + # Backup the the old PVC and PV before deleting them + kubectl get pvc -n $NAMESPACE $PVC_NAME -o yaml > "./pvAndPvcBackup/${NAMESPACE}_${PVC_NAME}.yaml" + kubectl get pv $VOLUME_NAME -o yaml > "./pvAndPvcBackup/${NAMESPACE}_${VOLUME_NAME}" # Delete old PVC from namespace kubectl delete pvc -n $NAMESPACE $PVC_NAME --wait=false kubectl patch pvc -n $NAMESPACE $PVC_NAME -p '{"metadata":{"finalizers":null}}' From 18c10a9ab8437801cbfcbc4d676afc25c34e5c58 Mon Sep 17 00:00:00 2001 From: Philip Date: Fri, 23 Aug 2024 13:13:16 +0200 Subject: [PATCH 10/23] sharename was wrong --- .../create-pv-and-pvc-for-namespace.sh | 9 ++-- infrastructure/pv.yaml | 4 +- .../pvAndPvcBackup/canary-main_nginx.yaml | 46 +++++++++++++++++++ ...n_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f | 36 +++++++++++++++ ...n_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 | 36 +++++++++++++++ infrastructure/pvc.yaml | 2 +- 6 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 infrastructure/pvAndPvcBackup/canary-main_nginx.yaml create mode 100644 infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f create mode 100644 infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index d30c96cd..24c0e87f 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -23,10 +23,13 @@ echo $NEW_VOLUME_NAME volumeName=$NEW_VOLUME_NAME yq -i '.spec.volumeName = strenv(volumeName)' pvc.yaml namespace=$1 yq -i '.metadata.namespace = strenv(namespace)' pvc.yaml -# Set the PV's name and sharename to the new volume name +# Set the PV's name to the new volume name volumeName=$NEW_VOLUME_NAME yq -i ' .metadata.name = strenv(volumeName) | - .spec.csi.volumeAttributes.shareName = strenv(volumeName) + ' pv.yaml +# The sharename is the same as we are doing a logical deletion and not a real one +shareName=$VOLUME_NAME yq -i ' + .spec.csi.volumeAttributes.shareName = strenv(shareName) ' pv.yaml # Apply the new PV and PVC to the cluster @@ -40,6 +43,6 @@ echo "$1 is now using the intermediary SC via it's new PVC and PV. The Nginx has echo "Proceeding to remove the now obsolete PV and PVC from the namespace $1" -backupAndDeleteOldPvAndPvc $1 $NEW_VOLUME_NAME "new-nginx" +backupAndDeleteOldPvAndPvc $1 $VOLUME_NAME "nginx" echo ######## Done ######## diff --git a/infrastructure/pv.yaml b/infrastructure/pv.yaml index cfd60ec2..b4275b71 100644 --- a/infrastructure/pv.yaml +++ b/infrastructure/pv.yaml @@ -3,7 +3,7 @@ kind: PersistentVolume metadata: annotations: pv.kubernetes.io/provisioned-by: file.csi.azure.com - name: new-pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 + name: new-pvc-0ed5e577-08bf-4488-9974-ea0aea26938f spec: capacity: storage: 5Gi @@ -17,7 +17,7 @@ spec: volumeHandle: /subscriptions/8ac8a259-5bb3-4799-bd1e-455145b12550/resourceGroups/rg-env-dplplat01/providers/Microsoft.Storage/storageAccounts/stdpldplplat01585708af/ # make sure volumeid is unique for every identical share in the cluster volumeAttributes: resourceGroup: rg-env-dplplat01 # optional, only set this when storage account is not in the same resource group as the cluster nodes - shareName: new-pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 + shareName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f nodeStageSecretRef: name: azure-storage-account-stdpldplplat01585708af-secret namespace: canary-main diff --git a/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml b/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml new file mode 100644 index 00000000..9059693b --- /dev/null +++ b/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml @@ -0,0 +1,46 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.syn.tools/backup: "true" + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0"},"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"canary","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"canary-main"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk"}} + lagoon.sh/branch: main + lagoon.sh/version: 23.12.0 + pv.kubernetes.io/bind-completed: "yes" + pv.kubernetes.io/bound-by-controller: "yes" + volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com + volume.kubernetes.io/storage-provisioner: file.csi.azure.com + creationTimestamp: "2024-08-23T08:43:03Z" + finalizers: + - kubernetes.io/pvc-protection + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nginx-php-persistent + helm.sh/chart: nginx-php-persistent-0.1.0 + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: canary + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + name: nginx + namespace: canary-main + resourceVersion: "582249915" + uid: 0ed5e577-08bf-4488-9974-ea0aea26938f +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: bulk + volumeMode: Filesystem + volumeName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f +status: + accessModes: + - ReadWriteMany + capacity: + storage: 5Gi + phase: Bound diff --git a/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f b/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f new file mode 100644 index 00000000..22c55271 --- /dev/null +++ b/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + kubernetes.io/azure-file-resource-group: rg-env-dplplat01 + pv.kubernetes.io/migrated-to: file.csi.azure.com + pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file + volume.kubernetes.io/provisioner-deletion-secret-name: "" + volume.kubernetes.io/provisioner-deletion-secret-namespace: "" + creationTimestamp: "2024-08-23T08:43:21Z" + finalizers: + - kubernetes.io/pv-protection + name: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f + resourceVersion: "582249916" + uid: 0ab40124-9f5a-4710-ac0e-0e1c8b71c747 +spec: + accessModes: + - ReadWriteMany + azureFile: + secretName: azure-storage-account-stdpldplplat01585708af-secret + secretNamespace: canary-main + shareName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f + capacity: + storage: 5Gi + claimRef: + apiVersion: v1 + kind: PersistentVolumeClaim + name: nginx + namespace: canary-main + resourceVersion: "582249506" + uid: 0ed5e577-08bf-4488-9974-ea0aea26938f + persistentVolumeReclaimPolicy: Retain + storageClassName: bulk + volumeMode: Filesystem +status: + phase: Bound diff --git a/infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 b/infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 new file mode 100644 index 00000000..91f9aaf1 --- /dev/null +++ b/infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + kubernetes.io/azure-file-resource-group: rg-env-dplplat01 + pv.kubernetes.io/migrated-to: file.csi.azure.com + pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file + volume.kubernetes.io/provisioner-deletion-secret-name: "" + volume.kubernetes.io/provisioner-deletion-secret-namespace: "" + creationTimestamp: "2024-04-10T12:58:58Z" + finalizers: + - kubernetes.io/pv-protection + name: pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 + resourceVersion: "424529568" + uid: 2240938a-7cba-4778-bdbe-b80d03864300 +spec: + accessModes: + - ReadWriteMany + azureFile: + secretName: azure-storage-account-stdpldplplat01585708af-secret + secretNamespace: canary-main + shareName: pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 + capacity: + storage: 5Gi + claimRef: + apiVersion: v1 + kind: PersistentVolumeClaim + name: nginx + namespace: canary-main + resourceVersion: "424529512" + uid: 5fb0f9d8-a67c-44a6-a11b-a38112e679a3 + persistentVolumeReclaimPolicy: Retain + storageClassName: bulk + volumeMode: Filesystem +status: + phase: Bound diff --git a/infrastructure/pvc.yaml b/infrastructure/pvc.yaml index 22a35b41..c09ec765 100644 --- a/infrastructure/pvc.yaml +++ b/infrastructure/pvc.yaml @@ -28,4 +28,4 @@ spec: storage: 5Gi storageClassName: new-bulk volumeMode: Filesystem - volumeName: "new-pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3" + volumeName: "new-pvc-0ed5e577-08bf-4488-9974-ea0aea26938f" From 8f3928b04c858568f6472f3d332876677ca36b20 Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 26 Aug 2024 11:22:31 +0200 Subject: [PATCH 11/23] needed to be split as the names are not the same --- infrastructure/create-pv-and-pvc-for-namespace.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index 24c0e87f..bf086dfe 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -24,13 +24,9 @@ volumeName=$NEW_VOLUME_NAME yq -i '.spec.volumeName = strenv(volumeName)' pvc.ya namespace=$1 yq -i '.metadata.namespace = strenv(namespace)' pvc.yaml # Set the PV's name to the new volume name -volumeName=$NEW_VOLUME_NAME yq -i ' - .metadata.name = strenv(volumeName) | - ' pv.yaml +volumeName=$NEW_VOLUME_NAME yq -i '.metadata.name = strenv(volumeName)' pv.yaml # The sharename is the same as we are doing a logical deletion and not a real one -shareName=$VOLUME_NAME yq -i ' - .spec.csi.volumeAttributes.shareName = strenv(shareName) - ' pv.yaml +shareName=$VOLUME_NAME yq -i '.spec.csi.volumeAttributes.shareName = strenv(shareName)' pv.yaml # Apply the new PV and PVC to the cluster kubectl apply -f pv.yaml From a533fab19693cf3352690ca6df5896536f49c33f Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 26 Aug 2024 11:22:53 +0200 Subject: [PATCH 12/23] point to the new one - we're done testing for now --- infrastructure/create-pv-and-pvc-for-namespace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/create-pv-and-pvc-for-namespace.sh index bf086dfe..a9733f2c 100755 --- a/infrastructure/create-pv-and-pvc-for-namespace.sh +++ b/infrastructure/create-pv-and-pvc-for-namespace.sh @@ -33,7 +33,7 @@ kubectl apply -f pv.yaml kubectl apply -f pvc.yaml # Switch the nginx deployments nginx volume to use the new PVC -kubectl patch deployments.apps -n $1 nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "nginx"}}]}}}}' +kubectl patch deployments.apps -n $1 nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "new-nginx"}}]}}}}' echo "$1 is now using the intermediary SC via it's new PVC and PV. The Nginx has been patched and new pods spun up" From c74779b0e54173550ee39a9c235ad6d96c52379a Mon Sep 17 00:00:00 2001 From: Philip Date: Mon, 26 Aug 2024 11:23:45 +0200 Subject: [PATCH 13/23] backups from sites the script has been run on --- .../pvAndPvcBackup/canary-main_nginx.yaml | 14 ++---- ...n_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f | 36 --------------- .../pvAndPvcBackup/hvidovre-main_nginx.yaml | 46 +++++++++++++++++++ ...n_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d | 36 +++++++++++++++ .../pvAndPvcBackup/struer-main_nginx.yaml | 46 +++++++++++++++++++ ...n_pvc-8f18f576-3623-44f9-892f-7919bac75aba | 36 +++++++++++++++ 6 files changed, 169 insertions(+), 45 deletions(-) create mode 100644 infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml create mode 100644 infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d create mode 100644 infrastructure/pvAndPvcBackup/struer-main_nginx.yaml create mode 100644 infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba diff --git a/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml b/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml index 9059693b..b6b682e5 100644 --- a/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml +++ b/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml @@ -4,14 +4,14 @@ metadata: annotations: k8up.syn.tools/backup: "true" kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0"},"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"canary","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"canary-main"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk"}} + {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0","pv.kubernetes.io/bind-completed":"yes","pv.kubernetes.io/bound-by-controller":"yes","volume.beta.kubernetes.io/storage-provisioner":"file.csi.azure.com","volume.kubernetes.io/storage-provisioner":"file.csi.azure.com"},"creationTimestamp":"2024-08-23T08:43:03Z","finalizers":["kubernetes.io/pvc-protection"],"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"canary","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"canary-main","resourceVersion":"582249915","uid":"0ed5e577-08bf-4488-9974-ea0aea26938f"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk","volumeMode":"Filesystem","volumeName":"pvc-0ed5e577-08bf-4488-9974-ea0aea26938f"},"status":{"accessModes":["ReadWriteMany"],"capacity":{"storage":"5Gi"},"phase":"Bound"}} lagoon.sh/branch: main lagoon.sh/version: 23.12.0 pv.kubernetes.io/bind-completed: "yes" pv.kubernetes.io/bound-by-controller: "yes" volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com volume.kubernetes.io/storage-provisioner: file.csi.azure.com - creationTimestamp: "2024-08-23T08:43:03Z" + creationTimestamp: "2024-08-23T10:31:59Z" finalizers: - kubernetes.io/pvc-protection labels: @@ -27,8 +27,8 @@ metadata: lagoon.sh/service-type: nginx-php-persistent name: nginx namespace: canary-main - resourceVersion: "582249915" - uid: 0ed5e577-08bf-4488-9974-ea0aea26938f + resourceVersion: "582394955" + uid: 13eb6a7c-90f2-46a9-9cde-15b881d106ca spec: accessModes: - ReadWriteMany @@ -39,8 +39,4 @@ spec: volumeMode: Filesystem volumeName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f status: - accessModes: - - ReadWriteMany - capacity: - storage: 5Gi - phase: Bound + phase: Lost diff --git a/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f b/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f index 22c55271..e69de29b 100644 --- a/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f +++ b/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - annotations: - kubernetes.io/azure-file-resource-group: rg-env-dplplat01 - pv.kubernetes.io/migrated-to: file.csi.azure.com - pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file - volume.kubernetes.io/provisioner-deletion-secret-name: "" - volume.kubernetes.io/provisioner-deletion-secret-namespace: "" - creationTimestamp: "2024-08-23T08:43:21Z" - finalizers: - - kubernetes.io/pv-protection - name: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f - resourceVersion: "582249916" - uid: 0ab40124-9f5a-4710-ac0e-0e1c8b71c747 -spec: - accessModes: - - ReadWriteMany - azureFile: - secretName: azure-storage-account-stdpldplplat01585708af-secret - secretNamespace: canary-main - shareName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f - capacity: - storage: 5Gi - claimRef: - apiVersion: v1 - kind: PersistentVolumeClaim - name: nginx - namespace: canary-main - resourceVersion: "582249506" - uid: 0ed5e577-08bf-4488-9974-ea0aea26938f - persistentVolumeReclaimPolicy: Retain - storageClassName: bulk - volumeMode: Filesystem -status: - phase: Bound diff --git a/infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml b/infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml new file mode 100644 index 00000000..85631b54 --- /dev/null +++ b/infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml @@ -0,0 +1,46 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.syn.tools/backup: "true" + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0"},"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"hvidovre","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"hvidovre-main"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk"}} + lagoon.sh/branch: main + lagoon.sh/version: 23.12.0 + pv.kubernetes.io/bind-completed: "yes" + pv.kubernetes.io/bound-by-controller: "yes" + volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com + volume.kubernetes.io/storage-provisioner: file.csi.azure.com + creationTimestamp: "2024-04-30T17:40:45Z" + finalizers: + - kubernetes.io/pvc-protection + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nginx-php-persistent + helm.sh/chart: nginx-php-persistent-0.1.0 + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: hvidovre + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + name: nginx + namespace: hvidovre-main + resourceVersion: "442548298" + uid: 0401b101-76e4-4b75-8a07-34c2a1d3739d +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: bulk + volumeMode: Filesystem + volumeName: pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d +status: + accessModes: + - ReadWriteMany + capacity: + storage: 5Gi + phase: Bound diff --git a/infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d b/infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d new file mode 100644 index 00000000..04ae8eb3 --- /dev/null +++ b/infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + kubernetes.io/azure-file-resource-group: rg-env-dplplat01 + pv.kubernetes.io/migrated-to: file.csi.azure.com + pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file + volume.kubernetes.io/provisioner-deletion-secret-name: "" + volume.kubernetes.io/provisioner-deletion-secret-namespace: "" + creationTimestamp: "2024-04-30T17:40:46Z" + finalizers: + - kubernetes.io/pv-protection + name: pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d + resourceVersion: "442548296" + uid: 6dc923f9-5857-4034-8113-1e088f02f261 +spec: + accessModes: + - ReadWriteMany + azureFile: + secretName: azure-storage-account-stdpldplplat01585708af-secret + secretNamespace: hvidovre-main + shareName: pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d + capacity: + storage: 5Gi + claimRef: + apiVersion: v1 + kind: PersistentVolumeClaim + name: nginx + namespace: hvidovre-main + resourceVersion: "442548241" + uid: 0401b101-76e4-4b75-8a07-34c2a1d3739d + persistentVolumeReclaimPolicy: Retain + storageClassName: bulk + volumeMode: Filesystem +status: + phase: Bound diff --git a/infrastructure/pvAndPvcBackup/struer-main_nginx.yaml b/infrastructure/pvAndPvcBackup/struer-main_nginx.yaml new file mode 100644 index 00000000..babf1ff6 --- /dev/null +++ b/infrastructure/pvAndPvcBackup/struer-main_nginx.yaml @@ -0,0 +1,46 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + annotations: + k8up.syn.tools/backup: "true" + kubectl.kubernetes.io/last-applied-configuration: | + {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0"},"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"struer","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"struer-main"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk"}} + lagoon.sh/branch: main + lagoon.sh/version: 23.12.0 + pv.kubernetes.io/bind-completed: "yes" + pv.kubernetes.io/bound-by-controller: "yes" + volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com + volume.kubernetes.io/storage-provisioner: file.csi.azure.com + creationTimestamp: "2024-02-19T10:30:09Z" + finalizers: + - kubernetes.io/pvc-protection + labels: + app.kubernetes.io/instance: nginx + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: nginx-php-persistent + helm.sh/chart: nginx-php-persistent-0.1.0 + lagoon.sh/buildType: branch + lagoon.sh/environment: main + lagoon.sh/environmentType: production + lagoon.sh/project: struer + lagoon.sh/service: nginx + lagoon.sh/service-type: nginx-php-persistent + name: nginx + namespace: struer-main + resourceVersion: "381778955" + uid: 8f18f576-3623-44f9-892f-7919bac75aba +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 5Gi + storageClassName: bulk + volumeMode: Filesystem + volumeName: pvc-8f18f576-3623-44f9-892f-7919bac75aba +status: + accessModes: + - ReadWriteMany + capacity: + storage: 5Gi + phase: Bound diff --git a/infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba b/infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba new file mode 100644 index 00000000..6f227a34 --- /dev/null +++ b/infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba @@ -0,0 +1,36 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + annotations: + kubernetes.io/azure-file-resource-group: rg-env-dplplat01 + pv.kubernetes.io/migrated-to: file.csi.azure.com + pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file + volume.kubernetes.io/provisioner-deletion-secret-name: "" + volume.kubernetes.io/provisioner-deletion-secret-namespace: "" + creationTimestamp: "2024-02-19T10:30:09Z" + finalizers: + - kubernetes.io/pv-protection + name: pvc-8f18f576-3623-44f9-892f-7919bac75aba + resourceVersion: "381778953" + uid: 3baff759-f910-4b62-ae3c-aced15e51c7f +spec: + accessModes: + - ReadWriteMany + azureFile: + secretName: azure-storage-account-stdpldplplat01585708af-secret + secretNamespace: struer-main + shareName: pvc-8f18f576-3623-44f9-892f-7919bac75aba + capacity: + storage: 5Gi + claimRef: + apiVersion: v1 + kind: PersistentVolumeClaim + name: nginx + namespace: struer-main + resourceVersion: "381778879" + uid: 8f18f576-3623-44f9-892f-7919bac75aba + persistentVolumeReclaimPolicy: Retain + storageClassName: bulk + volumeMode: Filesystem +status: + phase: Bound From 58b6a83ea84bd84d572e490ae5fa90d6d6ecab50 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:05:26 +0200 Subject: [PATCH 14/23] update name of the new csi, so lagoon can find and use it --- infrastructure/new-bulk.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/new-bulk.yaml b/infrastructure/new-bulk.yaml index 5685e0b4..bbbd797d 100644 --- a/infrastructure/new-bulk.yaml +++ b/infrastructure/new-bulk.yaml @@ -1,7 +1,7 @@ kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: - name: new-bulk + name: bulk provisioner: file.csi.azure.com reclaimPolicy: Retain volumeBindingMode: Immediate From a985d0de345adafd887122e2e12f48f9184e0061 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:06:59 +0200 Subject: [PATCH 15/23] point to the new SC as the provider --- infrastructure/pv.yaml | 2 +- infrastructure/pvc.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/infrastructure/pv.yaml b/infrastructure/pv.yaml index b4275b71..99c422c4 100644 --- a/infrastructure/pv.yaml +++ b/infrastructure/pv.yaml @@ -10,7 +10,7 @@ spec: accessModes: - ReadWriteMany persistentVolumeReclaimPolicy: Retain - storageClassName: new-bulk + storageClassName: bulk csi: driver: file.csi.azure.com readOnly: false diff --git a/infrastructure/pvc.yaml b/infrastructure/pvc.yaml index c09ec765..ca53109b 100644 --- a/infrastructure/pvc.yaml +++ b/infrastructure/pvc.yaml @@ -26,6 +26,6 @@ spec: resources: requests: storage: 5Gi - storageClassName: new-bulk + storageClassName: bulk volumeMode: Filesystem volumeName: "new-pvc-0ed5e577-08bf-4488-9974-ea0aea26938f" From 0677c42263363606af607ad48f91c4f4d20196ee Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:08:13 +0200 Subject: [PATCH 16/23] changes after having run scripts --- infrastructure/pv.yaml | 9 +++++---- infrastructure/pvc.yaml | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/infrastructure/pv.yaml b/infrastructure/pv.yaml index 99c422c4..4090ddfe 100644 --- a/infrastructure/pv.yaml +++ b/infrastructure/pv.yaml @@ -3,7 +3,8 @@ kind: PersistentVolume metadata: annotations: pv.kubernetes.io/provisioned-by: file.csi.azure.com - name: new-pvc-0ed5e577-08bf-4488-9974-ea0aea26938f + name: pvc-5e5d8491-5ed5-4f92-ad51-598e507a9826 + namespace: vordingborg-main spec: capacity: storage: 5Gi @@ -14,13 +15,13 @@ spec: csi: driver: file.csi.azure.com readOnly: false - volumeHandle: /subscriptions/8ac8a259-5bb3-4799-bd1e-455145b12550/resourceGroups/rg-env-dplplat01/providers/Microsoft.Storage/storageAccounts/stdpldplplat01585708af/ # make sure volumeid is unique for every identical share in the cluster + volumeHandle: /subscriptions/8ac8a259-5bb3-4799-bd1e-455145b12550/resourceGroups/rg-env-dplplat01/providers/Microsoft.Storage/storageAccounts/stdpldplplat01585708af/pvc-5e5d8491-5ed5-4f92-ad51-598e507a9826 # make sure volumeid is unique for every identical share in the cluster volumeAttributes: resourceGroup: rg-env-dplplat01 # optional, only set this when storage account is not in the same resource group as the cluster nodes - shareName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f + shareName: pvc-5e5d8491-5ed5-4f92-ad51-598e507a9826 nodeStageSecretRef: name: azure-storage-account-stdpldplplat01585708af-secret - namespace: canary-main + namespace: vordingborg-main mountOptions: - dir_mode=0777 - file_mode=0777 diff --git a/infrastructure/pvc.yaml b/infrastructure/pvc.yaml index ca53109b..66becff1 100644 --- a/infrastructure/pvc.yaml +++ b/infrastructure/pvc.yaml @@ -15,11 +15,11 @@ metadata: lagoon.sh/buildType: branch lagoon.sh/environment: main lagoon.sh/environmentType: production - lagoon.sh/project: canary + lagoon.sh/project: vordingborg lagoon.sh/service: nginx lagoon.sh/service-type: nginx-php-persistent - name: new-nginx - namespace: "canary-main" + name: nginx + namespace: "vordingborg-main" spec: accessModes: - ReadWriteMany @@ -28,4 +28,4 @@ spec: storage: 5Gi storageClassName: bulk volumeMode: Filesystem - volumeName: "new-pvc-0ed5e577-08bf-4488-9974-ea0aea26938f" + volumeName: "pvc-5e5d8491-5ed5-4f92-ad51-598e507a9826" From 7cc04ab26ac684856fc315dc73bb201ea35fc17e Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:12:47 +0200 Subject: [PATCH 17/23] we wont need this anymore --- .../pvAndPvcBackup/canary-main_nginx.yaml | 42 ----------------- ...n_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f | 0 ...n_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 | 36 --------------- .../pvAndPvcBackup/hvidovre-main_nginx.yaml | 46 ------------------- ...n_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d | 36 --------------- .../pvAndPvcBackup/struer-main_nginx.yaml | 46 ------------------- ...n_pvc-8f18f576-3623-44f9-892f-7919bac75aba | 36 --------------- 7 files changed, 242 deletions(-) delete mode 100644 infrastructure/pvAndPvcBackup/canary-main_nginx.yaml delete mode 100644 infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f delete mode 100644 infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 delete mode 100644 infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml delete mode 100644 infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d delete mode 100644 infrastructure/pvAndPvcBackup/struer-main_nginx.yaml delete mode 100644 infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba diff --git a/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml b/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml deleted file mode 100644 index b6b682e5..00000000 --- a/infrastructure/pvAndPvcBackup/canary-main_nginx.yaml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - annotations: - k8up.syn.tools/backup: "true" - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0","pv.kubernetes.io/bind-completed":"yes","pv.kubernetes.io/bound-by-controller":"yes","volume.beta.kubernetes.io/storage-provisioner":"file.csi.azure.com","volume.kubernetes.io/storage-provisioner":"file.csi.azure.com"},"creationTimestamp":"2024-08-23T08:43:03Z","finalizers":["kubernetes.io/pvc-protection"],"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"canary","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"canary-main","resourceVersion":"582249915","uid":"0ed5e577-08bf-4488-9974-ea0aea26938f"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk","volumeMode":"Filesystem","volumeName":"pvc-0ed5e577-08bf-4488-9974-ea0aea26938f"},"status":{"accessModes":["ReadWriteMany"],"capacity":{"storage":"5Gi"},"phase":"Bound"}} - lagoon.sh/branch: main - lagoon.sh/version: 23.12.0 - pv.kubernetes.io/bind-completed: "yes" - pv.kubernetes.io/bound-by-controller: "yes" - volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com - volume.kubernetes.io/storage-provisioner: file.csi.azure.com - creationTimestamp: "2024-08-23T10:31:59Z" - finalizers: - - kubernetes.io/pvc-protection - labels: - app.kubernetes.io/instance: nginx - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/name: nginx-php-persistent - helm.sh/chart: nginx-php-persistent-0.1.0 - lagoon.sh/buildType: branch - lagoon.sh/environment: main - lagoon.sh/environmentType: production - lagoon.sh/project: canary - lagoon.sh/service: nginx - lagoon.sh/service-type: nginx-php-persistent - name: nginx - namespace: canary-main - resourceVersion: "582394955" - uid: 13eb6a7c-90f2-46a9-9cde-15b881d106ca -spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 5Gi - storageClassName: bulk - volumeMode: Filesystem - volumeName: pvc-0ed5e577-08bf-4488-9974-ea0aea26938f -status: - phase: Lost diff --git a/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f b/infrastructure/pvAndPvcBackup/canary-main_pvc-0ed5e577-08bf-4488-9974-ea0aea26938f deleted file mode 100644 index e69de29b..00000000 diff --git a/infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 b/infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 deleted file mode 100644 index 91f9aaf1..00000000 --- a/infrastructure/pvAndPvcBackup/canary-main_pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - annotations: - kubernetes.io/azure-file-resource-group: rg-env-dplplat01 - pv.kubernetes.io/migrated-to: file.csi.azure.com - pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file - volume.kubernetes.io/provisioner-deletion-secret-name: "" - volume.kubernetes.io/provisioner-deletion-secret-namespace: "" - creationTimestamp: "2024-04-10T12:58:58Z" - finalizers: - - kubernetes.io/pv-protection - name: pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 - resourceVersion: "424529568" - uid: 2240938a-7cba-4778-bdbe-b80d03864300 -spec: - accessModes: - - ReadWriteMany - azureFile: - secretName: azure-storage-account-stdpldplplat01585708af-secret - secretNamespace: canary-main - shareName: pvc-5fb0f9d8-a67c-44a6-a11b-a38112e679a3 - capacity: - storage: 5Gi - claimRef: - apiVersion: v1 - kind: PersistentVolumeClaim - name: nginx - namespace: canary-main - resourceVersion: "424529512" - uid: 5fb0f9d8-a67c-44a6-a11b-a38112e679a3 - persistentVolumeReclaimPolicy: Retain - storageClassName: bulk - volumeMode: Filesystem -status: - phase: Bound diff --git a/infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml b/infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml deleted file mode 100644 index 85631b54..00000000 --- a/infrastructure/pvAndPvcBackup/hvidovre-main_nginx.yaml +++ /dev/null @@ -1,46 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - annotations: - k8up.syn.tools/backup: "true" - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0"},"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"hvidovre","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"hvidovre-main"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk"}} - lagoon.sh/branch: main - lagoon.sh/version: 23.12.0 - pv.kubernetes.io/bind-completed: "yes" - pv.kubernetes.io/bound-by-controller: "yes" - volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com - volume.kubernetes.io/storage-provisioner: file.csi.azure.com - creationTimestamp: "2024-04-30T17:40:45Z" - finalizers: - - kubernetes.io/pvc-protection - labels: - app.kubernetes.io/instance: nginx - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/name: nginx-php-persistent - helm.sh/chart: nginx-php-persistent-0.1.0 - lagoon.sh/buildType: branch - lagoon.sh/environment: main - lagoon.sh/environmentType: production - lagoon.sh/project: hvidovre - lagoon.sh/service: nginx - lagoon.sh/service-type: nginx-php-persistent - name: nginx - namespace: hvidovre-main - resourceVersion: "442548298" - uid: 0401b101-76e4-4b75-8a07-34c2a1d3739d -spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 5Gi - storageClassName: bulk - volumeMode: Filesystem - volumeName: pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d -status: - accessModes: - - ReadWriteMany - capacity: - storage: 5Gi - phase: Bound diff --git a/infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d b/infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d deleted file mode 100644 index 04ae8eb3..00000000 --- a/infrastructure/pvAndPvcBackup/hvidovre-main_pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - annotations: - kubernetes.io/azure-file-resource-group: rg-env-dplplat01 - pv.kubernetes.io/migrated-to: file.csi.azure.com - pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file - volume.kubernetes.io/provisioner-deletion-secret-name: "" - volume.kubernetes.io/provisioner-deletion-secret-namespace: "" - creationTimestamp: "2024-04-30T17:40:46Z" - finalizers: - - kubernetes.io/pv-protection - name: pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d - resourceVersion: "442548296" - uid: 6dc923f9-5857-4034-8113-1e088f02f261 -spec: - accessModes: - - ReadWriteMany - azureFile: - secretName: azure-storage-account-stdpldplplat01585708af-secret - secretNamespace: hvidovre-main - shareName: pvc-0401b101-76e4-4b75-8a07-34c2a1d3739d - capacity: - storage: 5Gi - claimRef: - apiVersion: v1 - kind: PersistentVolumeClaim - name: nginx - namespace: hvidovre-main - resourceVersion: "442548241" - uid: 0401b101-76e4-4b75-8a07-34c2a1d3739d - persistentVolumeReclaimPolicy: Retain - storageClassName: bulk - volumeMode: Filesystem -status: - phase: Bound diff --git a/infrastructure/pvAndPvcBackup/struer-main_nginx.yaml b/infrastructure/pvAndPvcBackup/struer-main_nginx.yaml deleted file mode 100644 index babf1ff6..00000000 --- a/infrastructure/pvAndPvcBackup/struer-main_nginx.yaml +++ /dev/null @@ -1,46 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - annotations: - k8up.syn.tools/backup: "true" - kubectl.kubernetes.io/last-applied-configuration: | - {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{"k8up.syn.tools/backup":"true","lagoon.sh/branch":"main","lagoon.sh/version":"23.12.0"},"labels":{"app.kubernetes.io/instance":"nginx","app.kubernetes.io/managed-by":"Helm","app.kubernetes.io/name":"nginx-php-persistent","helm.sh/chart":"nginx-php-persistent-0.1.0","lagoon.sh/buildType":"branch","lagoon.sh/environment":"main","lagoon.sh/environmentType":"production","lagoon.sh/project":"struer","lagoon.sh/service":"nginx","lagoon.sh/service-type":"nginx-php-persistent"},"name":"nginx","namespace":"struer-main"},"spec":{"accessModes":["ReadWriteMany"],"resources":{"requests":{"storage":"5Gi"}},"storageClassName":"bulk"}} - lagoon.sh/branch: main - lagoon.sh/version: 23.12.0 - pv.kubernetes.io/bind-completed: "yes" - pv.kubernetes.io/bound-by-controller: "yes" - volume.beta.kubernetes.io/storage-provisioner: file.csi.azure.com - volume.kubernetes.io/storage-provisioner: file.csi.azure.com - creationTimestamp: "2024-02-19T10:30:09Z" - finalizers: - - kubernetes.io/pvc-protection - labels: - app.kubernetes.io/instance: nginx - app.kubernetes.io/managed-by: Helm - app.kubernetes.io/name: nginx-php-persistent - helm.sh/chart: nginx-php-persistent-0.1.0 - lagoon.sh/buildType: branch - lagoon.sh/environment: main - lagoon.sh/environmentType: production - lagoon.sh/project: struer - lagoon.sh/service: nginx - lagoon.sh/service-type: nginx-php-persistent - name: nginx - namespace: struer-main - resourceVersion: "381778955" - uid: 8f18f576-3623-44f9-892f-7919bac75aba -spec: - accessModes: - - ReadWriteMany - resources: - requests: - storage: 5Gi - storageClassName: bulk - volumeMode: Filesystem - volumeName: pvc-8f18f576-3623-44f9-892f-7919bac75aba -status: - accessModes: - - ReadWriteMany - capacity: - storage: 5Gi - phase: Bound diff --git a/infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba b/infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba deleted file mode 100644 index 6f227a34..00000000 --- a/infrastructure/pvAndPvcBackup/struer-main_pvc-8f18f576-3623-44f9-892f-7919bac75aba +++ /dev/null @@ -1,36 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - annotations: - kubernetes.io/azure-file-resource-group: rg-env-dplplat01 - pv.kubernetes.io/migrated-to: file.csi.azure.com - pv.kubernetes.io/provisioned-by: kubernetes.io/azure-file - volume.kubernetes.io/provisioner-deletion-secret-name: "" - volume.kubernetes.io/provisioner-deletion-secret-namespace: "" - creationTimestamp: "2024-02-19T10:30:09Z" - finalizers: - - kubernetes.io/pv-protection - name: pvc-8f18f576-3623-44f9-892f-7919bac75aba - resourceVersion: "381778953" - uid: 3baff759-f910-4b62-ae3c-aced15e51c7f -spec: - accessModes: - - ReadWriteMany - azureFile: - secretName: azure-storage-account-stdpldplplat01585708af-secret - secretNamespace: struer-main - shareName: pvc-8f18f576-3623-44f9-892f-7919bac75aba - capacity: - storage: 5Gi - claimRef: - apiVersion: v1 - kind: PersistentVolumeClaim - name: nginx - namespace: struer-main - resourceVersion: "381778879" - uid: 8f18f576-3623-44f9-892f-7919bac75aba - persistentVolumeReclaimPolicy: Retain - storageClassName: bulk - volumeMode: Filesystem -status: - phase: Bound From e1ce7c8ba48ae6415483ec73d34b1b8f5eec2760 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:14:35 +0200 Subject: [PATCH 18/23] script to copy files from nginx to cli pod in a namespace --- infrastructure/copy-files-from-nginx-to-cli.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 infrastructure/copy-files-from-nginx-to-cli.sh diff --git a/infrastructure/copy-files-from-nginx-to-cli.sh b/infrastructure/copy-files-from-nginx-to-cli.sh new file mode 100755 index 00000000..cc85a5d3 --- /dev/null +++ b/infrastructure/copy-files-from-nginx-to-cli.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +# +# Start a KK Shell session +# +# Syntax: +# dplsh [-p profile-name] [additional shell args] +# +set -euo pipefail + +NAMESPACES=$(kubectl get ns -l lagoon.sh/controller=lagoon --no-headers | awk '{print $1}' | grep herning) + +for ns in $NAMESPACES; do + echo $ns + NGINX=$(kubectl get pod -n $ns -l lagoon.sh/service=nginx -o name | head -n1) + CLI=$(kubectl get pod -n $ns -l lagoon.sh/service=cli --no-headers | grep -v cronjob | grep Running | awk '{print $1}') + kubectl exec -n $ns $NGINX -- tar cf - /app/web/sites/default/files | kubectl exec -i -n $ns $CLI -- tar xvfk - -C / || true +done From e7d0973d400b83f2e7e364bd9c37a86b051354f3 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:15:08 +0200 Subject: [PATCH 19/23] script to delete obsolote pv's and pvc's --- infrastructure/delete-pv-and-pvc.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 infrastructure/delete-pv-and-pvc.sh diff --git a/infrastructure/delete-pv-and-pvc.sh b/infrastructure/delete-pv-and-pvc.sh new file mode 100755 index 00000000..bc9475a6 --- /dev/null +++ b/infrastructure/delete-pv-and-pvc.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# +# This script creates new PersistentVolumeClaims and PersistentVolumes for a namespace +# + +set -euo pipefail + +NAMESPACES=$(kubectl get ns -l lagoon.sh/controller=lagoon --no-headers | awk '{print $1}') +for NAMESPACE in $NAMESPACES; do + echo $NAMESPACE + # Get pvc variable + PV_NAME=$(kubectl get pv -n $NAMESPACE new-nginx | grep pvc | awk '{print $3}') || true + echo $PV_NAME + if [ -z $PV_NAME ]; then + echo "skipping" + continue + fi + echo $PV_NAME + + # Delete old PVC from namespace + kubectl delete pvc -n $NAMESPACE new-nginx --wait=false || true + kubectl patch pvc -n $NAMESPACE new-nginx -p '{"metadata":{"finalizers":null}}' || true + # Mark old PV as up for deletion + # kubectl delete pv $PV_NAME --grace-period=0 --wait=false || true + # kubectl patch pv $PV_NAME -p '{"metadata":{"finalizers":null}}' || true + +done From 2fe8ba4bb7f92e4cabf5b280de2fd92ac4c52c70 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:16:42 +0200 Subject: [PATCH 20/23] script to make temporary pv and pvc's for namespace --- .../make-tmp-pv-and-pvc-for-namespace.sh | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 infrastructure/make-tmp-pv-and-pvc-for-namespace.sh diff --git a/infrastructure/make-tmp-pv-and-pvc-for-namespace.sh b/infrastructure/make-tmp-pv-and-pvc-for-namespace.sh new file mode 100755 index 00000000..2e5a1d06 --- /dev/null +++ b/infrastructure/make-tmp-pv-and-pvc-for-namespace.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# +# Start a KK Shell session +# +# Syntax: +# dplsh [-p profile-name] [additional shell args] +# +set -euo pipefail + +NAMESPACES=$(kubectl get ns -l lagoon.sh/controller=lagoon --no-headers | awk '{print $1}' | grep main) +VOLUMEHANDLE_PREFIX="/subscriptions/8ac8a259-5bb3-4799-bd1e-455145b12550/resourceGroups/rg-env-dplplat01/providers/Microsoft.Storage/storageAccounts/stdpldplplat01585708af/" +for ns in $NAMESPACES; do + echo $ns + # Get pvc variable + SHARE_NAME=$(kubectl get pvc -n $ns tmp-nginx | grep pvc | awk '{print $3}' | cut -c 5- ) + # echo $SHARE_NAME + + PROJECT_NAME=$(echo $ns | rev | cut -c 6- | rev) + # echo $PROJECT_NAME + # Set the PV's name to the new sharename + volumeName="$SHARE_NAME" yq -i '.metadata.name = strenv(volumeName)' pv.yaml + # The sharename is the same as we are doing a logical deletion and not a real one + shareName=$SHARE_NAME yq -i '.spec.csi.volumeAttributes.shareName = strenv(shareName)' pv.yaml + + volumeHandle="$VOLUMEHANDLE_PREFIX$SHARE_NAME" yq -i '.spec.csi.volumeHandle = strenv(volumeHandle)' pv.yaml + namespace=$ns yq -i '.metadata.namespace = strenv(namespace)' pv.yaml + namespace=$ns yq -i '.spec.csi.nodeStageSecretRef.namespace = strenv(namespace)' pv.yaml + # cat pv.yaml + + namespace=$ns yq -i '.metadata.namespace = strenv(namespace)' pvc.yaml + volumeName="$SHARE_NAME" yq -i '.spec.volumeName = strenv(volumeName)' pvc.yaml + projectName=$PROJECT_NAME yq -i '.metadata.labels."lagoon.sh/project" = strenv(projectName)' pvc.yaml + # cat pvc.yaml + kubectl apply -f pv.yaml + kubectl apply -f pvc.yaml + + kubectl patch deployments.apps -n $ns cli -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "nginx"}}]}}}}' + kubectl patch deployments.apps -n $ns nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "nginx"}}]}}}}' +done From f659772c22bae0257d6f9cb38c68f5b764f3a196 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:17:32 +0200 Subject: [PATCH 21/23] script to patch the nginx's in a namespace so they use the right storage --- infrastructure/patch-nginx-in-namespaces.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 infrastructure/patch-nginx-in-namespaces.sh diff --git a/infrastructure/patch-nginx-in-namespaces.sh b/infrastructure/patch-nginx-in-namespaces.sh new file mode 100755 index 00000000..faa76303 --- /dev/null +++ b/infrastructure/patch-nginx-in-namespaces.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# Start a KK Shell session +# +# Syntax: +# dplsh [-p profile-name] [additional shell args] +# +set -euo pipefail + +NAMESPACES=$(kubectl get ns -l lagoon.sh/controller=lagoon --no-headers | awk '{print $1}' ) + +for ns in $NAMESPACES; do + echo $ns + kubectl patch deployments.apps -n $ns nginx -p '{"spec":{"template":{"spec": {"volumes": [{"name": "nginx", "persistentVolumeClaim": { "claimName": "tmp-nginx"}}]}}}}' +done From 7f3d807c5d9a06a0770273548fda6aa1ab1a04c3 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:18:11 +0200 Subject: [PATCH 22/23] script to patch the metadata so lagoon will recognize the pvc's --- infrastructure/patch-pvc-metadata.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 infrastructure/patch-pvc-metadata.sh diff --git a/infrastructure/patch-pvc-metadata.sh b/infrastructure/patch-pvc-metadata.sh new file mode 100755 index 00000000..f7831ff5 --- /dev/null +++ b/infrastructure/patch-pvc-metadata.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# +# Start a KK Shell session +# +# Syntax: +# dplsh [-p profile-name] [additional shell args] +# +set -euo pipefail + +NAMESPACES=$(kubectl get ns -l lagoon.sh/controller=lagoon --no-headers | awk '{print $1}') +for ns in $NAMESPACES; do + echo $ns + kubectl patch -n $ns pvc nginx -p '{ + "metadata": { + "annotations": { + "kubectl.kubernetes.io/last-applied-configuration": null + } + } + }' || true +done From 952de061e8c37399dae5c7a7dbe9a101c0355434 Mon Sep 17 00:00:00 2001 From: Philip Date: Wed, 28 Aug 2024 13:22:48 +0200 Subject: [PATCH 23/23] clean up the infrastruture folder --- .../bin/csi-migration-scripts}/copy-files-from-nginx-to-cli.sh | 0 .../bin/csi-migration-scripts}/create-pv-and-pvc-for-namespace.sh | 0 .../{ => dpladm/bin/csi-migration-scripts}/delete-pv-and-pvc.sh | 0 .../{ => dpladm/bin/csi-migration-scripts}/deleteOldPvAndPvc.sh | 0 .../csi-migration-scripts}/make-tmp-pv-and-pvc-for-namespace.sh | 0 .../{ => dpladm/bin/csi-migration-scripts}/new-bulk.yaml | 0 .../bin/csi-migration-scripts}/patch-nginx-in-namespaces.sh | 0 .../{ => dpladm/bin/csi-migration-scripts}/patch-pvc-metadata.sh | 0 infrastructure/{ => dpladm/bin/csi-migration-scripts}/pv.yaml | 0 infrastructure/{ => dpladm/bin/csi-migration-scripts}/pvc.yaml | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/copy-files-from-nginx-to-cli.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/create-pv-and-pvc-for-namespace.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/delete-pv-and-pvc.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/deleteOldPvAndPvc.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/make-tmp-pv-and-pvc-for-namespace.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/new-bulk.yaml (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/patch-nginx-in-namespaces.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/patch-pvc-metadata.sh (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/pv.yaml (100%) rename infrastructure/{ => dpladm/bin/csi-migration-scripts}/pvc.yaml (100%) diff --git a/infrastructure/copy-files-from-nginx-to-cli.sh b/infrastructure/dpladm/bin/csi-migration-scripts/copy-files-from-nginx-to-cli.sh similarity index 100% rename from infrastructure/copy-files-from-nginx-to-cli.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/copy-files-from-nginx-to-cli.sh diff --git a/infrastructure/create-pv-and-pvc-for-namespace.sh b/infrastructure/dpladm/bin/csi-migration-scripts/create-pv-and-pvc-for-namespace.sh similarity index 100% rename from infrastructure/create-pv-and-pvc-for-namespace.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/create-pv-and-pvc-for-namespace.sh diff --git a/infrastructure/delete-pv-and-pvc.sh b/infrastructure/dpladm/bin/csi-migration-scripts/delete-pv-and-pvc.sh similarity index 100% rename from infrastructure/delete-pv-and-pvc.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/delete-pv-and-pvc.sh diff --git a/infrastructure/deleteOldPvAndPvc.sh b/infrastructure/dpladm/bin/csi-migration-scripts/deleteOldPvAndPvc.sh similarity index 100% rename from infrastructure/deleteOldPvAndPvc.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/deleteOldPvAndPvc.sh diff --git a/infrastructure/make-tmp-pv-and-pvc-for-namespace.sh b/infrastructure/dpladm/bin/csi-migration-scripts/make-tmp-pv-and-pvc-for-namespace.sh similarity index 100% rename from infrastructure/make-tmp-pv-and-pvc-for-namespace.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/make-tmp-pv-and-pvc-for-namespace.sh diff --git a/infrastructure/new-bulk.yaml b/infrastructure/dpladm/bin/csi-migration-scripts/new-bulk.yaml similarity index 100% rename from infrastructure/new-bulk.yaml rename to infrastructure/dpladm/bin/csi-migration-scripts/new-bulk.yaml diff --git a/infrastructure/patch-nginx-in-namespaces.sh b/infrastructure/dpladm/bin/csi-migration-scripts/patch-nginx-in-namespaces.sh similarity index 100% rename from infrastructure/patch-nginx-in-namespaces.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/patch-nginx-in-namespaces.sh diff --git a/infrastructure/patch-pvc-metadata.sh b/infrastructure/dpladm/bin/csi-migration-scripts/patch-pvc-metadata.sh similarity index 100% rename from infrastructure/patch-pvc-metadata.sh rename to infrastructure/dpladm/bin/csi-migration-scripts/patch-pvc-metadata.sh diff --git a/infrastructure/pv.yaml b/infrastructure/dpladm/bin/csi-migration-scripts/pv.yaml similarity index 100% rename from infrastructure/pv.yaml rename to infrastructure/dpladm/bin/csi-migration-scripts/pv.yaml diff --git a/infrastructure/pvc.yaml b/infrastructure/dpladm/bin/csi-migration-scripts/pvc.yaml similarity index 100% rename from infrastructure/pvc.yaml rename to infrastructure/dpladm/bin/csi-migration-scripts/pvc.yaml