k8s部署sonarqube
安装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
所有的努力都值得期许,所有的梦想都应该灌溉!