Skip to content

Commit

Permalink
update delete.sh to support self-sign-certs
Browse files Browse the repository at this point in the history
Signed-off-by: jooho <[email protected]>
  • Loading branch information
Jooho committed Aug 29, 2023
1 parent 4a47d56 commit f6a615c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,35 @@ if [[ ! -z $user_ns_array ]]; then
rm runtimes.yaml
fi

export enable_self_signed_ca=true
if kubectl get certificates modelmesh-webhook-server-cert -n $namespace &> /dev/null; then
echo "Cert Manager is installed"
export enable_self_signed_ca=false
fi

if [[ $enable_self_signed_ca == "true" ]]; then
echo "Enabled Self Signed CA: Update manifest"
if [[ ! -f certmanager/kustomization.yaml.ori ]]; then
cp certmanager/kustomization.yaml certmanager/kustomization.yaml.ori
fi
cd certmanager; kustomize edit remove resource certificate.yaml; cd ../

if [[ ! -f default/kustomization.yaml.ori ]]; then
cp default/kustomization.yaml default/kustomization.yaml.ori
fi
cd default; kustomize edit remove resource ../certmanager; cd ../

# comment out vars
configMapGeneratorStartLine=$(grep -n configMapGenerator ./default/kustomization.yaml |cut -d':' -f1)
configMapGeneratorBeforeLine=$((configMapGeneratorStartLine-1))
sed -i.bak "1,${configMapGeneratorBeforeLine}s/^/#/g" default/kustomization.yaml

# remove webhookcainjection_patch.yaml
sed -i.bak '/webhookcainjection_patch.yaml/d' default/kustomization.yaml

rm default/kustomization.yaml.bak
fi

# Determine whether a modelmesh-controller-rolebinding clusterrolebinding exists and is
# associated with the service account in this namespace. If not, don't delete the cluster level RBAC.
set +e
Expand All @@ -141,3 +170,9 @@ kubectl delete -f dependencies/fvt.yaml --ignore-not-found=true
if [[ "$namespace" != "$old_namespace" ]]; then
kubectl config set-context --current --namespace=${old_namespace}
fi

if [[ $enable_self_signed_ca == "true" ]]; then
cp certmanager/kustomization.yaml.ori certmanager/kustomization.yaml
cp default/kustomization.yaml.ori default/kustomization.yaml
rm certmanager/kustomization.yaml.ori default/kustomization.yaml.ori
fi

0 comments on commit f6a615c

Please sign in to comment.