<返回更多

k8s-jenkins安装

2022-07-06    永远相信光的追蜂少年
加入收藏

1.创建namespace

apiVersion: v1

kind: Namespace

metadata:

name: jenkins

2.创建deployoment

apiVersion: Apps/v1

kind: Deployment

metadata:

name: jenkins

spec:

replicas: 1

selector:

matchLabels:

app: jenkins

template:

metadata:

labels:

app: jenkins

spec:

containers:

- name: jenkins

image: jenkins/jenkins:lts

ports:

- name: http-port

containerPort: 8080

- name: jnlp-port

containerPort: 50000

volumeMounts:

- name: ops-jenkins-data

mountPath: /var/jenkins_home

initContainers: ###因jenkins家目录权限需要对挂载的pvc进行权限修改

- args:

- -c

- chmod 755 /var/jenkins_home && chown 1000:1000 /var/jenkins_home

command:

- /bin/sh

image: centos

imagePullPolicy: IfNotPresent

name: chauth

securityContext:

privileged: true ### 建议开启特权模式

volumeMounts:

- mountPath: /var/jenkins_home ### initc也要对此数据卷进行挂载

name: ops-jenkins-data

volumes:

- name: ops-jenkins-data

persistentVolumeClaim:

claimName: ops-jenkins-data

3.创建针对jenkins相关的service,事例中只针对集群内部开放访问,如需要可以开启Nodeport、loadbalancer类型。

apiVersion: v1

kind: Service

metadata:

name: jenkins

spec:

type: ClusterIP

ports:

- port: 8080

targetPort: 8080

selector:

app: jenkins

---

apiVersion: v1

kind: Service

metadata:

name: jenkins-jnlp

spec:

type: ClusterIP

ports:

- port: 50000

targetPort: 50000

selector:

app: jenkins

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>