# SonarQube 云环境部署
# Namespace
$ kubectl create namespace devops
# 部署
sonar-deployment.yml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sonar
namespace: devops
spec:
replicas: 1
selector:
matchLabels:
app: sonar
template:
metadata:
labels:
app: sonar
spec:
containers:
- name: sonar
image: 172.16.62.204:30085/puyuan/sonarqube:7.8-community
imagePullPolicy: Always
env:
- name: SONARQUBE_JDBC_USERNAME
value: root
- name: SONARQUBE_JDBC_PASSWORD
value: password
- name: SONARQUBE_JDBC_URL
value: jdbc:mysql://mysql:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
ports:
- containerPort: 9000
name: port
protocol: TCP
resources:
limits:
cpu: 1000m
memory: 2Gi
requests:
cpu: 1000m
memory: 2Gi
# 服务暴漏
sonar-svc.yml
---
apiVersion: v1
kind: Service
metadata:
name: sonar
namespace: devops
labels:
app: sonar
spec:
selector:
app: sonar
type: NodePort
ports:
- name: port
port: 9000
targetPort: port
nodePort: 30076