1.k8s安装sonarqube 记录,三个配置文件搞上来
首先是创建postgre的PV PVC 配置文件,kubectl apply -f pvc-xxxxxx.yaml 这里的目的是让sonarqube的数据库postgresql 的数据持久化存储,不会因为pod删除而丢失,name 、path 可以自定义,这个type 还不太清楚具体的意义,貌似可有可无啊,后续尝试去掉进行部署
apiVersion: v1 kind: PersistentVolume metadata: name: postgres-data labels: type: local spec: storageClassName: manual capacity: storage: 10Gi accessModes: - ReadWriteMany hostPath: path: "/data/postgresql" --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: postgres-data spec: storageClassName: manual accessModes: - ReadWriteMany resources: requests: storage: 10Gi
2.k8s安装postgresql,kubectl apply -f postgres(文件名称).yaml
apiVersion: apps/v1 kind: Deployment metadata: name: postgres-sonar spec: replicas: 1 selector: matchLabels: app: postgres-sonar template: metadata: labels: app: postgres-sonar spec: containers: - name: postgres-sonar image: postgres:latest imagePullPolicy: IfNotPresent ports: - containerPort: 5432 env: - name: POSTGRES_DB value: "sonar" - name: POSTGRES_USER value: "sonar" - name: POSTGRES_PASSWORD value: "sonar" volumeMounts: - name: data mountPath: /var/lib/postgresql/data volumes: - name: data persistentVolumeClaim: claimName: postgres-data --- 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
3.k8s安装sonarqube,kubectl apply -f sonarqube(文件名称).yaml
apiVersion: apps/v1 kind: Deployment metadata: name: sonarqube spec: replicas: 1 selector: matchLabels: app: sonarqube template: metadata: labels: app: sonarqube spec: containers: - name: sonarqube image: sonarqube:k8s imagePullPolicy: IfNotPresent ports: - containerPort: 9000 env: - name: SONARQUBE_JDBC_USERNAME value: "sonar" - name: SONARQUBE_JDBC_PASSWORD value: "sonar" - name: SONARQUBE_JDBC_URL value: "jdbc:postgresql://postgres-sonar:5432/sonar" --- 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
注意:需要注意的地方就是SONARQUBE_JDBC_URL的配置,
jdbc:postgresql://postgres-sonar:5432/sonar postgres-sonar 是pg数据库的service 5432是端口 sonar是db 不要搞错
还有就是如果是半路移过来的镜像容易有问题,比如pg数据库数据丢失,sonarqube无法链接数据库等,建议使用新的镜像进行部署
常用命令查看现有的node,服务,pod,deployment,PV,pvc,svc,sc等等 kubectl get node pod service pv pvc sc svc depyloyment 查看具体的namespace需要加上-n 空间名 kubectl get po -n default 查看pod的详细信息 kubectl describe pod xxxxxpod 通过配置文件进行应用部署 kubectl apply -f XXXXXX.yaml 通过配置文件进行删除部署 kubectl delete -f XXXXXX.yaml
标签:name,sonarqube,metadata,sonar,k8s,安装,spec,postgres From: https://www.cnblogs.com/dkzou/p/17074430.html