Skip to content

Commit

Permalink
fix(scripts/dsl): printf & job dsl parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Neeptossss committed Dec 13, 2023
1 parent fd72dd8 commit 0fa2f66
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 50 deletions.
9 changes: 9 additions & 0 deletions examples/python-hello-world/whanos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
deployment:
replicas: 3
resources:
limits:
memory: "128M"
requests:
memory: "64M"
ports:
- 3000
4 changes: 3 additions & 1 deletion jenkins/job_dsl.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ freeStyleJob("link-project") {
preBuildCleanup()
}
steps {
shell('cp -r /whanos/scripts/* . && chmod -R 777 . && sh -c "./whanos.sh \${GITHUB_NAME}"')
shell('echo "Building project $DISPLAY_NAME"')
shell('export DISPLAY_NAME=$DISPLAY_NAME')
shell('cp -r /whanos/scripts/* . && chmod -R 777 . && sh -c "./whanos.sh $DISPLAY_NAME"')
}
}
''')
Expand Down
8 changes: 1 addition & 7 deletions kube/helm/whanos/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,4 @@ jenkins:
mountPath: /whanos
envVars:
- name: DOCKER_REGISTRY
value: "whanos-docker-registry.local"

docker-registry:
ingress:
enabled: true
hosts:
- whanos-docker-registry.local
value: "whanos-registry.local"
2 changes: 2 additions & 0 deletions kube/init/docker-registry/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: selfsigned-issuer
nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
name: docker-registry
namespace: docker-registry
spec:
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy_image.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if [[ -f whanos.yml ]]; then
helm upgrade -if whanos.yml "$1" /helm/AutoDeploy --set image.image=$image_name --set image.name="$1-name"
helm upgrade -if whanos.yml "$1" /whanos/helm/AutoDeploy --set image.image=$image_name --set image.name="$1-name"

external_ip=""
ip_timeout=20
Expand Down
1 change: 1 addition & 0 deletions scripts/install_dockercli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/source
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | tee /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y docker-ce-cli kubectl
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
31 changes: 15 additions & 16 deletions scripts/installation/all.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
#!/bin/bash
printf "Installing kubetools"
./kubetools.sh
printf "Installing kubetools\n"
./scripts/installation/kubetools.sh
if [ $? -ne 0 ]; then
printf "Installation of kubetools failed ❌"
printf "Installation of kubetools failed ❌\n"
exit 1
fi
printf "Installation of kubetools completed successfully ✅"
printf "\n\n\nInstallation of kubetools completed successfully ✅\n\n\n"

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

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

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

printf "INSTALLATION SUMMARY\n"
printf "========INSTALLATION SUMMARY========\n"
./installation-summary.sh
./scripts/installation/installation-summary.sh
if [ $? -ne 0 ]; then
echo "Installation summary failed ❌"
echo "Installation summary failed ❌\n"
exit 1
fi
printf "====================================\n"
Expand Down
34 changes: 17 additions & 17 deletions scripts/installation/docker-registry.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash
printf "Installing nginx ingress controller"
printf "Installing nginx ingress controller\n"
kubectl apply -f kube/init/nginx-ingress-controller/deployment.yaml
printf "Installed nginx ingress controller ✅"
printf "Installed nginx ingress controller ✅\n\n\n"

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

printf "Installing cert-manager"
printf "Installing cert-manager\n"
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
Expand All @@ -22,29 +22,29 @@ helm install \
--set ingressShim.defaultIssuerName=letsencrypt-prod \
--set ingressShim.defaultIssuerKind=ClusterIssuer \
--set ingressShim.defaultIssuerGroup=cert-manager.io
printf "Installed cert-manager ✅"
printf "Installed cert-manager ✅\n\n\n"

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 "Cert-manager is ready ✅\n\n\n"

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

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

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 "Adding whanos-registry.local fake DNS to /etc/hosts\n"
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; sudo echo "End point ready" && sudo sh -c "echo $external_ip whanos-registry.local >> /etc/hosts"'
printf "Added whanos-registry.local fake DNS to /etc/hosts ✅\n\n\n"

printf "Installing docker registry certificate"
printf "Installing docker registry certificate\n"
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 ✅"
kubectl get secret registry-tls -n docker-registry -o jsonpath="{.data.ca\.crt}" | base64 --decode > /tmp/whanos-registry.local.crt && sudo mv /tmp/whanos-registry.local.crt /etc/docker/certs.d/whanos-registry.local:443/ca.crt
printf "Installed docker registry certificate ✅\n\n\n"
Empty file modified scripts/installation/installation-summary.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions scripts/installation/jenkins.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
printf "Installing jenkins"
printf "Installing jenkins\n"
helm install whanos kube/helm/whanos --create-namespace --namespace whanos
printf "Installed jenkins ✅"
printf "Installed jenkins ✅\n\n\n"
12 changes: 6 additions & 6 deletions scripts/installation/kubetools.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
printf "Installing kubectl"
printf "Installing kubectl\n"
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 "Installed kubectl ✅\n\n\n"

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

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

0 comments on commit 0fa2f66

Please sign in to comment.