首页 > 其他分享 >k8s 快速部署 sonarqube 详解

k8s 快速部署 sonarqube 详解

时间:2024-10-19 14:10:04浏览次数:7  
标签:name sonarqube metadata 详解 sonar k8s data postgres

sonarqube

https://blog.csdn.net/li81562/article/details/139255900
https://www.jindouyun.cn/document/industry/details/184076

apiVersion: v1
kind: Namespace
metadata:
  name: sonar-ns
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
  namespace: sonar-ns
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    server: 10.0.2.11
    path: "/root/share/pg"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-data 
  namespace: sonar-ns
spec:
  accessModes:
    - ReadWriteOnce  #访问模式为RWO
  resources:
    requests:
      storage: 5Gi

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv2
  namespace: sonar-ns
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  nfs:
    server: 10.0.2.11
    path: "/root/share/sonar"

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: sonarqube-data
  namespace: sonar-ns
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-sonar
  namespace: sonar-ns
  labels:
    app: postgres-sonar
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres-sonar
  template:
    metadata:
      labels:
        app: postgres-sonar
    spec:
      containers:
      - name: postgres-sonar
        image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/bitnami/postgresql:16
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5432
        env:
        - name: POSTGRES_DB
          value: "sonarDB"  #数据库
        - name: POSTGRES_USER
          value: "sonar" #登录数据库的用户
        - name: POSTGRES_PASSWORD 
          value: "123456" #数据库密码
        resources:
          limits:
            cpu: 1000m
            memory: 2Gi
          requests:
            cpu: 500m
            memory: 1Gi
        volumeMounts:
          - name: data
            mountPath: /var/lib/postgresql/data
            subPath: data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: postgres-data
apiVersion: v1
kind: Service
metadata:
  name: postgres-sonar
  namespace: sonar-ns
  labels:
    app: postgres-sonar
spec:
  type: NodePort
  ports:
  - port: 5432
    protocol: TCP
    targetPort: 5432
    nodePort: 31000
  selector:
    app: postgres-sonar
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sonarqube
  namespace: sonar-ns
  labels:
    app: sonarqube
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sonarqube
  template:
    metadata:
      labels:
        app: sonarqube
    spec:
      initContainers:
      - name: init-sysctl
        image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/gcr.io/google-containers/busybox:1.27.2
        imagePullPolicy: IfNotPresent
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      containers:
      - name: sonarqube
        image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/sonarqube:lts-community
        ports:
        - containerPort: 9000
        env:
        - name: SONARQUBE_JDBC_USERNAME
          value: "sonar"
        - name: SONARQUBE_JDBC_PASSWORD
          value: "123456"
        - name: SONARQUBE_JDBC_URL
          value: "jdbc:postgresql://postgres-sonar:5432/sonarDB"
        livenessProbe:
          httpGet:
            path: /sessions/new
            port: 9000
          initialDelaySeconds: 60
          periodSeconds: 30
        readinessProbe:
          httpGet:
            path: /sessions/new
            port: 9000
          initialDelaySeconds: 60
          periodSeconds: 30
          failureThreshold: 6
        resources:
          limits:
            cpu: 2000m
            memory: 2Gi
          requests:
            cpu: 1000m
            memory: 2Gi
        volumeMounts:
        - mountPath: /opt/sonarqube/conf
          name: data
          subPath: conf
        - mountPath: /opt/sonarqube/data
          name: data
          subPath: data
        - mountPath: /opt/sonarqube/extensions
          name: data
          subPath: extensions
      volumes:
      - name: data
        persistentVolumeClaim:
          claimName: sonarqube-data
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sonarqube
  name: sonarqube
  namespace: sonar-ns
spec:
  internalTrafficPolicy: Cluster
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
  ports:
    - name: sonarqube
      port: 9000
      protocol: TCP
      targetPort: 19000
  selector:
    app: sonarqube
  sessionAffinity: None
  type: NodePort

consul

下载consul

https://developer.hashicorp.com/consul/install#windows

启动

consul agent -dev

访问

http://localhost:8500 

参考:

