k8s 中部署Jenkins

  1. 创建namespace
yaml 复制代码
apiVersion: v1
kind: Namespace
metadata:
  name: jenkins
  1. 创建pv以及pvc
yaml 复制代码
kind: PersistentVolume
apiVersion: v1
metadata:
  name: jenkins-pv-volume
  namespace: jenkins
  labels:
    type: local
    app: jenkins
spec:
  #storageClassName: manual
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/home/ellis/k8s/Jenkins/jenkinsdata/vol"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jenkins-pv-claim
  namespace: jenkins
  labels:
    app: jenkins
spec:
  storageClassName: ""
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
---
kind: PersistentVolume
apiVersion: v1
metadata:
  name: jenkinshome-pv-volume
  namespace: jenkins
  labels:
    type: local
    app: jenkins
spec:
  #storageClassName: manual
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/home/ellis/k8s/Jenkins/jenkinsdata/home"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jenkinshome-pv-claim
  namespace: jenkins
  labels:
    app: jenkins
spec:
  storageClassName: ""
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 5Gi
  1. 创建deployment以及service
yaml 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jenkins
  namespace: 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
        env:
        - name: TZ
          value: "Asia/Shanghai"
        volumeMounts:
          - name: jenkins-vol
            mountPath: /var/jenkins_vol
          - name: jenkins-home
            mountPath: /var/jenkins_home
        resources:
          limits:
            cpu: 500m
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 2Gi
      volumes:
        - name: jenkins-vol
          persistentVolumeClaim:
            claimName: jenkins-pv-claim
        - name: jenkins-home
          persistentVolumeClaim:
            claimName: jenkinshome-pv-claim
---
apiVersion: v1
kind: Service
metadata:
  name: jenkins
  namespace: jenkins
spec:
  type: NodePort
  ports:
    - port: 8080
      targetPort: 8080
      nodePort: 30000
  selector:
    app: jenkins

---

apiVersion: v1
kind: Service
metadata:
  name: jenkins-jnlp
  namespace: jenkins
spec:
  type: ClusterIP
  ports:
    - port: 50000
      targetPort: 50000
  selector:
    app: jenkins
  1. 查看admin password
    拉到最下面查找password
yaml 复制代码
sudo kubectl logs pod/jenkins-d6fcdfdd6-hqqvd   -n jenkins   
  1. 访问http://ip:30000
  2. Windows安装java 21
  • 下载zip
  • 解压
  • 添加JAVA_HOME环境变量,例如D:\java21sdk\jdk-21.0.1
  • 添加PATH 例如 %JAVA_HOME%\bin;
  1. 配置添加Windows节点
    启动方式选择如下

跟着配置即可

相关推荐
陆鳐LuLu1 小时前
日志管理利器:基于 ELK 的日志收集、存储与可视化实战
运维·elk·jenkins
土豆沒加1 小时前
K8S的Dashboard登录及验证
云原生·容器·kubernetes
[奋斗不止]1 小时前
Jenkins 配置 Credentials 凭证
jenkins·jenkins 配置凭证
终端行者3 小时前
kubernetes1.28部署mysql5.7主从同步,使用Nfs制作持久卷存储,适用于centos7/9操作系统,
数据库·容器·kubernetes
寂夜了无痕8 小时前
k8s容器运行时环境选型指南
云原生·kubernetes·k8s运行时环境选择
[奋斗不止]10 小时前
Jenkins 构建 Unity 打包 .apk 同时生成 .aab
jenkins·jenkins 打包 .aab·jenkins导出aab·jenkisn 导出 apk
boy快快长大10 小时前
【Elasticsearch】同一台服务器部署集群
服务器·elasticsearch·jenkins
深情不及里子11 小时前
纯手工搭建整套CI/CD流水线指南
ci/cd·gitlab·jenkins·harbor
梁萌11 小时前
04-DevOps-安装并初始化Jenkins
运维·jenkins·devops
跳跳的向阳花12 小时前
06、ElasticStack系列,第六章:elasticsearch设置密码
大数据·elasticsearch·jenkins