One - click Deployment of Jenkins Based on K8S

Recently, due to project requirements, I organized the content of deploying Jenkins on K8S before and made a one - click deployment.

For detailed scripts and configurations, see [github](https://github.com/yexia553/k8s - app/tree/main/one - click - jenkins)

The following is the content of the readme.

One - click Deployment of Jenkins Based on EKS (K8S)


Deployment

Command example

1
2
3
4
5
6
7
8
9
10
11
$ ./common_template/deploy.sh --help
Usage:
Deploy jenkins server in eks
Need kubectl installed and admin permisson on current cluster
Parameters:
--namespace <namespace>
--efs <efs id>
--cert <path to tls cert file>
--key <path to tls key file>

./deploy.sh --namespace jenkins - stg --efs fs - d23e74d6 --cert /path/to/server.crt --key /path/to/server.key

Parameter description:
–namespace: the namespace in which you want to deploy the jenkins server
–efs: the efs id that Jenkins will use as the storageclass backend
–cert: the path of the https certificate
–key: the path of the key bound to the https certificate

Dependencies for one - click deployment:

  1. The efs csi driver should be deployed in advance.
  2. The ingress nginx controller should be available (service exposure is done through ingress nginx).

Remarks:
If you don’t need one - click deployment or some of the dependent conditions are not met, you can actually extract the parts you need from the template and convert them into yaml files. Just change the variables in the files to actual values.

Reference resources:
During the process of making this one - click deployment, I referred to the blog of the great master Yangming in many places. Here I only wrote about how to deploy Jenkins based on K8S, but did not explain its specific usage. You can refer to the master’s blog, which has a more detailed introduction. Here are the original links:

[CI/CD Based on Jenkins, Gitlab, Harbor, Helm and Kubernetes (Part 1)](https://www.qikqiak.com/post/complete - cicd - demonstrate - 1/)

[CI/CD Based on Jenkins, Gitlab, Harbor, Helm and Kubernetes (Part 2)](https://www.qikqiak.com/post/complete - cicd - demonstrate - 2/)

Several Configurations for Using EFS as Storage in EKS

  1. EFS CSI Installation
    Reference: https://docs.aws.amazon.com/eks/latest/userguide/efs - csi.html
    When using EFS as storage in EKS, you need to install the csi driver in EKS.
    Before creating the storageclass, you need to execute the following command to install the driver

    1
    kubectl apply -k "github.com/kubernetes - sigs/aws - efs - csi - driver/deploy/kubernetes/overlays/stable/ecr/?ref=release - 1.0"
  2. Create EFS, configure sg (security group), AZ and mount points
    Official guidance link:
    https://aws.amazon.com/cn/premiumsupport/knowledge - center/eks - persistent - storage/


K8S Pods HPA

This depends on the metrics server to collect the performance data of the cluster.
When configuring the –max parameter, it is necessary to consider that the sum of the computing resources required by the corresponding number of pods is less than 90% of the total resources of the EKS node (the remaining 10% is used for k8s itself for scheduling).

1
kubectl autoscale deployment <deployment name>--cpu - percent=75 --min = 1 --max = 5

Nginx Ingress IP and Path Access Control

https://blog.aliasmee.com/post/kubernetes - nginx - ingress - block - ip - whitelist/


Nginx Ingress Session Fixation

https://www.jianshu.com/p/ff0463ba7482
https://kaerser.github.io/2019/04/30/nginx - ingress%E9%85%8D%E7%BD%AE%E4%BC%9A%E8%AF%9D%E4%BF%9D%E6%8C%81/