kubesphere 集成 sonar

文章目錄

  • 安裝 helm
  • 通過 helm 安裝 sonar
  • 配置 SonarQube 服務器
    • 創建 SonarQube 管理員令牌
    • SonarQube 配置添加到 ks-installer
    • 創建 Webhook 服務器
    • 將 SonarQube 服務器添加至 Jenkins
    • 將 sonarqubeURL 添加到 KubeSphere 控制臺
    • 重啟服務
  • 為新項目創建 SonarQube Token

官方文檔: 將 SonarQube 集成到流水線

安裝 helm

先安裝helm,可參考文章 CentOS7 安裝 helm

通過 helm 安裝 sonar

安裝命令

helm upgrade --install sonarqube sonarqube --repo https://charts.kubesphere.io/main -n kubesphere-devops-system  --create-namespace --set service.type=NodePort

安裝成功
在這里插入圖片描述

查看 SonarQube 的狀態

kubectl get pod -n kubesphere-devops-system

在這里插入圖片描述

輸出 sonar 訪問地址

export NODE_PORT=$(kubectl get --namespace kubesphere-devops-system -o jsonpath="{.spec.ports[0].nodePort}" services sonarqube-sonarqube)
export NODE_IP=$(kubectl get nodes --namespace kubesphere-devops-system -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT

在這里插入圖片描述

默認賬號:admin
默認密碼:admin

成功訪問,ip:32525
在這里插入圖片描述

?

配置 SonarQube 服務器

創建 SonarQube 管理員令牌

點擊右上角字母 A,然后從菜單中選擇 My Account 以轉到 Profile 頁面。
在這里插入圖片描述

點擊 Security 并輸入令牌名稱,例如 kubesphere
在這里插入圖片描述

復制 token 并保存好

SonarQube 配置添加到 ks-installer

編輯 ks-installer,或在自定義資源中搜索 ClusterConfiguration,點擊 ks-installer 右側的按鈕 ,選擇編輯 YAML

kubectl edit cc -n kubesphere-system ks-installer
  • externalSonarUrl:sonar 的訪問地址
  • externalSonarToken:上一步生成的 token
devops:enabled: truejenkinsJavaOpts_MaxRAM: 2gjenkinsJavaOpts_Xms: 512mjenkinsJavaOpts_Xmx: 512mjenkinsMemoryLim: 2GijenkinsMemoryReq: 1500MijenkinsVolumeSize: 8Gisonarqube: # Add this field manually.externalSonarUrl: http://10.xx.xx.xx:32525externalSonarToken: xxxxxx

檢查安裝過程

kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l 'app in (ks-install, ks-installer)' -o jsonpath='{.items[0].metadata.name}') -f

創建 Webhook 服務器

獲取 SonarQube Webhook 的地址。

