当前位置: 首页 > article >正文

kubernetes部署jenkins

参考:kubernetes 部署 Jenkins jenkins kubernetes pipeline_mob64ca14116c53的技术博客_51CTO博客

第七篇:kubernetes部署jenkins-CSDN博客

1、当前kubernetes集群已部署nfs服务

showmount -e

创建jenkins目录

2、添加jenkins的pvc

kubectl create namespace jenkins-k8s

cd /opt/dockerfile/jenkins/

touch jenkins-pv.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-k8s-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  nfs:
   server: 192.168.1.247
   path: /opt/nfsdata/jenkins

touch jeckins-pvc.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: jenkins-k8s-pvc
  namespace: jenkins-k8s
spec:
  resources:
    requests:
      storage: 10Gi
  accessModes:
    - ReadWriteMany

kubectl get pv -n jenkins-k8s

 创建一个sa账号,做rbac授权

kubectl create sa jenkins-k8s-sa -n jenkins-k8s

kubectl create clusterrolebinding jenkins-k8s-sa-cluster -n jenkins-k8s  --clusterrole=cluster-admin --serviceaccount=jenkins-k8s:jenkins-k8s-sa

2、部署 jenkins

kubectl apply -f jeckins-deploy.yaml

kind: Deployment
apiVersion: apps/v1
metadata:
  name: jenkins
  namespace: jenkins-k8s
spec:
  replicas: 1
  selector:
    matchLabels:
      app: jenkins
  template:
    metadata:
      labels:
        app: jenkins
    spec:
      serviceAccount: jenkins-k8s-sa
      containers:
      - name: jenkins
        image: jenkins/jenkins:lts
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8080
          name: web
          protocol: TCP
        - containerPort: 50000
          name: agent
          protocol: TCP
        resources:
          limits:
            cpu: 1000m
            memory: 1Gi
          requests:
            cpu: 500m
            memory: 512Mi
        livenessProbe:
          httpGet:
            path: /login
            port: 8080
          initialDelaySeconds: 60
          timeoutSeconds: 5
          failureThreshold: 12
        readinessProbe:
          httpGet:
            path: /login
            port: 8080
          initialDelaySeconds: 60
          timeoutSeconds: 5
          failureThreshold: 12
        volumeMounts:
        - name: jenkins-volume
          subPath: jenkins-home
          mountPath: /var/jenkins_home
      volumes:
      - name: jenkins-volume
        persistentVolumeClaim:
          claimName: jenkins-k8s-pvc

kubectl apply -f jeckins-deploy.yaml

kubectl describe pod jenkins-74bb6797d9-qd92c -n jenkins-k8s
 

kubectl logs pod jenkins-74bb6797d9-qd92c -c jenkins -n jenkins-k8s
没权限

chown -R 1000:1000 /opt/nfsdata/jenkins

kubectl delete -f jeckins-deploy.yaml

重装

kubectl apply -f jeckins-deploy.yaml

kubectl get pod -n jenkins-k8s  -owide

3、验证

kubectl get pod -n jenkins-k8s -owide

curl 10.100.27.19:8080

4、kubectl apply -f jenkins-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: jenkins-service
  namespace: jenkins-k8s
  labels:
    app: jenkins
spec:
  selector:
    app: jenkins
  type: NodePort
  ports:
  - name: web
    port: 8080
    targetPort: web
    nodePort: 30002
  - name: agent
    port: 50000
    targetPort: agent

kubectl get svc -n jenkins-k8s

cd /opt/nfsdata/jenkins/jenkins-home/secrets

若无法正常配置,可尝试http://192.168.1.12:30002/restart

安装推荐的插件:

创建用户名密码,搭建完成。

http://192.168.1.247:30002/


 


http://www.kler.cn/a/135520.html

相关文章:

  • vivo 游戏中心包体积优化方案与实践
  • 什么是数字图像?
  • Kafka - 启用安全通信和认证机制_SSL + SASL
  • 监控录音如何消除杂音?降低录音噪音的五个技巧
  • 使用HTML、CSS和JavaScript创建动态圣诞树
  • ubuntu20.04安装anaconda与基本使用
  • flink源码分析之功能组件(一)-metrics
  • openGauss学习笔记-128 openGauss 数据库管理-设置透明数据加密(TDE)
  • Hibernate 函数 ,子查询 和原生SQL查询
  • YOLOV8部署Android Studio安卓平台NCNN
  • Java Web——JS中的BOM
  • CISP模拟试题(三)
  • 前置语音群呼与语音机器人群呼哪个更好
  • python-opencv 培训课程笔记(1)
  • React整理总结(四)
  • LeetCode 面试题 16.25. LRU 缓存
  • js 对象数组删除某一个特定的对象
  • 达索系统3DEXPERIENCE云端设计新体验
  • CSS-表格属性(1)
  • docker数据卷详细讲解及数据卷常用命令
  • 【计算机视觉】24-Object Detection
  • Django 路由配置(二)
  • ESP32-BLE基础知识
  • 多态语法详解
  • URAT串口通信协议
  • 05_常用API