Skip to content

Commit

Permalink
feat(scripts): add installation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeptossss committed Dec 2, 2023
1 parent 244d064 commit 490bb9b
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
38 changes: 38 additions & 0 deletions scripts/installation/all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
printf "Installing kubetools"
./kubetools.sh
if [ $? -ne 0 ]; then
printf "Installation of kubetools failed ❌"
exit 1
fi
printf "Installation of kubetools completed successfully ✅"

printf "Installing docker registry"
./docker-registry.sh
if [ $? -ne 0 ]; then
printf "Installation of docker registry failed ❌"
exit 1
fi
printf "Installation of docker registry completed successfully ✅"

printf "Installing jenkins"
./jenkins.sh
if [ $? -ne 0 ]; then
echo "Installation of jenkins failed ❌"
exit 1
fi
printf "Installation of jenkins completed successfully ✅"

printf "INSTALLATION COMPLETED SUCCESSFULLY ✅"
printf "\n\n\n\n\n"

printf "INSTALLATION SUMMARY\n"
printf "========INSTALLATION SUMMARY========\n"
./installation-summary.sh
if [ $? -ne 0 ]; then
echo "Installation summary failed ❌"
exit 1
fi
printf "====================================\n"
printf "Happy hacking! 🚀\n"

50 changes: 50 additions & 0 deletions scripts/installation/docker-registry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
printf "Installing nginx ingress controller"
kubectl apply -f kube/init/nginx-ingress-controller/deployment.yaml
printf "Installed nginx ingress controller ✅"

printf "Waiting for ingress controller to be ready"
kubectl wait --namespace ingress-nginx \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=120s
printf "Ingress controller is ready ✅"

printf "Installing cert-manager"
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.5.4 \
--set installCRDs=true \
--set ingressShim.defaultIssuerName=letsencrypt-prod \
--set ingressShim.defaultIssuerKind=ClusterIssuer \
--set ingressShim.defaultIssuerGroup=cert-manager.io
printf "Installed cert-manager ✅"

printf "Waiting for cert-manager to be ready"
kubectl wait --namespace cert-manager \
--for=condition=ready pod \
--selector=app.kubernetes.io/component=webhook \
--timeout=120s
printf "Cert-manager is ready ✅"

printf "Deploying cluster issuer for cert-manager"
kubectl apply -f kube/init/cert-manager/cluster-issuer.yaml
printf "Deployed cluster issuer for cert-manager ✅"

printf "Deploying docker registry"
kubectl apply -f kube/init/docker-registry/deployment.yaml
kubectl apply -f kube/init/docker-registry/ingress.yaml
printf "Deployed docker registry ✅"

printf "Adding whanos-registry.local fake DNS to /etc/hosts"
sudo sh -c 'external_ip=""; while [ -z $external_ip ]; do echo "Waiting for end point..."; external_ip=$(kubectl get ingress -n docker-registry docker-registry -o jsonpath="{.status.loadBalancer.ingress[0].ip}"); [ -z "$external_ip" ] && sleep 10; done; echo "End point ready" && echo $external_ip whanos-registry.local >> /etc/hosts'
printf "Added whanos-registry.local fake DNS to /etc/hosts ✅"

printf "Installing docker registry certificate"
sudo mkdir -p /etc/docker/certs.d/whanos-registry.local:443/
kubectl get secret registry-tls -n docker-registry -o jsonpath='{.data.ca\.crt}' | base64 --decode > /etc/docker/certs.d/whanos-registry.local:443/ca.crt
printf "Installed docker registry certificate ✅"
4 changes: 4 additions & 0 deletions scripts/installation/installation-summary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
printf "🚀 You can now access your Jenkins instance at http://localhost:8080\n"
printf "🚀 You can now access your Docker registry at http://localhost:5000\n"
printf "🚀 You can now access your Kubernetes dashboard at http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/\n"
4 changes: 4 additions & 0 deletions scripts/installation/jenkins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
printf "Installing jenkins"
helm install whanos /whanos/kube/helm/whanos --create-namespace --namespace whanos
printf "Installed jenkins ✅"
19 changes: 19 additions & 0 deletions scripts/installation/kubetools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
printf "Installing kubectl"
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
printf 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
printf "Installed kubectl ✅"

printf "Configuring kubectl"
mkdir -p ~/.kube
sudo cp /etc/kubernetes/admin.conf ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
printf "Configured kubectl ✅"

printf "Installing helm"
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
printf "Installed helm ✅"

0 comments on commit 490bb9b

Please sign in to comment.