https://zhuanlan.zhihu.com/p/715754843
https://www.cnblogs.com/jruing/p/17434858.html

标签:name,sonarqube,metadata,详解,sonar,k8s,data,postgres
From: https://www.cnblogs.com/happyhuangjinjin/p/18475827

相关文章

  • java 调用 k8s 的 apiserver
    创建serviceaccountserviceaccount.yamlapiVersion:v1kind:ServiceAccountmetadata:name:myadminnamespace:default创建集群角色ClusterRoleclusterrole.yamlapiVersion:rbac.authorization.k8s.io/v1kind:ClusterRolemetadata:name:my-clusterrolerul......
  • Nuxt.js 应用中的 app:templatesGenerated 事件钩子详解
    title:Nuxt.js应用中的app:templatesGenerated事件钩子详解date:2024/10/19updated:2024/10/19author:cmdragonexcerpt:app:templatesGenerated是Nuxt.js的一个生命周期钩子,在模板编译到虚拟文件系统(VirtualFileSystem,VFS)之后被调用。这个钩子允许开发者在生......
  • ThreadLocal源码详解
    目录Thread、ThreadLocalMap、ThreadLocal关系ThreadLocal中的get、Set方法ThreadLocal内存泄露问题Thread、ThreadLocalMap、ThreadLocal关系从源码可以看出:Thread类中有成员变量ThreadLocalMap,ThreadLocalMap类中有成员变量Entry[]数组,每个Entry对象的key是Thread......
  • Java Spring详解 -- 看完超越99%的同行
    Spring的核心功能IOC(控制反转,依赖注入),AOP(面向切面的编程)IOC:我们在使用过程中不用关注于对象是怎么创建的,只用应用过去,sping自动帮我们完成注入,对象的创建,spring默认创建对象是单例,这样减少了频繁创建对象,让对象重复利用,所有的对象都是放在BeanFactory工厂的AOP:面向切面的编程,......
  • 【数据结构】分治算法经典: 快速排序详解
    快速排序(Quicksort)是一种高效的排序算法,最早由TonyHoare在1960年提出。它采用了分治(DivideandConquer)策略,平均时间复杂度为O(nlog......
  • sql注入盲注详解以及绕过waf方法
    盲注mysql函数普及exists():用于判度条件是否满足,满足返回True,否则返回Falseif(条件,为真返回的值,为假返回的值):根据条件真假返回指定的值length(string):计算出长度string可以是任何字符串字面量或者字段名。substr(string,子字符串开始的位置,要提取的子字符串长......
  • transformers 推理 Qwen2.5 等大模型技术细节详解(一)transformers 初始化和对象加载(
    上周收到一位网友的私信,希望老牛同学写一篇有关使用transformers框架推理大模型的技术细节的文章。老牛同学刚开始以为这类的文章网上应该会有很多,于是想着百度几篇质量稍高一点的回复这位网友。结果,老牛同学搜索后发现,类似文章确实不少,但是总觉得不太满意,要么细节深度不够,要么......
  • Visual Basic 开发环境语言超详细教程详解总结
    一、章节目录VisualBasic语言简介VisualBasic开发环境VisualBasic语法基础控制结构数组与集合过程与函数用户界面设计文件操作数据库访问学习VisualBasic的方法VisualBasic语言教程简介与总结二、各章节知识点总结VisualBasic语言简介VisualBasic(简称V......
  • Typora超详细教程学习总结界面与功能详解
    一、章节目录Typora简介Typora界面与功能Typora编辑技巧Typora主题与样式Typora与其他工具的配合学习Typora的方法Typora资源简介与总结二、各章节知识点总结Typora简介Typora是一款简洁高效的Markdown编辑器,支持实时预览,让用户在编辑文本的同时可以立即......
  • ARP协议超详细知识点详解入门攻略总结
    章节目录一、ARP协议概述二、ARP协议的工作原理三、ARP缓存及其管理四、ARP报文格式及类型五、ARP协议的应用场景六、ARP协议的安全性及防御措施七、如何学习ARP协议知识八、资源简介一、ARP协议概述重点详细内容知识点总结:ARP(AddressResolutionProtocol)地址解析协议......