k8s helm安装jenkins

1、环境介绍

[root@master ~]# kubectl get node 
NAME     STATUS   ROLES                  AGE     VERSION
master   Ready    control-plane,master   6h38m   v1.20.5
node1    Ready    <none>                 6h38m   v1.20.5
node2    Ready    <none>                 6h38m   v1.20.5
[root@master ~]# kubectl get sc 
NAME                  PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
managed-nfs-storage   fuseim.pri/ifs   Delete          Immediate           true                   148m
[root@master ~]# helm  version
version.BuildInfo{Version:"v3.2.0", GitCommit:"e11b7ce3b12db2941e90399e874513fbd24bcb71", GitTreeState:"clean", GoVersion:"go1.13.10"}

2、添加阿里云chart仓库

helm repo add aliyuncs https://apphub.aliyuncs.com
  • 查看仓库
[root@master ~]# helm  repo list 
NAME          	URL                                                                      
rancher-stable	https://releases.rancher.com/server-charts/stable                        
incubator     	https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/
aliyuncs      	https://apphub.aliyuncs.com   

3、搜索jenkins

[root@master jenkins]# helm  search repo  jenkins
NAME                     	CHART VERSION	APP VERSION	DESCRIPTION                                       
aliyuncs/jenkins         	4.1.5        	2.204.2    	The leading open source automation server         
aliyuncs/jenkins-operator	0.3.0        	0.3.0      	A Helm chart for Kubernetes Jenkins Operator      
incubator/ack-jenkins    	2.205        	1.0        	Open source continuous integration server. It s...

4、下载helm包

[root@master ~]# helm pull aliyuncs/jenkins 
[root@master ~]# tar xf jenkins-4.1.5.tgz 
[root@master ~]# cd jenkins/
[root@master jenkins]# ll
total 48
-rwxr-xr-x 1 root root   416 Feb 18  2020 Chart.yaml
drwxr-xr-x 2 root root  4096 Mar 26 15:38 ci
-rwxr-xr-x 1 root root 17974 Feb 18  2020 README.md
drwxr-xr-x 2 root root  4096 Mar 26 15:38 templates
-rwxr-xr-x 1 root root  2789 Feb 18  2020 values.schema.json
-rwxr-xr-x 1 root root  8638 Mar 26 16:10 values.yaml

5、修改volume.yaml,添加storageClass

[root@master jenkins]# kubectl get sc
NAME                  PROVISIONER      RECLAIMPOLICY   VOLUMEBINDINGMODE   ALLOWVOLUMEEXPANSION   AGE
managed-nfs-storage   fuseim.pri/ifs   Delete          Immediate           true                   121m


[root@master jenkins]# grep persistence -A 20 values.yaml 
## Enable persistence using Persistent Volume Claims
## ref: http://kubernetes.io/docs/user-guide/persistent-volumes/
##
persistence:
  ## If true, use a Persistent Volume Claim, If false, use emptyDir
  ##
  enabled: true
  ## Persistent Volume Storage Class
  ## If defined, storageClassName: <storageClass>
  ## If set to "-", storageClassName: "", which disables dynamic provisioning
  ## If undefined (the default) or set to null, no storageClassName spec is
  ##   set, choosing the default provisioner.  (gp2 on AWS, standard on
  ##   GKE, AWS & OpenStack)
  ##
  storageClass: "managed-nfs-storage"   #添加内容
  ## Persistent Volume Claim annotations
  ##
  annotations:
  ## Persistent Volume Access Mode
  ##
  accessModes:
    - ReadWriteOnce
  ## Persistent Volume size
  ##

6、修复valume.yal,将svc由LoadBalancer改成clusterIP或nodePort

  • 我这为了方便,就改成nodePort
[root@master jenkins]# grep "service:" -A 20 values.yaml 
service:
  ## Service type
  ##
  type: NodePort
  ## HTTP port
  ##
  #port: 80
  ## HTTPS port
  ##
  #httpsPort: 443
  ## Specify the nodePort(s) value(s) for the LoadBalancer and NodePort service types.
  ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport
  ##
  nodePorts:
    http: "30180"
    https: "30143"
  ## Set the LoadBalancer service type to internal only.
  ## ref: https://kubernetes.io/docs/concepts/services-networking/service/#internal-load-balancer
  ##
  # loadBalancerIP:
  ## Provide any additional annotations which may be required. This can be used to

7、helm安装

[root@master jenkins]# helm install  jenkins   aliyuncs/jenkins  -f values.yaml 
NAME: jenkins
LAST DEPLOYED: Fri Mar 26 16:17:28 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
** Please be patient while the chart is being deployed **

1. Get the Jenkins URL by running:

  export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services jenkins)
  export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
  echo "Jenkins URL: http://$NODE_IP:$NODE_PORT/"

2. Login with the following credentials

  echo Username: user
  echo Password: $(kubectl get secret --namespace default jenkins -o jsonpath="{.data.jenkins-password}" | base64 --decode)

8、查看

[root@master jenkins]# kubectl get pvc 
NAME         STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS          AGE
jenkins      Bound    pvc-45d57390-589e-4cf5-9114-939163fa796c   8Gi        RWO            managed-nfs-storage   5s
test-claim   Bound    pvc-37e9c8f1-55c6-43be-b7a4-02609cdff372   1Mi        RWX            managed-nfs-storage   140m
[root@master jenkins]# kubectl get svc 
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
jenkins      NodePort    10.102.147.162   <none>        80:30180/TCP,443:30143/TCP   12s
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP                      6h35m
[root@master jenkins]# kubectl get deploy jenkins
NAME      READY   UP-TO-DATE   AVAILABLE   AGE
jenkins   1/1     1            1           113s
[root@master jenkins]# kubectl get pod |grep jenkins
jenkins-7bf88885b7-lkffk                  1/1     Running   0          2m1s

9、浏览器访问

image.png

posted @ 2021-03-26 16:28  巽逸  阅读(0)  评论(0编辑  收藏  举报  来源