Compare commits
No commits in common. "jenkins-dev" and "main" have entirely different histories.
jenkins-de
...
main
18
Dockerfile
18
Dockerfile
|
|
@ -1,18 +0,0 @@
|
||||||
FROM jenkins/jenkins:2.332.3-jdk11
|
|
||||||
USER root
|
|
||||||
RUN apt-get update && apt-get install -y lsb-release
|
|
||||||
RUN apt-get install wget -y
|
|
||||||
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
|
|
||||||
https://download.docker.com/linux/debian/gpg
|
|
||||||
RUN echo "deb [arch=$(dpkg --print-architecture) \
|
|
||||||
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
|
|
||||||
https://download.docker.com/linux/debian \
|
|
||||||
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
|
|
||||||
RUN apt-get update && apt-get install -y docker-ce-cli
|
|
||||||
|
|
||||||
RUN wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
|
|
||||||
RUN echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/hashicorp.list
|
|
||||||
RUN apt update && apt install terraform -y
|
|
||||||
|
|
||||||
USER jenkins
|
|
||||||
RUN jenkins-plugin-cli --plugins "blueocean:1.25.3 docker-workflow:1.28"
|
|
||||||
32
README.md
32
README.md
|
|
@ -1,34 +1,14 @@
|
||||||
# Local Jenkins Setup
|
# k3s and Application Installer
|
||||||
|
|
||||||
Creates a Jenkins image and launches a local Jenkins container for pipeline development
|
Installs k3s and a application on target machine.
|
||||||
|
For now only application ```sock_shop``` is supported.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
```
|
```
|
||||||
docker build -t jenkins-blueocean:2.332.3-1 .
|
./setup.sh -a sock_shop
|
||||||
```
|
```
|
||||||
|
|
||||||
Create network
|
Help:
|
||||||
```
|
```
|
||||||
docker network create jenkins
|
./setup.sh -h
|
||||||
```
|
|
||||||
|
|
||||||
Run the container:
|
|
||||||
```
|
|
||||||
docker run --name jenkins-blueocean --restart=on-failure --detach \
|
|
||||||
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
|
|
||||||
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
|
|
||||||
--publish 8080:8080 --publish 50000:50000 \
|
|
||||||
--volume jenkins-data:/var/jenkins_home \
|
|
||||||
--volume jenkins-docker-certs:/certs/client:ro \
|
|
||||||
jenkins-blueocean:2.332.3-1
|
|
||||||
```
|
|
||||||
|
|
||||||
Get Jenkins Password
|
|
||||||
```
|
|
||||||
docker exec jenkins-blueocean cat /var/jenkins_home/secrets/initialAdminPassword
|
|
||||||
```
|
|
||||||
|
|
||||||
Connect to Jenkins:
|
|
||||||
```
|
|
||||||
https://localhost:8080/
|
|
||||||
```
|
```
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
# Author : NTT Data AG
|
||||||
|
# Date : 11-05-2023
|
||||||
|
|
||||||
|
|
||||||
|
# update resources
|
||||||
|
function update {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# install necessary packages
|
||||||
|
function install_resources {
|
||||||
|
sudo dnf install -y container-selinux
|
||||||
|
sudo dnf install -y https://rpm.rancher.io/k3s/stable/common/centos/8/noarch/k3s-selinux-1.2-2.el8.noarch.rpm
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# install k3s
|
||||||
|
# docs: https://docs.k3s.io/installation/configuration
|
||||||
|
function get_k3s {
|
||||||
|
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_SYMLINK="skip" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
|
||||||
|
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||||
|
k3s kubectl get pods -A
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# fetch helm resources
|
||||||
|
# docs: https://helm.sh/docs/intro/install/
|
||||||
|
function install_helm {
|
||||||
|
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||||||
|
chmod 700 get_helm.sh
|
||||||
|
./get_helm.sh
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
git
|
||||||
|
https://www.liquidweb.com/kb/how-to-install-and-configure-git-on-fedora-22/#:~:text=1%20Introduction.%20Git%20is%20a%20widely%20adopted%2C%20distributed,for%20git.%20Using%20the%20%E2%80%93global%20option...%20More%20
|
||||||
|
|
||||||
|
sudo dnf -y update
|
||||||
|
sudo dnf -y install git
|
||||||
|
|
||||||
|
|
||||||
|
checkout sockshop
|
||||||
|
https://microservices-demo.github.io/deployment/kubernetes-start.html
|
||||||
|
|
||||||
|
git clone https://github.com/microservices-demo/microservices-demo.git
|
||||||
|
k3s kubectl create namespace sock-shop
|
||||||
|
k3s kubectl apply -f complete-demo.yaml
|
||||||
|
|
||||||
|
|
||||||
|
other
|
||||||
|
k3s kubectl get pods -n sock-shop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function get_k3s {
|
||||||
|
|
||||||
|
write_progress "Installing K3s (${K3SVERSION}) with NGINX instead of Traefik Ingress"
|
||||||
|
|
||||||
|
curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL="${K3SVERSION}" INSTALL_K3S_SYMLINK="skip" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# set the kubeconfig
|
||||||
|
|
||||||
|
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||||
|
|
||||||
|
kubectl get pods -A
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# install ingress nginx
|
||||||
|
|
||||||
|
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
|
||||||
|
|
||||||
|
helm repo update
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "####### EW "
|
||||||
|
|
||||||
|
helm install ingress-nginx ingress-nginx/ingress-nginx --version="${NGINX_INGRESS_VERSION}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# wait for nginx to be ready
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,128 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Author : NTT Data AG
|
||||||
|
# Date : 11-05-2023
|
||||||
|
|
||||||
|
helm_install=false
|
||||||
|
app_name=""
|
||||||
|
|
||||||
|
# fetch helm resources
|
||||||
|
# docs: https://helm.sh/docs/intro/install/
|
||||||
|
install_helm () {
|
||||||
|
# curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
|
||||||
|
# chmod 700 get_helm.sh
|
||||||
|
# ./get_helm.sh
|
||||||
|
echo "Helm not support yet."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# install resources
|
||||||
|
# TODO: check if this works
|
||||||
|
install_k3s () {
|
||||||
|
sudo dnf install -y container-selinux
|
||||||
|
sudo dnf install -y https://rpm.rancher.io/k3s/stable/common/centos/8/noarch/k3s-selinux-1.2-2.el8.noarch.rpm
|
||||||
|
|
||||||
|
get_k3s
|
||||||
|
}
|
||||||
|
|
||||||
|
# install k3s
|
||||||
|
# docs: https://docs.k3s.io/installation/configuration
|
||||||
|
get_k3s () {
|
||||||
|
sudo curl -sfL https://get.k3s.io | INSTALL_K3S_SYMLINK="skip" K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="--disable=traefik" sh -
|
||||||
|
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||||
|
kubectl get pods -A
|
||||||
|
}
|
||||||
|
|
||||||
|
# install git
|
||||||
|
install_git () {
|
||||||
|
sudo dnf -y update
|
||||||
|
sudo dnf -y install git
|
||||||
|
}
|
||||||
|
|
||||||
|
install_sock_shop () {
|
||||||
|
git clone https://github.com/microservices-demo/microservices-demo.git
|
||||||
|
cd microservices-demo/deploy/kubernetes
|
||||||
|
kubectl create namespace sock-shop
|
||||||
|
kubectl apply -f complete-demo.yaml
|
||||||
|
echo "Getting Pods from sock-shop namespace"
|
||||||
|
kubectl get pods -n sock-shop
|
||||||
|
# TODO: create check if list with pods returns and if they are ready
|
||||||
|
}
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $0 [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Show help information
|
||||||
|
-m, --helm Install Helm. Set flag when you want to install helm.
|
||||||
|
-a, --app <app_name> Specify the app name
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
show_allowed_apps () {
|
||||||
|
cat <<EOF
|
||||||
|
Supported apps:
|
||||||
|
- socks_shop
|
||||||
|
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
-h|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-m|--helm)
|
||||||
|
helm_install=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-a|--app)
|
||||||
|
if [ "$2" ]; then
|
||||||
|
app_name="$2"
|
||||||
|
shift 2
|
||||||
|
else
|
||||||
|
echo "Error: Missing argument for $1 option"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unrecognized option $1"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Validate app names
|
||||||
|
if [ -z "$app_name" ]; then
|
||||||
|
echo "Please specify app"
|
||||||
|
else
|
||||||
|
case $app_name in
|
||||||
|
"sock_shop")
|
||||||
|
echo "$app_name OK"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
show_allowed_apps
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if --helm was set
|
||||||
|
if [ "$helm_install" = true ]; then
|
||||||
|
install_helm
|
||||||
|
else
|
||||||
|
echo "Skipping helm"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Installing GIT"
|
||||||
|
install_git
|
||||||
|
|
||||||
|
echo "Installing K3S"
|
||||||
|
install_k3s
|
||||||
|
|
||||||
|
echo "Installing $app_name"
|
||||||
|
install_sock_shop
|
||||||
Loading…
Reference in New Issue