首页 > 其他分享 >k8s部署sonarqube

k8s部署sonarqube

时间:2023-05-25 14:45:44浏览次数:32  
标签:name 部署 sonarqube app sonar k8s data postgres

安装PGSql

apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-sonar
  labels:
    app: postgres-sonar
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres-sonar
  template:
    metadata:
      labels:
        app: postgres-sonar
    spec:
      containers:
      - name: postgres-sonar
        image: postgres:11.4
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5432
        env:
        - name: POSTGRES_DB
          value: "sonarDB"
        - name: POSTGRES_USER
          value: "sonarUser"
        - name: POSTGRES_PASSWORD 
          value: "123456"
        resources:
          limits:
            cpu: 1000m
            memory: 2048Mi
          requests:
            cpu: 500m
            memory: 1024Mi
        volumeMounts:
          - name: data
            mountPath: /var/lib/postgresql/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: postgres-data

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: postgres-data 
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: "gluster-heketi"
  resources:
    requests:
      storage: 1Gi

---
apiVersion: v1
kind: Service
metadata:
  name: postgres-sonar
  labels:
    app: postgres-sonar
spec:
  clusterIP: None
  ports:
  - port: 5432
    protocol: TCP
    targetPort: 5432
  selector:
    app: postgres-sonar

部署SonarQube

apiVersion: apps/v1
kind: Deployment
metadata:
  name: sonarqube
  labels:
    app: sonarqube
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sonarqube
  template:
    metadata:
      labels:
        app: sonarqube
    spec:
      initContainers:
      - name: init-sysctl
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      containers:
      - name: sonarqube
        image: sonarqube:lts
        ports:
        - containerPort: 9000
        env:
        - name: SONARQUBE_JDBC_USERNAME
          value: "sonarUser"
        - 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: 2048Mi
          requests:
            cpu: 1000m
            memory: 1024Mi
        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: PersistentVolumeClaim
metadata:
  name: sonarqube-data 
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: "gluster-heketi"
  resources:
    requests:
      storage: 10Gi

---
apiVersion: v1
kind: Service
metadata:
  name: sonarqube
  labels:
    app: sonarqube
spec:
  type: NodePort
  ports:
    - name: sonarqube
      port: 9000
      targetPort: 9000
      nodePort: 30003
      protocol: TCP
  selector:
    app: sonarqube

标签:name,部署,sonarqube,app,sonar,k8s,data,postgres
From: https://www.cnblogs.com/sunshinefly/p/17431139.html

相关文章

  • k8s部署grafana
    创建grafana.yamlapiVersion:v1kind:PersistentVolumeClaimmetadata:name:grafana-pvcnamespace:pro-wxspec:accessModes:-ReadWriteOnceresources:requests:storage:10GistorageClassName:openebs-hostpath---apiVersion:apps/......
  • tomcat 部署多个程序
    可以采取多tomcat的形式 将已有tomcat复制为tomcat2修改tomcat\conf\Catalina\localhost下的xml文件将docBase指向项目路径path和docBase同名<?xmlversion="1.0"encoding="UTF-8"?><Contextpath="/NXZNDATA"reloadable="false"doc......
  • k8s与数据分析--利用redash做自助数据分析
    前言通过数据分析和挖掘,让数据产生价值。一直以来我认为 devops 必须是一个闭环,即apm,日志,监控着三大系统的数据,必须经过分析对dev和ops有价值。数据可视化是大数据的『最后一公里』,做好可视化是对于数据分析是重要的。今天,主要介绍 redash 这款数据分析的利器。redash简介......
  • K8S异常之Unable to connect to the server: x509: certificate has expired or is n
    一、问题:k8s证书过期[root@nb001~]#kubectlgetnodeUnabletoconnecttotheserver:x509:certificatehasexpiredorisnotyetvalid:currenttime2022-12-10T10:26:21+08:00isafter2022-12-10T01:55:52Z 二、解决方案:2.1处理步骤#备份kubernetes配置......
  • 部署aws命令配置管理机以及部署eksctl管理eks
    AWS命令部署curl"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"-o"awscliv2.zip"unzipawscliv2.zipsudo./aws/installaws--versionawsconfigurecurl-Ohttps://s3.us-west-2.amazonaws.com/amazon-eks/1.26.2/2023-03-17/bin/linu......
  • K8s单master集群搭建
    (文章目录)集群搭建环境与配置:CentOS7.5系统,虚拟机2核4G内存50G硬盘主机名ip地址master192.168.10.144node1192.168.10.154node2192.168.10.155【若无特殊说明,以下操作默认都是在三台主机上同时进行】1.初始化集群环境一、配置ip、修改主机名ip最好使......
  • k8s Pod状态详解
    k8sPod状态详解在Kubernetes中,Pod是最小的可部署的计算单元,它是一组容器的集合,共享同一个网络命名空间、存储卷等资源。Kubernetes中的Pod有以下几种状态:Pending(挂起):Pod已经被KubernetesAPI接受,但它的容器镜像还没有被拉取,或者Pod所需的节点资源(CPU、内存等)还没......
  • k8s中 fpm 和 nginx 的文件共享问题
    目录引言docker镜像构建哲学为什么一定要共享文件代码的迭代更新问题引言初看这是一个值得记录的问题吗?或者说这算是一个问题吗?各种数据卷挂载,然后一顿操作不就完成了么?我也是这么认为的。看人讨论fpm与nginx的文件共享问题。想到自己当初也遇到了类似的困惑,记得当......
  • k8s-1.26.0 + Containerd安装过程
    1.前言Kubernetes社区早在2020年7月就开始着手移除dockershim,这将意味着Kubernetes不再将docker作为默认的底层容器工具,Docker和其他容器运行时将一视同仁,不会单独对待内置支持,如果我们还想直接使用Docker这种容器运行时应该怎么办呢?可以将dockershim的功能单独提取......
  • Appengine部署JPA
    GoogleAppEngineandJPA[url]http://www.vogella.com/blog/2011/01/10/google-app-engine-jpa/[/url]在googleappengine中使用JPA[url]http://www.1zhang.com/group/viewthread.php?tid=5188[/url]1.创建的时候,会自动增加jpa的jar.2.src/META-INF/p......