K8s環境下安裝sonarqube整合jenkins
阿新 • • 發佈:2019-01-03
K8s環境下安裝sonarqube
官網下載映象地址:https://hub.docker.com/_/sonarqube
用6.7穩定版
一、安裝sonarqube
安裝環境:私有k8s(經過2次開發)
1、 為了資料的持久化,建立儲存掛載到/opt/sonarqube目錄下
docker run啟動映象,進入/opt/sonarqube將其壓縮打包拷貝拷貝出來,上傳至儲存中
2、 deployment.yaml檔案
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: kube-stable-sonarqube namespace: nanjing-jc-web spec: replicas: 1 template: metadata: labels: name: kube-stable-sonarqube spec: containers: - name: kube-stable-sonarqube image: 10.19.248.12:30100/staging/tool-sonarqube-jxy:1.0 env: - name: TZ value: Asia/Shanghai - name: SONARQUBE_JDBC_USERNAME value: bocom - name: SONARQUBE_JDBC_PASSWORD value: bocommysql - name: SONARQUBE_JDBC_URL value: "jdbc:mysql://tool-mysql.development.svc.cluster.local:31286/sonardb?useSSL=false&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance" ports: - containerPort: 9000 protocol: TCP volumeMounts: - name: stable-pv-sonarqube mountPath: /opt/sonarqube resources: limits: cpu: 1000m memory: 6000Mi requests: cpu: 500m memory: 5000Mi volumes: - name: stable-pv-sonarqube persistentVolumeClaim: claimName: stable-pv-sonarqube
3、 service.yaml檔案
apiVersion: v1 kind: Service metadata: name: kube-stable-sonarqube namespace: nanjing-jc-web labels: name: kube-stable-sonarqube spec: type: NodePort selector: name: kube-stable-sonarqube ports: - protocol: TCP targetPort: 9000 port: 9000 nodePort: 32196 name: web
4、 storage.yaml檔案
"apiVersion": "v1" "items": - "apiVersion": "v1" "kind": "Storage" "metadata": "name": "stable-pv-sonarqube" "namespace": "nanjing-jc-web" "spec": "accessModes": "ReadWriteOnce" "persisted": false "readOnly": false "resources": "requests": "storage": "10Gi" "type": "CephFS" "unshared": false "kind": "List"
5、 執行過程:先建立儲存storage,在建立pod和svc
二、配置jenkins
1、登入sonarqube頁面記錄下令牌
2、在jenkins的系統管理---->系統設定裡配置sonarqube資訊
輸入第一步儲存的令牌
3、在jenkins的系統管理---->全域性工具配置中新增sonarqube資訊
三、建立jenkins構建job
具體配置如下“
”
管道語法還有點問題沒調通