在kubernetes上部署SonarQube
2020-04-21 本文已影响0人
橘子基因
此部署用到了外部存储,可自行手动创建pv和pvc或参考文章https://www.jianshu.com/p/1b9dbdc3d451
1. 部署postgresql
pvc.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pv-claim
annotations:
volume.beta.kubernetes.io/storage-class: "YourStrageClassName"
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-config
labels:
app: postgres
data:
POSTGRES_DB: postgresdb
POSTGRES_USER: postgresadmin
POSTGRES_PASSWORD: admin123
deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: postgres
spec:
replicas: 1
template:
metadata:
labels:
app: postgres
spec:
containers:
- name: postgres
image: postgres:latest
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: moe-postgres-config
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgredb
volumes:
- name: postgredb
persistentVolumeClaim:
claimName: postgres-pv-claim
cat service.yaml
apiVersion: v1
kind: Service
metadata:
name: postgres
labels:
app: postgres
spec:
type: NodePort
ports:
- port: 5432
selector:
app: postgres
2.部署SonarQube
cat sonarqube.yaml
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: sonarqube
spec:
replicas: 1
template:
metadata:
labels:
app: sonarqube
spec:
containers:
- name: sonarqube
image: sonarqube:7.9.1-community
ports:
- name: port1
containerPort: 9000
- name: port2
containerPort: 9092
env:
- name: SONARQUBE_JDBC_USERNAME
value: postgresadmin
- name: SONARQUBE_JDBC_PASSWORD
value: admin123
- name: SONARQUBE_JDBC_URL
value: jdbc:postgresql://postgres:5432/postgresdb
cat server.yaml
apiVersion: v1
kind: Service
metadata:
name: sonarqube
spec:
type: NodePort
ports:
- port: 9000
targetPort: 9000
nodePort: 30090
selector:
app: sonarqube
3. 浏览器访问ip:30090,默认密码和账户都是admin。
sonarqube.pnglogin.png