|
| 1 | +apiVersion: v1 |
| 2 | +kind: Template |
| 3 | +metadata: |
| 4 | + name: "sonarqube" |
| 5 | +objects: |
| 6 | +- apiVersion: v1 |
| 7 | + kind: ServiceAccount |
| 8 | + metadata: |
| 9 | + annotations: |
| 10 | + serviceaccounts.openshift.io/oauth-redirectreference.sonarqube: '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"${ROUTE_NAME}"}}' |
| 11 | + name: sonarqube |
| 12 | +- apiVersion: v1 |
| 13 | + kind: RoleBinding |
| 14 | + metadata: |
| 15 | + name: sonarqube_view |
| 16 | + roleRef: |
| 17 | + name: view |
| 18 | + subjects: |
| 19 | + - kind: ServiceAccount |
| 20 | + name: sonarqube |
| 21 | +- apiVersion: v1 |
| 22 | + kind: PersistentVolumeClaim |
| 23 | + metadata: |
| 24 | + name: sonarqube-data |
| 25 | + spec: |
| 26 | + accessModes: |
| 27 | + - ReadWriteOnce |
| 28 | + resources: |
| 29 | + requests: |
| 30 | + storage: ${SONARQUBE_PERSISTENT_VOLUME_SIZE} |
| 31 | + status: {} |
| 32 | +- apiVersion: v1 |
| 33 | + kind: ImageStream |
| 34 | + metadata: |
| 35 | + labels: |
| 36 | + name: "${NAME}" |
| 37 | + app: "${NAME}" |
| 38 | + name: "${NAME}" |
| 39 | + spec: |
| 40 | + tags: |
| 41 | + - annotations: |
| 42 | + openshift.io/imported-from: "${CONTAINER_IMAGE}" |
| 43 | + from: |
| 44 | + kind: DockerImage |
| 45 | + name: "${CONTAINER_IMAGE}" |
| 46 | + importPolicy: {} |
| 47 | + name: latest |
| 48 | + referencePolicy: |
| 49 | + type: Source |
| 50 | +- apiVersion: v1 |
| 51 | + kind: DeploymentConfig |
| 52 | + metadata: |
| 53 | + generation: 1 |
| 54 | + labels: |
| 55 | + app: sonarqube |
| 56 | + name: sonarqube |
| 57 | + spec: |
| 58 | + replicas: 1 |
| 59 | + selector: |
| 60 | + app: sonarqube |
| 61 | + deploymentconfig: sonarqube |
| 62 | + strategy: |
| 63 | + activeDeadlineSeconds: 21600 |
| 64 | + recreateParams: |
| 65 | + timeoutSeconds: 600 |
| 66 | + post: |
| 67 | + execNewPod: |
| 68 | + command: |
| 69 | + - /bin/sh |
| 70 | + - -c |
| 71 | + - sleep 30 && curl http://admin:admin@sonarqube:9000/api/webhooks/create |
| 72 | + -X POST -d "name=jenkins&url=${JENKINS_URL}/sonarqube-webhook/" |
| 73 | + containerName: sonarqube |
| 74 | + failurePolicy: Abort |
| 75 | + type: Recreate |
| 76 | + template: |
| 77 | + metadata: |
| 78 | + annotations: |
| 79 | + openshift.io/generated-by: OpenShiftWebConsole |
| 80 | + labels: |
| 81 | + app: sonarqube |
| 82 | + deploymentconfig: sonarqube |
| 83 | + spec: |
| 84 | + containers: |
| 85 | + - env: |
| 86 | + - name: JDBC_URL |
| 87 | + value: jdbc:postgresql://sonardb:5432/sonar |
| 88 | + - name: JDBC_USERNAME |
| 89 | + valueFrom: |
| 90 | + secretKeyRef: |
| 91 | + key: database-user |
| 92 | + name: sonardb |
| 93 | + - name: JDBC_PASSWORD |
| 94 | + valueFrom: |
| 95 | + secretKeyRef: |
| 96 | + key: database-password |
| 97 | + name: sonardb |
| 98 | + - name: FORCE_AUTHENTICATION |
| 99 | + value: "true" |
| 100 | + - name: PROXY_HOST |
| 101 | + value: ${PROXY_HOST} |
| 102 | + - name: PROXY_PORT |
| 103 | + value: ${PROXY_PORT} |
| 104 | + - name: PROXY_USER |
| 105 | + value: ${PROXY_USER} |
| 106 | + - name: PROXY_PASSWORD |
| 107 | + value: ${PROXY_PASSWORD} |
| 108 | + imagePullPolicy: Always |
| 109 | + livenessProbe: |
| 110 | + failureThreshold: 3 |
| 111 | + httpGet: |
| 112 | + path: / |
| 113 | + port: 9000 |
| 114 | + scheme: HTTP |
| 115 | + initialDelaySeconds: 45 |
| 116 | + periodSeconds: 10 |
| 117 | + successThreshold: 1 |
| 118 | + timeoutSeconds: 1 |
| 119 | + name: sonarqube |
| 120 | + ports: |
| 121 | + - containerPort: 9000 |
| 122 | + protocol: TCP |
| 123 | + readinessProbe: |
| 124 | + failureThreshold: 3 |
| 125 | + httpGet: |
| 126 | + path: / |
| 127 | + port: 9000 |
| 128 | + scheme: HTTP |
| 129 | + initialDelaySeconds: 10 |
| 130 | + periodSeconds: 10 |
| 131 | + successThreshold: 1 |
| 132 | + timeoutSeconds: 1 |
| 133 | + resources: {} |
| 134 | + terminationMessagePath: /dev/termination-log |
| 135 | + terminationMessagePolicy: File |
| 136 | + volumeMounts: |
| 137 | + - mountPath: /opt/sonarqube/data |
| 138 | + name: sonar-data |
| 139 | + dnsPolicy: ClusterFirst |
| 140 | + restartPolicy: Always |
| 141 | + schedulerName: default-scheduler |
| 142 | + securityContext: {} |
| 143 | + serviceAccount: sonarqube |
| 144 | + serviceAccountName: sonarqube |
| 145 | + terminationGracePeriodSeconds: 30 |
| 146 | + volumes: |
| 147 | + - name: sonar-data |
| 148 | + persistentVolumeClaim: |
| 149 | + claimName: sonarqube-data |
| 150 | + test: false |
| 151 | + triggers: |
| 152 | + - imageChangeParams: |
| 153 | + automatic: true |
| 154 | + containerNames: |
| 155 | + - sonarqube |
| 156 | + from: |
| 157 | + kind: ImageStreamTag |
| 158 | + name: sonarqube:latest |
| 159 | + type: ImageChange |
| 160 | + - type: ConfigChange |
| 161 | +- apiVersion: v1 |
| 162 | + kind: Route |
| 163 | + metadata: |
| 164 | + labels: |
| 165 | + app: sonarqube |
| 166 | + name: "${ROUTE_NAME}" |
| 167 | + spec: |
| 168 | + port: |
| 169 | + targetPort: 9000-tcp |
| 170 | + tls: |
| 171 | + termination: edge |
| 172 | + to: |
| 173 | + kind: Service |
| 174 | + name: sonarqube |
| 175 | + weight: 100 |
| 176 | + wildcardPolicy: None |
| 177 | +- apiVersion: v1 |
| 178 | + kind: Service |
| 179 | + metadata: |
| 180 | + labels: |
| 181 | + app: sonarqube |
| 182 | + name: sonarqube |
| 183 | + spec: |
| 184 | + ports: |
| 185 | + - name: 9000-tcp |
| 186 | + port: 9000 |
| 187 | + protocol: TCP |
| 188 | + targetPort: 9000 |
| 189 | + selector: |
| 190 | + deploymentconfig: sonarqube |
| 191 | + sessionAffinity: None |
| 192 | + type: ClusterIP |
| 193 | +parameters: |
| 194 | + - description: Database name for the Posgres Database to be used by Sonarqube |
| 195 | + displayName: Postgres database name |
| 196 | + name: POSTGRES_DATABASE_NAME |
| 197 | + value: sonar |
| 198 | + required: true |
| 199 | + - name: SONARQUBE_PERSISTENT_VOLUME_SIZE |
| 200 | + description: The persistent storage volume for SonarQube to use for plugins/config/logs/etc... |
| 201 | + displayName: SonarQube Storage Space Size |
| 202 | + required: true |
| 203 | + value: 5Gi |
| 204 | + - name: ROUTE_NAME |
| 205 | + value: sonarqube |
| 206 | + description: The name of the route for sonarqube |
| 207 | + displayName: SonarQube Route Name |
| 208 | + - name: SONAR_AUTOCREATE_USERS |
| 209 | + value: 'false' |
| 210 | + description: When using an external authentication system, should SonarQube automatically create accounts for users? |
| 211 | + displayName: Enable auto-creation of users from external authentication systems? |
| 212 | + required: true |
| 213 | + - name: PROXY_HOST |
| 214 | + description: Hostname of proxy server the SonarQube application should use to access the Internet |
| 215 | + displayName: Proxy server hostname/IP |
| 216 | + - name: PROXY_PORT |
| 217 | + description: TCP port of proxy server the SonarQube application should use to access the Internet |
| 218 | + displayName: Proxy server port |
| 219 | + - name: PROXY_USER |
| 220 | + description: Username credential when the Proxy Server requires authentication |
| 221 | + displayName: Proxy server username |
| 222 | + - name: PROXY_PASSWORD |
| 223 | + description: Password credential when the Proxy Server requires authentication |
| 224 | + displayName: Proxy server password |
| 225 | + - name: JENKINS_URL |
| 226 | + description: The Jenkins URL used for the webhook |
| 227 | + displayName: Jenkins URL |
| 228 | + value: http://jenkins |
| 229 | + - name: CONTAINER_IMAGE |
| 230 | + description: The Container Image to use for the ImageStream |
| 231 | + displayName: Nexus Container Image |
| 232 | + value: quay.io/mcanoy/labs-sonarqube:latest |
| 233 | + - name: NAME |
| 234 | + displayName: Name |
| 235 | + description: The name assigned to all objects and the resulting imagestream. |
| 236 | + required: true |
| 237 | + value: sonarqube |
0 commit comments