diff --git a/jigsaw-payment-infra/k8s/sonar-mysql-rc.yaml b/jigsaw-payment-infra/k8s/sonar-mysql-rc.yaml new file mode 100644 index 0000000..d6143a7 --- /dev/null +++ b/jigsaw-payment-infra/k8s/sonar-mysql-rc.yaml @@ -0,0 +1,57 @@ +# +# Licensed to the Jigsaw Projects under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The Jigsaw Projects licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# 创建sonarqube的resource + +apiVersion: v1 +kind: ReplicationController +metadata: + name: sonar-mysql + namespace: sonar + labels: + name: mysql + context: ctpaas_staging_site +spec: + replicas: 1 + template: + metadata: + labels: + name: mysql + spec: + containers: + - name: mysql + image: docker.io/mysql + args: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci", "--max_allowed_packet=32M"] + env: + - name: TZ + value: 'Asia/Shanghai' + - name: LANG + value: 'C.UTF-8' + - name: MYSQL_ROOT_PASSWORD + value: 'zaq1XSW@' + - name: MYSQL_DATABASE + value: 'sonar' + ports: + - containerPort: 3306 + volumeMounts: + - mountPath: "/var/lib/sonar-mysql" + name: sonar-mysql-data-dir + volumes: + - name: sonar-mysql-data-dir + nfs: + server: kube-master.jigsaw + path: "/nfs_share/mysql/sonar_data" \ No newline at end of file diff --git a/jigsaw-payment-infra/k8s/sonar-mysql-svc.yaml b/jigsaw-payment-infra/k8s/sonar-mysql-svc.yaml new file mode 100644 index 0000000..efe8d91 --- /dev/null +++ b/jigsaw-payment-infra/k8s/sonar-mysql-svc.yaml @@ -0,0 +1,36 @@ +# +# Licensed to the Jigsaw Projects under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The Jigsaw Projects licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: v1 +kind: Service +metadata: + name: svc-mysql + namespace: sonar +spec: + ports: + - port: 3306 # the port that this service should serve on + # the container on each pod to connect to, can be a name + # (e.g. 'www') or a number (e.g. 80) + targetPort: 3306 + protocol: TCP + nodePort: 0 + # just like the selector in the replication controller, + # but this time it identifies the set of pods to load balance + # traffic to. + selector: + name: mysql + type: + NodePort \ No newline at end of file diff --git a/jigsaw-payment-infra/k8s/sonar-ns.yaml b/jigsaw-payment-infra/k8s/sonar-ns.yaml new file mode 100644 index 0000000..c48489a --- /dev/null +++ b/jigsaw-payment-infra/k8s/sonar-ns.yaml @@ -0,0 +1,23 @@ +# +# Licensed to the Jigsaw Projects under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The Jigsaw Projects licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# 创建sonarqube的namespace + +apiVersion: v1 +kind: Namespace +metadata: + name: sonar diff --git a/jigsaw-payment-infra/k8s/sonar-rc.yaml b/jigsaw-payment-infra/k8s/sonar-rc.yaml new file mode 100644 index 0000000..5342b4d --- /dev/null +++ b/jigsaw-payment-infra/k8s/sonar-rc.yaml @@ -0,0 +1,54 @@ +apiVersion: v1 +kind: ReplicationController +metadata: + name: sonar-rc + namespace: sonar + labels: + name: sonar +spec: + replicas: 1 + selector: + name: sonar + template: + metadata: + labels: + name: sonar + spec: + containers: + - name: sonar + image: docker.io/sonarqube + env: + - name: SONARQUBE_JDBC_USERNAME + value: sonar + - name: SONARQUBE_JDBC_PASSWORD + value: zaq1XSW@ + - name: SONARQUBE_JDBC_URL + value: 'jdbc:mysql://10.100.243.163:3306/sonar?useUnicode=true&characterEncoding=utf8' + ports: + - containerPort: 9000 + volumeMounts: + - mountPath: "/opt/sonarqube/conf" + name: sonar-conf + - mountPath: "/opt/sonarqube/data" + name: sonar-data + - mountPath: "/opt/sonarqube/extensions" + name: sonar-extensions + - mountPath: "/opt/sonarqube/logs" + name: sonar-logs + volumes: + - name: sonar-conf + nfs: + server: kube-master.jigsaw + path: "/nfs_share/sonar/conf" + - name: sonar-data + nfs: + server: kube-master.jigsaw + path: "/nfs_share/sonar/data" + - name: sonar-extensions + nfs: + server: kube-master.jigsaw + path: "/nfs_share/sonar/extensions" + - name: sonar-logs + nfs: + server: kube-master.jigsaw + path: "/nfs_share/sonar/logs" \ No newline at end of file diff --git a/jigsaw-payment-infra/k8s/sonar-svc.yaml b/jigsaw-payment-infra/k8s/sonar-svc.yaml new file mode 100644 index 0000000..5fe136f --- /dev/null +++ b/jigsaw-payment-infra/k8s/sonar-svc.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: sonar-svc + namespace: sonar +spec: + type: NodePort + ports: + - port: 9000 + protocol: TCP + nodePort: 0 + selector: + name: sonar \ No newline at end of file