Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from in tree to csi #448

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Switch from in tree to csi #448

wants to merge 23 commits into from

Conversation

ITViking
Copy link
Contributor

@ITViking ITViking commented Sep 6, 2024

What does this PR do?

These are the scripts we have used to move to the new CSI

Should this be tested by the reviewer and how?

no

Any specific requests for how the PR should be reviewed?

read it

What are the relevant tickets?

https://reload.atlassian.net/jira/software/c/projects/DDFDRIFT/boards/464?search=csi&selectedIssue=DDFDRIFT-189

@ITViking ITViking requested a review from ath88 September 6, 2024 10:20
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

shellcheck

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl get pvc -n $NAMESPACE $PVC_NAME -o yaml > "./pvAndPvcBackup/${NAMESPACE}_${PVC_NAME}.yaml"


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl get pv $VOLUME_NAME -o yaml > "./pvAndPvcBackup/${NAMESPACE}_${VOLUME_NAME}"


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl delete pvc -n $NAMESPACE $PVC_NAME --wait=false


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl delete pvc -n $NAMESPACE $PVC_NAME --wait=false


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl patch pvc -n $NAMESPACE $PVC_NAME -p '{"metadata":{"finalizers":null}}'


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl patch pvc -n $NAMESPACE $PVC_NAME -p '{"metadata":{"finalizers":null}}'


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl delete pv $VOLUME_NAME --grace-period=0 --wait=false


📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

kubectl patch pv $VOLUME_NAME -p '{"metadata":{"finalizers":null}}'

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

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- )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

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"}}]}}}}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

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"}}]}}}}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

# 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

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"}}]}}}}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086


echo "Proceeding to remove the now obsolete PV and PVC from the namespace $1"

backupAndDeleteOldPvAndPvc $1 $VOLUME_NAME "nginx"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086


echo "Proceeding to remove the now obsolete PV and PVC from the namespace $1"

backupAndDeleteOldPvAndPvc $1 $VOLUME_NAME "nginx"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

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"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Double quote to prevent globbing and word splitting. SC2086

Comment on lines +14 to +15
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}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shellcheck (suggestion)] reported by reviewdog 🐶

Suggested change
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}"
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}"

Comment on lines +17 to +18
kubectl delete pvc -n $NAMESPACE $PVC_NAME --wait=false
kubectl patch pvc -n $NAMESPACE $PVC_NAME -p '{"metadata":{"finalizers":null}}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shellcheck (suggestion)] reported by reviewdog 🐶

Suggested change
kubectl delete pvc -n $NAMESPACE $PVC_NAME --wait=false
kubectl patch pvc -n $NAMESPACE $PVC_NAME -p '{"metadata":{"finalizers":null}}'
kubectl delete pvc -n "$NAMESPACE" "$PVC_NAME" --wait=false
kubectl patch pvc -n "$NAMESPACE" "$PVC_NAME" -p '{"metadata":{"finalizers":null}}'

Comment on lines +20 to +21
kubectl delete pv $VOLUME_NAME --grace-period=0 --wait=false
kubectl patch pv $VOLUME_NAME -p '{"metadata":{"finalizers":null}}'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shellcheck (suggestion)] reported by reviewdog 🐶

Suggested change
kubectl delete pv $VOLUME_NAME --grace-period=0 --wait=false
kubectl patch pv $VOLUME_NAME -p '{"metadata":{"finalizers":null}}'
kubectl delete pv "$VOLUME_NAME" --grace-period=0 --wait=false
kubectl patch pv "$VOLUME_NAME" -p '{"metadata":{"finalizers":null}}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants