sonarqube部署安装
postgres:11.6 sonarqube:9.0.0-community busybox:1.27.1
sonarqube7.9及以上使用postgres为数据库使用
PVC
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: sonar-mysql namespace: demo spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi storageClassName: nfs volumeMode: Filesystem
Deployment
kind: Deployment apiVersion: apps/v1 metadata: name: sonar-db namespace: demo labels: app: sonar-db name: sonar-db spec: replicas: 1 selector: matchLabels: app: sonar-db name: sonar-db template: metadata: labels: app: sonar-db name: sonar-db spec: volumes: - name: sonar-mysql persistentVolumeClaim: claimName: sonar-mysql containers: - name: postgres image: 'postgres:11.6' ports: - containerPort: 5432 protocol: TCP env: - name: POSTGRES_DB value: sonardb - name: POSTGRES_USER value: sonar - name: POSTGRES_PASSWORD value: sonar resources: limits: cpu: '1' memory: 2Gi requests: cpu: 800m memory: 2Gi volumeMounts: - name: sonar-mysql mountPath: /var/lib/postgresql/data imagePullPolicy: IfNotPresent restartPolicy: Always
Service
kind: Service apiVersion: v1 metadata: name: sonar-db namespace: demo labels: name: sonar-db spec: ports: - name: tcp-port-0 protocol: TCP port: 5432 targetPort: 5432 selector: name: sonar-db type: ClusterIP
PVC
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: sonar-data namespace: demo spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi storageClassName: nfs volumeMode: Filesystem --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: sonar-extensions namespace: demo spec: accessModes: - ReadWriteMany resources: requests: storage: 1Gi storageClassName: nfs volumeMode: Filesystem
Deployment
kind: Deployment apiVersion: apps/v1 metadata: name: sonarqube namespace: demo labels: app: sonarqube name: sonarqube spec: replicas: 1 selector: matchLabels: app: sonarqube name: sonarqube template: metadata: labels: app: sonarqube name: sonarqube spec: volumes: - name: sonar-extensions persistentVolumeClaim: claimName: sonar-extensions - name: sonar-data persistentVolumeClaim: claimName: sonar-data initContainers: - name: init-sysctl image: 'busybox:1.27.1' command: # elasticsearch用户拥有的内存权限太小,es启动会报错,此命令保证es正常启动 - sysctl - '-w' - vm.max_map_count=262144 ports: - containerPort: 80 protocol: TCP resources: limits: cpu: '1' memory: 2Gi requests: cpu: 800m memory: 2Gi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File imagePullPolicy: IfNotPresent securityContext: # 配置特权 privileged: true containers: - name: sonarqube image: 'sonarqube:9.0.0-community' ports: - containerPort: 9000 protocol: TCP env: - name: SONARQUBE_JDBC_USERNAME value: sonar - name: SONARQUBE_JDBC_PASSWORD value: sonar - name: SONARQUBE_JDBC_URL value: 'jdbc:postgresql://sonar-db.demo:5432/sonardb' resources: limits: cpu: '1' memory: 4Gi requests: cpu: 800m memory: 2Gi volumeMounts: - name: sonar-extensions mountPath: /opt/sonarqube/extensions - name: sonar-data mountPath: /opt/sonarqube/data readinessProbe: httpGet: path: / port: 9000 scheme: HTTP initialDelaySeconds: 240 timeoutSeconds: 5 periodSeconds: 5 successThreshold: 1 failureThreshold: 3 imagePullPolicy: IfNotPresent securityContext: privileged: false restartPolicy: Always
Service
kind: Service apiVersion: v1 metadata: name: sonarqube namespace: demo labels: name: sonarqube spec: ports: - name: tcp-port-0 protocol: TCP port: 9000 targetPort: 9000 selector: name: sonarqube type: ClusterIP|NodePort
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!