export NODE_PORT=$(kubectl get --namespace kubesphere-devops-system -o jsonpath="{.spec.ports[0].nodePort}" services devops-jenkins)
export NODE_IP=$(kubectl get nodes --namespace kubesphere-devops-system -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/sonarqube-webhook/

在這里插入圖片描述

依次點擊 Administration、Configuration 和 Webhooks 創建一個 Webhook
在這里插入圖片描述

新建
在這里插入圖片描述

  • name:自定義
  • url:上面獲取的 Webhook

在這里插入圖片描述

將 SonarQube 服務器添加至 Jenkins

獲取 Jenkins 的地址

export NODE_PORT=$(kubectl get --namespace kubesphere-devops-system -o jsonpath="{.spec.ports[0].nodePort}" services devops-jenkins)
export NODE_IP=$(kubectl get nodes --namespace kubesphere-devops-system -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT

在這里插入圖片描述
默認賬號:admin
默認密碼:P@88w0rd

如果報錯

WARNING o.s.c.s.ResourceBundleMessageSource#getResourceBundle: ResourceBundle [org.acegisecurity.messages] not found for MessageSource: Can’t find bundle for base name org.acegisecurity.messages, locale en
WARNING o.a.p.l.a.BindAuthenticator2#handleBindException: Failed to bind to LDAP: userDnuid=admin,ou=Users,dc=kubesphere,dc=io username=admin
javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]

可以修改密碼,參考文章 KubeSphere3.0我在部署devops服務之后,jenkins無法使用ldap賬號登錄

kubectl patch users admin -p '{"spec":{"password":"Admin123456"}}' --type='merge' && kubectl annotate users admin iam.kubesphere.io/password-encrypted-

系統管理 - Manage Credentials - Jenkins - 全局憑據
在這里插入圖片描述

在這里插入圖片描述

Secret text - 全局 - 上面創建的 token
在這里插入圖片描述

點擊 系統管理 - 系統配置 - SonarQube servers - Add SonarQube - 選擇sonarqube

在這里插入圖片描述

將 sonarqubeURL 添加到 KubeSphere 控制臺

編輯 config

kubectl edit  cm -n kubesphere-system  ks-console-config

搜尋到 data.client.enableKubeConfig,在下方添加 devops 字段并指定 sonarqubeURL。
在這里插入圖片描述

重啟服務

kubectl -n kubesphere-devops-system rollout restart deploy devops-apiserver
kubectl -n kubesphere-system rollout restart deploy ks-console

為新項目創建 SonarQube Token

創建項目
在這里插入圖片描述
創建 token
在這里插入圖片描述

得到 mvn 發布命令
在這里插入圖片描述

執行命令
在這里插入圖片描述

成功發布到 sonar

在這里插入圖片描述

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/42841.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/42841.shtml
英文地址,請注明出處:http://en.pswp.cn/news/42841.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Threejs學習04——球緩沖幾何體環境光以及直線光源

實現隨機多個三角形隨機位置隨機顏色展示效果 這是一個非常簡單基礎的threejs的學習應用!本節主要學習的是球面緩沖幾何體在環境光合直線光源下的效果,可以學習到環境光和直線光源的生成效果等功能!主要使用的是球緩沖幾何體對象SphereGeome…

使用el-tree實現自定義樹結構樣式

實現效果: 直接上代碼: <template><div><div class"tops"><el-tree :default-expanded-keys"[1]" ref"myTree" :data"data" :props"defaultProps" node-click"handleNodeClick" highlight…

【uniapp】picker mode=“region“ 最簡單的省市區 三級聯動

省市區 picker template <picker mode"region" :value"date" class"u-w-440" change"bindTimeChange"><u--inputborder"bottom"class"u-fb u-f-s-28"placeholder"請選擇省市區"type"te…

第8章 對同步的硬件支持 摘錄

為了保證并行程序執行的正確性和高效性&#xff0c;構建一個共享存儲多處理器系統的硬件必須要解決緩存一致性、存儲一致性和同步原語的支持等問題。 被廣泛使用的同步原語包括鎖lock、柵欄barrier和點對點同步(signal和wait信號量)。舉例來說&#xff0c;鎖和柵欄被大量使用在…

ARM 作業1

一、思維導圖 二、 1. 2. .text 文本段 .globl _start 聲明_start:mov r0,#0mov r1,#0fun:cmp r1,#100bhi stopadd r0,r0,r1add r1,r1,#1b fun stop:b stop .end

C++函數模板和類模板

C另一種編程思想稱為泛型編程&#xff0c;主要利用的技術是模板 C提供兩種模板機制&#xff1a;函數模板和類模板 C提供了模板(template)編程的概念。所謂模板&#xff0c;實際上是建立一個通用函數或類&#xff0c; 其類內部的類型和函數的形參類型不具體指定&#xff0c; 用…

Axios使用CancelToken取消重復請求

處理重復請求&#xff1a;沒有響應完成的請求&#xff0c;再去請求一個相同的請求&#xff0c;會把之前的請求取消掉 新增一個cancelRequest.js文件 import axios from "axios" const cancelTokens {}export const addPending (config) > {const requestKey …

如何區分閏年與平年

首先要明白 地球繞太陽運行周期為365天5小時48分46秒&#xff08;合365.24219天&#xff09;&#xff0c;即一回歸年&#xff08;tropical year&#xff09;。公歷的平年只有365日&#xff0c;比回歸年短約0.2422 日&#xff0c;每四年累積約一天&#xff0c;把這一天加于2月末…

Docker安裝基礎使用練習

目錄 1、安裝Docker-CE 1&#xff09;簡單使用yum方式安裝 ! 2&#xff09;配置鏡像加速&#xff1a; 2、下載系統鏡像&#xff08;Ubuntu、 centos&#xff09; 1&#xff09;先查看我們所需的鏡像有哪些版本。使用search命令&#xff01; 2&#xff09;下載鏡像使用的是pul…

【爬蟲】P1 對目標網站的背景調研(robot.txt,advanced_search,builtwith,whois)

對目標網站的背景調研 檢查 robot.txt估算網站大小識別網站所用技術尋找網站的所有者 檢查 robot.txt 目的&#xff1a; 大多數的網站都會包含 robot.txt 文件。該文件用于指出使用爬蟲爬取網站時有哪些限制。而我們通過讀 robot.txt 文件&#xff0c;亦可以最小化爬蟲被封禁的…

vue中實現文字檢索時候將搜索內容標紅

實現結果 html&#xff1a; <div class"searchBox"><span class"bt">標&#8195&#8195題</span><div class"search"><div class"shuru"><!-- <span class"title">生產經營<…

[leetcode] 707 設計鏈表

707. 設L計鏈表 中等 902 相關企業 你可以選擇使用單鏈表或者雙鏈表&#xff0c;設計并實現自己的鏈表。 單鏈表中的節點應該具備兩個屬性&#xff1a;val 和 next 。val 是當前節點的值&#xff0c;next 是指向下一個節點的指針/引用。 如果是雙向鏈表&#xff0c;則還需…

如何批量修改圖片名為不同名稱

如何批量修改圖片名為不同名稱&#xff1f;當今社會&#xff0c;因為人們都養成了隨手拍照的習慣&#xff0c;所以擁有上千上萬張照片的相冊已經司空見慣不足為奇。然而&#xff0c;我們在保存這些照片時往往都會碰到一個大難題——電腦中的圖片名稱千奇百怪&#xff0c;讓整個…

C++并發多線程--std::async、std::packaged_task和std::promise的使用

目錄 1--std::async的使用 2--std::packaged_task的使用 3--std::promise的使用 1--std::async的使用 std::async用于啟動一個異步任務&#xff0c;并返回一個std::future對象&#xff1b;std::future對象里含有異步任務線程入口函數的結果&#xff1b; std::launch::deferr…

完美解決微信小程序使用復選框van-checkbox無法選中

由于小程序使用了vant-ui框架&#xff0c;導致checkbox點擊無法選中問題 <van-checkbox value"{{ checked }}" shape"square"><view class"check-content"><view class"checktext">我已閱讀并同意>《用戶協議》…

opencv-目標追蹤

import argparse import time import cv2 import numpy as np# 配置參數 ap argparse.ArgumentParser() ap.add_argument("-v", "--video", typestr,help"path to input video file") ap.add_argument("-t", "--tracker", …

第1天----驗證一個字符串是否是另一個字符串的子串

本文我們將學習如何去驗證一個字符串是否是另一個字符串的子串。 一、小試牛刀&#xff1a; 題目描述 輸入兩個字符串&#xff0c;驗證其中一個串是否為另一個串的子串。 輸入格式 兩行&#xff0c;每行一個字符串。 輸出格式 若第一個串 s 1 是第二個串 s 2 的子串&#xff0c…

java Spring Boot properties多環境配置拆分文件管理

上文 java Spring Boot yml多環境拆分文件管理優化 我們用yml 做了一個多環境配置文件的拆分管理 我們將 application.yml 改為 application.properties 參考代碼如下 spring.profiles.activedev我們知道 yml 是用 : 來區分高低基本 而 properties是直接通過 . 來表達 其他基本…

使用svd 分解的方法對神經網絡模型進行壓縮(能不能壓縮要看秩的大小)

參考和理論 壓縮原理代碼 import torch import numpy as np torch.manual_seed(0)# ------------------------------------ # n:輸入數據維度 # m:輸出數據維度 # ------------------------------------ n = 12 m = 10# ------------------------------------ # 隨機初始化權…

樹形組件淺知

別人寫好的輪子&#xff0c;會用即可 首先&#xff0c;需要安裝依賴&#xff0c;npm install --save riophae/vue-treeselect 如果使用npm 不行 那么就使用 yarn add --save riophae/vue-treeselect 然后在使用的地方引入即可 // import the componentimport Treeselect from…