当前位置: 首页 > 工具软件 > ks-devops > 使用案例 >

K8S ks-jenkins重新安装

潘秦斩
2023-12-01

问题:K8S流水线突然打不开,报错404页面找不到,网上找了很久没处理,今天索性把ks-jenkins这个pod重新安装一下

kind: Deployment
apiVersion: apps/v1
metadata:
  name: ks-jenkins
  namespace: kubesphere-devops-system
  labels:
    app: ks-jenkins
  annotations:
    deployment.kubernetes.io/revision: '2'
    kubesphere.io/creator: admin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ks-jenkins
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: ks-jenkins
    spec:
      volumes:
        - name: casc-config
          configMap:
            name: jenkins-casc-config
            defaultMode: 420
        - name: jenkins-config
          configMap:
            name: ks-jenkins
            defaultMode: 420
        - name: secrets-dir
          emptyDir: {}
        - name: jenkins-home
          persistentVolumeClaim:
            claimName: ks-jenkins
        - name: host-time
          hostPath:
            path: /etc/localtime
            type: ''
      initContainers:
        - name: copy-default-config
          image: 'kubesphere/ks-jenkins:2.249.1'
          command:
            - sh
            - /var/jenkins_config/apply_config.sh
          env:
            - name: JENKINS_UC_DOWNLOAD
              value: 'http://uc-jenkins-update-center'
          resources:
            limits:
              cpu: '1'
              memory: 2Gi
            requests:
              cpu: 100m
              memory: 1500Mi
          volumeMounts:
            - name: jenkins-home
              mountPath: /var/jenkins_home
            - name: jenkins-config
              mountPath: /var/jenkins_config
            - name: secrets-dir
              mountPath: /usr/share/jenkins/ref/secrets/
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      containers:
        - name: ks-jenkins
          image: 'kubesphere/ks-jenkins:2.249.1'
          args:
            - '--argumentsRealm.passwd.$(ADMIN_USER)=$(ADMIN_PASSWORD)'
            - '--argumentsRealm.roles.$(ADMIN_USER)=admin'
          ports:
            - name: http
              containerPort: 8080
              protocol: TCP
            - name: slavelistener
              containerPort: 50000
              protocol: TCP
          env:
            - name: JAVA_TOOL_OPTIONS
              value: >-
                -Xms512m -Xmx512m -XX:MaxRAM=2g
                -Dhudson.slaves.NodeProvisioner.initialDelay=20
                -Dhudson.slaves.NodeProvisioner.MARGIN=50
                -Dhudson.slaves.NodeProvisioner.MARGIN0=0.85
                -Dhudson.model.LoadStatistics.clock=5000
                -Dhudson.model.LoadStatistics.decay=0.2
                -Dhudson.slaves.NodeProvisioner.recurrencePeriod=5000
                -Dio.jenkins.plugins.casc.ConfigurationAsCode.initialDelay=10000
                -verbose:gc -Xloggc:/var/jenkins_home/gc-%t.log
                -XX:NumberOfGCLogFiles=2 -XX:+UseGCLogFileRotation
                -XX:GCLogFileSize=100m -XX:+PrintGC -XX:+PrintGCDateStamps
                -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCCause
                -XX:+PrintTenuringDistribution -XX:+PrintReferenceGC
                -XX:+PrintAdaptiveSizePolicy -XX:+UseG1GC
                -XX:+UseStringDeduplication -XX:+ParallelRefProcEnabled
                -XX:+DisableExplicitGC -XX:+UnlockDiagnosticVMOptions
                -XX:+UnlockExperimentalVMOptions 
            - name: JENKINS_OPTS
            - name: ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: ks-jenkins
                  key: jenkins-admin-password
            - name: ADMIN_USER
              valueFrom:
                secretKeyRef:
                  name: ks-jenkins
                  key: jenkins-admin-user
            - name: CASC_JENKINS_CONFIG
              value: /var/jenkins_home/casc_configs/jenkins.yaml
            - name: com.sun.jndi.ldap.connect.timeout
              value: '15000'
            - name: com.sun.jndi.ldap.read.timeout
              value: '60000'
            - name: kubernetes.connection.timeout
              value: '60000'
            - name: kubernetes.request.timeout
              value: '60000'
            - name: EMAIL_SMTP_HOST
              value: mail.example.com
            - name: EMAIL_SMTP_PORT
              value: '465'
            - name: EMAIL_USE_SSL
              value: 'False'
            - name: EMAIL_FROM_NAME
              value: KubeSphere
            - name: EMAIL_FROM_ADDR
              value: admin@example.com
            - name: EMAIL_FROM_PASS
              value: P@ssw0rd
          resources:
            limits:
              cpu: '1'
              memory: 2Gi
            requests:
              cpu: 100m
              memory: 1500Mi
          volumeMounts:
            - name: casc-config
              readOnly: true
              mountPath: /var/jenkins_home/casc_configs
            - name: jenkins-home
              mountPath: /var/jenkins_home
            - name: jenkins-config
              readOnly: true
              mountPath: /var/jenkins_config
            - name: secrets-dir
              mountPath: /usr/share/jenkins/ref/secrets/
          livenessProbe:
            httpGet:
              path: /login
              port: http
              scheme: HTTP
            initialDelaySeconds: 90
            timeoutSeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 12
          readinessProbe:
            httpGet:
              path: /login
              port: http
              scheme: HTTP
            initialDelaySeconds: 60
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: ks-jenkins
      serviceAccount: ks-jenkins
      securityContext:
        runAsUser: 0
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

安装之后,访问jenkins的用户名 admin P@88w0rd

 类似资料: