Last active
March 23, 2024 00:51
-
-
Save gitricko/b5125a3649e5d52faec4e4f9a496e166 to your computer and use it in GitHub Desktop.
Epinio accelerator installer + test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL := /bin/bash | |
export CLUSTER_NAME ?= epinio | |
export TMP_DIR ?= /tmp | |
IP_ADDR := $(shell ifconfig -a | grep "inet " | grep -v 127 | awk 'NR==1{print $$2}') | |
export DOMAIN ?= $(IP_ADDR).sslip.io | |
export EPINIO_SERVER_VERSION ?= 1.11.0 | |
export ADM_USR ?= admin | |
export ADM_PWD ?= password | |
export ADM_PWD_ENCRYPT := '$(shell htpasswd -bnBC 10 "" ${ADM_PWD} | tr -d :)' | |
export DEV_USR ?= dev | |
export DEV_PWD ?= password | |
export DEV_PWD_ENCRYPT := '$(shell htpasswd -bnBC 10 "" ${DEV_PWD} | tr -d :)' | |
# sudo apt-get install apache2-utils | |
cleanup-docker: | |
-docker rm -f $$(docker ps -qa) | |
docker system prune -a -f | |
docker volume prune -a -f | |
check-dependencies: | |
command -v docker && echo "docker - ok" | |
command -v k3d && echo "k3d - ok" | |
command -v kubectl && echo "kubectl - ok" | |
command -v helm && echo "helm - ok" | |
command -v epinio && echo "epinio - ok" | |
EP_CLI_VERSION := $(shell epinio -v | awk '{print $$3}') | |
check-epinio-cli-version: | |
if [[ $(EP_CLI_VERSION) == *${EPINIO_SERVER_VERSION}* ]]; then \ | |
echo "epinio cli and server are at the same version - $${EPINIO_SERVER_VERSION}"; \ | |
else \ | |
echo "epinio cli - $(EP_CLI_VERSION) and server - $${EPINIO_SERVER_VERSION} must be at the same version."; \ | |
exit 1; \ | |
fi | |
get-myip: | |
@echo "This current machine IP: $(IP_ADDR)" | |
get-ingress-ip: | |
kubectl get svc -n kube-system traefik -o jsonpath="{.status.loadBalancer.ingress[0]}" | jq -r ".ip" | |
create-cluster: | |
k3d cluster create $(CLUSTER_NAME) -p '80:80@loadbalancer' -p '443:443@loadbalancer' | |
kubectl rollout status deployment metrics-server -n kube-system --timeout=480s | |
delete-cluster: | |
k3d cluster delete $(CLUSTER_NAME) | |
get-kubeconfig: | |
k3d kubeconfig get $(CLUSTER_NAME) | |
install-cert-manager: | |
kubectl create namespace cert-manager | |
helm repo add jetstack https://charts.jetstack.io | |
helm repo update | |
helm install cert-manager --namespace cert-manager jetstack/cert-manager \ | |
--set installCRDs=true \ | |
--set extraArgs[0]=--enable-certificate-owner-ref=true | |
get-domain-k3d-traefik: | |
kubectl get svc -n kube-system traefik -o jsonpath="{.status.loadBalancer.ingress[0]}" | jq -r ".ip" | |
deploy-epinio: | |
helm repo add epinio https://epinio.github.io/helm-charts | |
kubectl rollout status deployment traefik -n kube-system --timeout=480s | |
helm install epinio -n epinio --create-namespace --version ${EPINIO_SERVER_VERSION} epinio/epinio \ | |
--set kubed.operator.repository=mirrored-appscode-kubed \ | |
--set kubed.operator.registry=rancher \ | |
--set global.domain=${DOMAIN} \ | |
--set api.users[0].roles[0]=admin \ | |
--set api.users[0].username=${ADM_USR} \ | |
--set api.users[0].passwordBcrypt=${ADM_PWD_ENCRYPT} \ | |
--set api.users[1].roles[0]=user \ | |
--set api.users[1].username=${DEV_USR} \ | |
--set api.users[1].passwordBcrypt=${DEV_PWD_ENCRYPT} \ | |
# --set minio.enabled=false \ | |
# --set s3gw.enabled=true \ | |
# ^^ Use s3gw instead of minio | |
kubectl rollout status deployment epinio-server -n epinio --timeout=480s | |
# Use this fix if helmchart backing service is broken if the version is wrong. | |
# kubectl get service.application.epinio -n epinio rabbitmq-dev -o json | jq '.spec.chartVersion="11.2.2"' | kubectl apply -f - | |
logout-epinio-user: | |
SETTINGS=$$(epinio settings show | grep Settings: | awk -F\: '{print $$2}' | xargs) && rm -- "$${SETTINGS}" | |
install-epinio-cli-linux: | |
-rm -f /usr/local/bin/epinio | |
curl -s -o epinio -L https://github.com/epinio/epinio/releases/download/v$(EPINIO_SERVER_VERSION)/epinio-linux-x86_64 | |
chmod +x ./epinio && mv epinio /usr/local/bin | |
install-epinio-cli-osx: | |
-rm -f /usr/local/bin/epinio | |
curl -s -o epinio -L https://github.com/epinio/epinio/releases/download/v$(EPINIO_SERVER_VERSION)/epinio-darwin-x86_64 | |
chmod +x ./epinio && mv epinio /usr/local/bin | |
test-epinio-wordpress: | |
-epinio service create mysql-dev mydb | |
-epinio apps create wordpress | |
sleep 30 | |
-epinio service bind mydb wordpress | |
cd $$(mktemp -d) && git clone --depth=1 https://github.com/epinio/example-wordpress && cd example-wordpress && \ | |
epinio push -n wordpress -r wordpress.${DOMAIN} -e BP_PHP_VERSION=8.1.x -e BP_PHP_SERVER=nginx -e BP_PHP_WEB_DIR=wordpress -e DB_HOST=$$(epinio configurations list | grep mydb | awk '{print $$2}') -e SERVICE_NAME=mydb | |
sleep 3 && curl -s -k https://wordpress.${DOMAIN} -L | grep 'Error establishing' || true | |
curl -s -k https://wordpress.${DOMAIN} -L | grep 'option value="en_CA"' | |
@echo | |
@echo "****** test epinio app with backing-sevice: succeeded" | |
@echo | |
test-epinio-python: | |
cd $$(mktemp -d) && git clone --depth=1 https://github.com/paketo-buildpacks/samples && \ | |
cd samples/python/conda && epinio push --name conda-app --route conda-app.${DOMAIN} | |
sleep 3 && curl -k https://conda-app.${DOMAIN} | |
@echo | |
@echo "****** test epinio app: succeeded" | |
@echo | |
test-epinio-ui-login: | |
curl -s -k "https://epinio.${DOMAIN}" | |
curl -s -k "https://epinio.${DOMAIN}/pp/v1/epinio/rancher/v3-public/authProviders/local/login" -X POST --data-raw '{"description":"UI session","responseType":"cookie","username":"admin","password":"password"}' | |
test-epinio: | |
epinio login -u $(ADM_USR) -p $(ADM_PWD) --trust-ca https://epinio.${DOMAIN} | |
$(MAKE) test-epinio-python | |
@echo "*** If you see this, your epinio stack is up and running !!! ***" | |
undeploy-epinio: undeploy-epinio | |
helm uninstall -n epinio epinio | |
uninstall-epinio: | |
$(MAKE) delete-cluster | |
install-epinio: | |
@echo | |
@echo "****** STEP (0): Checking dependencies..." | |
@echo | |
$(MAKE) check-dependencies | |
-$(MAKE) logout-epinio-user | |
$(MAKE) check-epinio-cli-version | |
@echo | |
@echo "****** STEP (1): Create k3d cluster..." | |
@echo | |
$(MAKE) create-cluster | |
@echo | |
@echo "****** STEP (2): Deploy cert-manager into cluster..." | |
@echo | |
$(MAKE) install-cert-manager | |
@echo | |
@echo "****** STEP (3): Deploy epinio into cluster..." | |
@echo | |
$(MAKE) deploy-epinio | |
@echo | |
@echo "****** STEP (4): Verify epinio admin ui/login works..." | |
@echo | |
$(MAKE) test-epinio-ui-login | |
@echo | |
@echo "****** STEP (5): Verify epinio install by push apps..." | |
@echo | |
$(MAKE) test-epinio | |
@echo | |
@echo "****** STEP (6): Verify backing service by installing wordpress..." | |
@echo | |
$(MAKE) test-epinio-wordpress | |
@echo | |
@echo "****** SUCCESS: If you see this message, it means epinio app PaaS is in working condition" | |
@echo | |
epinio settings show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment