Skip to content

Commit

Permalink
Add --purge flag
Browse files Browse the repository at this point in the history
Also uses removed finalizers before deleting crds. kubernetes/kubernetes#60538
  • Loading branch information
tamalsaha committed Mar 8, 2018
1 parent 1a7ee23 commit 0810f60
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 36 deletions.
17 changes: 12 additions & 5 deletions docs/setup/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ product_name: voyager
menu_name: product_voyager_6.0.0-rc.2
section_menu_id: setup
---

# Installation Guide

## Using YAML
Voyager operator can be installed via a script or as a Helm chart.

## Using Script

Voyager can be installed via installer script included in the [/hack/deploy](https://github.com/appscode/voyager/tree/6.0.0-rc.2/hack/deploy) folder.
To install Voyager in your Kubernetes cluster, pick the appropriate cluster provider and run the following command:

```console
# provider=acs
Expand All @@ -32,9 +33,11 @@ $ curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0-rc.2/hack/
| bash -s -- --provider=$provider
```

After successful installation, you should have a `voyager-operator-***` pod running in the `kube-system` namespace.

#### Customizing Installer

You can see the full list of flags available to installer using `-h` flag.
The installer script and associated yaml files can be found in the [/hack/deploy](https://github.com/appscode/voyager/tree/6.0.0-rc.2/hack/deploy) folder. To see the full list of flags available to installer, use the `-h` flag.

```console
$ curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0-rc.2/hack/deploy/voyager.sh | bash -s -- -h
Expand All @@ -51,8 +54,10 @@ options:
--image-pull-secret name of secret used to pull voyager operator images
--restrict-to-namespace restrict voyager to its own namespace
--run-on-master run voyager operator on master
--enable-admission-webhook configure admission webhook for Voyager CRDs
--enable-admission-webhook configure admission webhook for voyager CRDs
--template-cfgmap=CONFIGMAP name of configmap with custom templates
--uninstall uninstall voyager
--purge purges Voyager crd objects and crds
```

If you would like to run Voyager operator pod in `master` instances, pass the `--run-on-master` flag:
Expand Down Expand Up @@ -98,6 +103,8 @@ $ curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0-rc.2/hack/
| bash -s -- --provider=$provider --enable-admission-webhook [--rbac]
```

To use custom templates to render HAProxy configuration, visit [here](/docs/guides/ingress/configuration/custom-templates.md).

## Using Helm

Voyager can be installed via [Helm](https://helm.sh/) using the [chart](https://github.com/appscode/voyager/tree/6.0.0-rc.2/chart/stable/voyager) included in this repository or from official charts repository. To install the chart with the release name `my-release`:
Expand Down
31 changes: 2 additions & 29 deletions docs/setup/uninstall.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ product_name: voyager
menu_name: product_voyager_6.0.0-rc.2
section_menu_id: setup
---

# Uninstall Voyager

Please follow the steps below to uninstall Voyager:

- Delete the deployment and service used for Voyager operator.
To uninstall Voyager operator, run the following command:

```console
$ curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0-rc.2/hack/deploy/voyager.sh \
Expand All @@ -34,28 +31,4 @@ No resources found
No resources found
```

- Now, wait several seconds for Voyager to stop running. To confirm that Voyager operator pod(s) have stopped running, run:

```console
$ kubectl get pods --all-namespaces -l app=voyager
```

- To keep a copy of your existing Voyager objects, run:

```console
$ kubectl get ingress.voyager.appscode.com --all-namespaces -o yaml > ingress.yaml
$ kubectl get certificate.voyager.appscode.com --all-namespaces -o yaml > certificate.yaml
```

- To delete existing Voyager objects from all namespaces, run the following command in each namespace one by one.

```console
$ kubectl delete ingress.voyager.appscode.com --all --cascade=false
$ kubectl delete certificate.voyager.appscode.com --all --cascade=false
```

- Delete the old CRD-registration.

```console
kubectl delete crd -l app=voyager
```
The above command will leave the Voyager crd objects as-is. If you wish to **nuke** all Voyager crd objects, also pass the `--purge` flag. This will keep a copy of Voyager crd objects in your current directory.
53 changes: 51 additions & 2 deletions hack/deploy/voyager.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/bash
set -eou pipefail

crds=(certificates ingresses)

echo "checking kubeconfig context"
kubectl config current-context || { echo "Set a context (kubectl use-context <context>) out of the following:"; echo; kubectl config get-contexts; exit 1; }
Expand Down Expand Up @@ -52,6 +55,8 @@ export VOYAGER_ROLE_TYPE=ClusterRole
export VOYAGER_DOCKER_REGISTRY=appscode
export VOYAGER_IMAGE_PULL_SECRET=
export VOYAGER_UNINSTALL=0
export VOYAGER_PURGE=0
export VOYAGER_TEMPLATE_CONFIGMAP=

KUBE_APISERVER_VERSION=$(kubectl version -o=json | $ONESSL jsonpath '{.serverVersion.gitVersion}')
$ONESSL semver --check='>=1.9.0' $KUBE_APISERVER_VERSION
Expand All @@ -76,6 +81,7 @@ show_help() {
echo " --enable-admission-webhook configure admission webhook for voyager CRDs"
echo " --template-cfgmap=CONFIGMAP name of configmap with custom templates"
echo " --uninstall uninstall voyager"
echo " --purge purges Voyager crd objects and crds"
}

while test $# -gt 0; do
Expand Down Expand Up @@ -155,6 +161,10 @@ while test $# -gt 0; do
export VOYAGER_UNINSTALL=1
shift
;;
--purge)
export VOYAGER_PURGE=1
shift
;;
*)
show_help
exit 1
Expand All @@ -176,6 +186,43 @@ if [ "$VOYAGER_UNINSTALL" -eq 1 ]; then
kubectl delete rolebindings -l app=voyager --namespace $VOYAGER_NAMESPACE
kubectl delete role -l app=voyager --namespace $VOYAGER_NAMESPACE

echo "waiting for voyager operator pod to stop running"
for (( ; ; )); do
pods=($(kubectl get pods --all-namespaces -l app=voyager -o jsonpath='{range .items[*]}{.metadata.name} {end}'))
total=${#pods[*]}
if [ $total -eq 0 ] ; then
break
fi
sleep 2
done

# https://github.com/kubernetes/kubernetes/issues/60538
if [ "$VOYAGER_PURGE" -eq 1 ]; then
for crd in "${crds[@]}"; do
pairs=($(kubectl get ${crd}.voyager.appscode.com --all-namespaces -o jsonpath='{range .items[*]}{.metadata.name} {.metadata.namespace} {end}'))
total=${#pairs[*]}

# save objects
if [ $total -gt 0 ]; then
echo "dumping ${crd} objects into ${crd}.yaml"
kubectl get ${crd}.voyager.appscode.com --all-namespaces -o yaml > ${crd}.yaml
fi

for (( i=0; i<$total; i+=2 )); do
# remove finalizers
kubectl patch ${crd}.voyager.appscode.com ${pairs[$i]} -n ${pairs[$i + 1]} -p '{"metadata":{"finalizers":[]}}' --type=merge
# delete crd object
echo "deleting ${crd} ${pairs[$i + 1]}/${pairs[$i]}"
kubectl delete ${crd}.voyager.appscode.com ${pairs[$i]} -n ${pairs[$i + 1]}
done

# delete crd
kubectl delete crd ${crd}.voyager.appscode.com || true
done
fi

echo
echo "Successfully uninstalled Voyager!"
exit 0
fi

Expand Down Expand Up @@ -270,15 +317,17 @@ if [ "$VOYAGER_ENABLE_ADMISSION_WEBHOOK" = true ]; then
curl -fsSL https://raw.githubusercontent.com/appscode/voyager/6.0.0-rc.2/hack/deploy/admission.yaml | $ONESSL envsubst | kubectl apply -f -
fi

echo
echo "waiting until voyager operator deployment is ready"
$ONESSL wait-until-ready deployment voyager-operator --namespace $VOYAGER_NAMESPACE || { echo "Voyager operator deployment failed to be ready"; exit 1; }

echo "waiting until voyager apiservice is available"
$ONESSL wait-until-ready apiservice v1beta1.admission.voyager.appscode.com || { echo "Voyager apiservice failed to be ready"; exit 1; }

echo "waiting until voyager crds are ready"
$ONESSL wait-until-ready crd certificates.voyager.appscode.com || { echo "Certificate CRD failed to be ready"; exit 1; }
$ONESSL wait-until-ready crd ingresses.voyager.appscode.com || { echo "Ingress CRD failed to be ready"; exit 1; }
for crd in "${crds[@]}"; do
$ONESSL wait-until-ready crd ${crd}.voyager.appscode.com || { echo "$crd crd failed to be ready"; exit 1; }
done

echo
echo "Successfully installed Voyager!"

0 comments on commit 0810f60

Please sign in to comment.