From 67c19ef4037d21b30a326be3f6b0a86c5a12f3ce Mon Sep 17 00:00:00 2001 From: Victor Timofei Date: Wed, 8 Dec 2021 23:51:00 +0200 Subject: [PATCH] Add initial installation script --- .gitignore | 1 + cluster_issuer.yaml | 14 +++++++++ install.sh | 76 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 .gitignore create mode 100644 cluster_issuer.yaml create mode 100755 install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/cluster_issuer.yaml b/cluster_issuer.yaml new file mode 100644 index 0000000..0f429c7 --- /dev/null +++ b/cluster_issuer.yaml @@ -0,0 +1,14 @@ +apiVersion: cert-manager.io/v1 +kind: ClusterIssuer +metadata: + name: letsencrypt-prod +spec: + acme: + email: EMAIL_ADDRESS + server: https://acme-v02.api.letsencrypt.org/directory + privateKeySecretRef: + name: letsencrypt-prod-private-key + solvers: + - http01: + ingress: + class: nginx diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..3c33b1d --- /dev/null +++ b/install.sh @@ -0,0 +1,76 @@ +#!/usr/bin/bash + +EMAIL_ADDRESS="${EMAIL_ADDRESS:-kubernetesadmin@example.org}" +KUBECTL_BIN="${KUBECTL_BIN:-kubectl}" +INSTALL_DIR="${INSTALL_DIR:-$(pwd)/bin}" +HELM_BIN="${INSTALL_DIR}/helm" +ARGOCD_BIN="${INSTALL_DIR}/argocd" + +blue_color="\e[34m" +reset_color="\e[0m" + +function log_info { + printf "%b%s%b\n" "${blue_color}" "${1}" "${reset_color}" +} + +function install_helm { + curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 \ + | USE_SUDO="false" HELM_INSTALL_DIR="${INSTALL_DIR}" bash +} + +function install_nginx_ingress_controller { + ${HELM_BIN} repo add ingress-nginx https://kubernetes.github.io/ingress-nginx + ${HELM_BIN} repo update + ${HELM_BIN} install nginx-ingress ingress-nginx/ingress-nginx \ + --set controller.publishService.enabled=true +} + +function install_cert_manager { + ${KUBECTL_BIN} create namespace cert-manager + ${HELM_BIN} repo add jetstack https://charts.jetstack.io + ${HELM_BIN} repo update + ${HELM_BIN} install cert-manager jetstack/cert-manager \ + --namespace cert-manager \ + --version v1.2.0 \ + --set installCRDs=true +} + +function create_cluster_issuer { + sed "s/EMAIL_ADDRESS/${EMAIL_ADDRESS}/" cluster_issuer.yaml | ${KUBECTL_BIN} apply -f - +} + +function install_argocd_full { + ${KUBECTL_BIN} create namespace argocd + ${KUBECTL_BIN} apply \ + -n argocd \ + -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml + + curl -sSL -o "${ARGOCD_BIN}" https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64 + chmod +x "${ARGOCD_BIN}" + +} + +function install_tekton { + ${KUBECTL_BIN} apply \ + -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml +} + +mkdir -pv "${INSTALL_DIR}" + +log_info "Installing Helm..." +install_helm + +log_info "Installing NGINX ingress controller..." +install_nginx_ingress_controller + +log_info "Installing cert manager..." +install_cert_manager +create_cluster_issuer + +log_info "Installing Argo CD..." +install_argocd_full + +log_info "Installing Tekton..." +install_tekton + +log_info "Installation completed successfuly!"