From 4009b10d224adcf65e17cc6ef734a808902bc099 Mon Sep 17 00:00:00 2001 From: Yik Teng Hie Date: Sun, 6 Nov 2022 22:00:58 +0800 Subject: [PATCH] windows jenkins slave agent setup --- jenkins/windows-slave-node.md | 28 +++++++++++++++++ k8s/README.md | 58 +++++++++++++++++++++++++++++++++-- 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 jenkins/windows-slave-node.md diff --git a/jenkins/windows-slave-node.md b/jenkins/windows-slave-node.md new file mode 100644 index 0000000..c30c1eb --- /dev/null +++ b/jenkins/windows-slave-node.md @@ -0,0 +1,28 @@ +# Setup Windows Slave node + +## Use case +- Windows Application build pipeline (Visual Studio C++ / C#) + +## Tools +- for installing jenkins agent as a windows service + - [Windows Service Wrapper](https://github.com/winsw/winsw) + - Alternative tool + - [nssm - Non-Sucking Service Manager](https://nssm.cc/) + - [Package Manager - Chocolatey](https://chocolatey.org/) + +## Windows +- Create a user 'jenkins' + +## Steps +- Create a jenkins slave node setup on jenkins server +- Install JDK 11 (Preferable the same version as Jenkins Master Version) +- Create a folder `C:\jenkins` +- Download `agent.jar` from jenkins server +- Run the agent using the `Windows Service Wrapper` as a Windows Service and log on as `jenkins` user profile +- Create a ssh key and update `rsa_id.pub` to git server to allow agent to clone from git repo + +# Setup Jenkins build to target windows slave node for build +- Create a build +- Set label to target the slave node +- Git clone to the node +- Run the windows build script on the node \ No newline at end of file diff --git a/k8s/README.md b/k8s/README.md index 9757b90..f9302e7 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -1,20 +1,74 @@ # Kubernetes -- minikube +- Terms + - pod : running container / instance. Normal a pod run a single container. However, a pod can also run more than one container + - node : virtual machine node + - cluster : private network cluster + - deployment : pod with auto scaling feature + - service : To use LoadBalancer feature. Thus, to allow pod accessible from localhost (before this all pod is only accessible within minikube) + - ClusterIP : IP adrress accessible within cluster only. NOT accessible from localhost + - ExternalIP : For actual cloud + - LoadBalancerIP : + + + +- minikube : single master-slave Kubernetes cluster setup ```shell $ minikube start drivers=kvm2 $ minikube status +# IP address of minikube +$ minikube ip + +# ssh into minikube +# ssh docker@ +# password : tcuser +$ minikube ssh + +# inside minikube +$ docker ps +$ docker exec -it sh ``` -- kubectl +- kubectl : Kubernetes CLI ```shell # create jenkins namespace $ kubectl create namespace jenkins # list existing namespaces $ kubectl get namespaces + +$ kubectl cluster-info + +$ kubectl get node + +$ kubectl get pods + +# run nginx docker image +$ kubectl run nginx --image=nginx +$ kubectl get pods +$ kubectl describe pod nginx + +# get pods container IP address +$ kubectl get pods -o wide + +$ kubectl delete pod nginx + +# deployment in order to do scaling +$ kubectl create deployment nginx-deployment --image=nginx +$ kubectl get deployments +$ kubectl get pods +$ kubectl describe deployment nginx-deployment +# show all running replicas +$ kubectl get pods -o wide + +# create a service, expose internal port 80 to external 8080 +$ kubectl expose deployment nginx-deployment --port=8080 --target-port=80 + +# get svc +$ kubectl get services + ``` - Port forwarding