diff --git a/.dockerignore b/.dockerignore index 12389ce613..87ac5d9034 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,6 +11,7 @@ /.travis.yml /AUTHORS /CONTRIBUTORS +/doc /Dockerfile /LICENSE /bin diff --git a/doc/infra/minikube.md b/doc/infra/minikube.md new file mode 100644 index 0000000000..5e4b745f88 --- /dev/null +++ b/doc/infra/minikube.md @@ -0,0 +1,52 @@ +# Deploy stack to minikube + +## Setup + +status : Alpha + + + +```bash +minikube start +minikube addons enable ingress +``` + +Get the minikube IP: + +```bash +minikube ip +``` + + +Refer to [sample.yaml](../infra/helm/sample.yaml) to get all domains. +Add these domains to your `/etc/hosts`: + +``` +# Alchemy Minikube +192.168.49.2 phraseanet-bo.alchemy.kube +# ... add other domains +``` + +For a quicker setup we will use the nginx configuration explained in [dev-with-nginx](./dev-with-nginx.md) + +## Build local image in minikube + +If you need to test your fresh image directly into minikube cluster, you need to build them +with the Mminikube Docker daemon: + +```bash +eval $(minikube docker-env) +docker-compose build +``` + +Alternatively you can run a registry in minikube and push your images: +https://minikube.sigs.k8s.io/docs/handbook/pushing/#4-pushing-to-an-in-cluster-using-registry-add + +If your minikube server name is not "minikube" define it in MINIKUBE_NAME + + +```bash +infra/dev/deploy-minikube.sh install +infra/dev/deploy-minikube.sh update +infra/dev/deploy-minikube.sh uninstall +``` \ No newline at end of file diff --git a/infra/dev/deploy-minikube.sh b/infra/dev/deploy-minikube.sh new file mode 100755 index 0000000000..c158a7eba5 --- /dev/null +++ b/infra/dev/deploy-minikube.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +set -ex + + +BASEDIR="$(dirname $0)" +DIR="${BASEDIR}" + +#MINIKUBE_NAME:${MINIKUBE_NAME:-"minikube"} + +NS=${NS:-"phraseanet"} +RELEASE_NAME="phraseanet" +CHART_DIR="infra/helm/all" +VALUE_SRC="infra/helm/myvalues.yaml" + +#kubectl config use-context $MINIKUBE_NAME + +case $1 in + uninstall) + helm uninstall ${RELEASE_NAME} || true; + ;; + validate) + helm install --dry-run --debug ${RELEASE_NAME} "${CHART_DIR}" \ + -f "${VALUE_SRC}" \ + --namespace $NS + ;; + update) + echo "Updating..." + helm upgrade ${RELEASE_NAME} "${CHART_DIR}" \ + -f "${VALUE_SRC}" \ + --namespace $NS + ;; + + *) + if [ ! -d "${CHART_DIR}/charts" ]; then + (cd "${CHART_DIR}" && helm dependency update) + fi + kubectl create ns $NS || true + helm uninstall ${RELEASE_NAME} --namespace $NS || true; + # kubectl -n $NS delete pvc elasticsearch-master-elasticsearch-master-0 || true + while [ $(kubectl -n $NS get pvc | wc -l) -gt 0 ] || [ $(kubectl -n $NS get pods | wc -l) -gt 0 ] + do + echo "Waiting for resources to be deleted..." + sleep 5 + done + echo "Installing release ${RELEASE_NAME} in namespace $NS..." + helm install ${RELEASE_NAME} "${CHART_DIR}" \ + -f "${VALUE_SRC}" \ + --namespace $NS + ;; +esac