|
| 1 | +apiVersion: template.openshift.io/v1 |
| 2 | +kind: Template |
| 3 | +metadata: |
| 4 | + name: prometheus-test |
| 5 | + annotations: |
| 6 | + "openshift.io/display-name": Prometheus |
| 7 | + description: | |
| 8 | + Creates two resources that are part of different groups with no overlapping groupversions. |
| 9 | + Used to test `new-app` versioned output when dealing with lists of varying objects. |
| 10 | + iconClass: icon-cogs |
| 11 | + tags: "monitoring,prometheus, alertmanager,time-series" |
| 12 | +parameters: |
| 13 | +- description: The namespace to instantiate prometheus under. Defaults to 'kube-system'. |
| 14 | + name: NAMESPACE |
| 15 | + value: kube-system |
| 16 | +- description: The location of the proxy image |
| 17 | + name: IMAGE_PROXY |
| 18 | + value: openshift/oauth-proxy:v1.0.0 |
| 19 | +- description: The location of the prometheus image |
| 20 | + name: IMAGE_PROMETHEUS |
| 21 | + value: openshift/prometheus:v2.0.0-dev |
| 22 | +- description: The location of the alertmanager image |
| 23 | + name: IMAGE_ALERTMANAGER |
| 24 | + # TODO: Change to official openshift build |
| 25 | + value: openshift/prometheus-alertmanager:dev |
| 26 | +- description: The location of alert-buffer image |
| 27 | + name: IMAGE_ALERT_BUFFER |
| 28 | + # TODO: change to official openshift build |
| 29 | + value: ilackarms/message-buffer |
| 30 | +- description: The session secret for the proxy |
| 31 | + name: SESSION_SECRET |
| 32 | + generate: expression |
| 33 | + from: "[a-zA-Z0-9]{43}" |
| 34 | +objects: |
| 35 | +- apiVersion: v1 |
| 36 | + kind: Secret |
| 37 | + metadata: |
| 38 | + name: prometheus-proxy |
| 39 | + namespace: "${NAMESPACE}" |
| 40 | + stringData: |
| 41 | + session_secret: "${SESSION_SECRET}=" |
| 42 | +- apiVersion: extensions/v1beta1 |
| 43 | + kind: Deployment |
| 44 | + metadata: |
| 45 | + labels: |
| 46 | + app: prometheus |
| 47 | + name: prometheus |
| 48 | + namespace: "${NAMESPACE}" |
| 49 | + spec: |
| 50 | + replicas: 1 |
| 51 | + selector: |
| 52 | + matchLabels: |
| 53 | + app: prometheus |
| 54 | + template: |
| 55 | + metadata: |
| 56 | + labels: |
| 57 | + app: prometheus |
| 58 | + name: prometheus |
| 59 | + spec: |
| 60 | + serviceAccountName: prometheus |
| 61 | + containers: |
| 62 | + # Deploy Prometheus behind an oauth proxy |
| 63 | + - name: prom-proxy |
| 64 | + image: ${IMAGE_PROXY} |
| 65 | + imagePullPolicy: IfNotPresent |
| 66 | + ports: |
| 67 | + - containerPort: 8443 |
| 68 | + name: web |
| 69 | + args: |
| 70 | + - -provider=openshift |
| 71 | + - -https-address=:8443 |
| 72 | + - -email-domain=* |
| 73 | + - -upstream=http://localhost:9090 |
| 74 | + - -client-id=system:serviceaccount:${NAMESPACE}:prometheus |
| 75 | + - '-openshift-sar={"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}' |
| 76 | + - '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "resourceName": "${NAMESPACE}", "namespace": "${NAMESPACE}"}}' |
| 77 | + - -tls-cert=/etc/tls/private/tls.crt |
| 78 | + - -tls-key=/etc/tls/private/tls.key |
| 79 | + - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token |
| 80 | + - -cookie-secret-file=/etc/proxy/secrets/session_secret |
| 81 | + - -skip-auth-regex=^/metrics |
| 82 | + volumeMounts: |
| 83 | + - mountPath: /etc/tls/private |
| 84 | + name: prometheus-tls |
| 85 | + - mountPath: /etc/proxy/secrets |
| 86 | + name: prometheus-secrets |
| 87 | + - mountPath: /prometheus |
| 88 | + name: prometheus-data |
| 89 | + |
| 90 | + - name: prometheus |
| 91 | + args: |
| 92 | + - --storage.tsdb.retention=6h |
| 93 | + - --config.file=/etc/prometheus/prometheus.yml |
| 94 | + - --web.listen-address=localhost:9090 |
| 95 | + image: ${IMAGE_PROMETHEUS} |
| 96 | + imagePullPolicy: IfNotPresent |
| 97 | + volumeMounts: |
| 98 | + - mountPath: /etc/prometheus |
| 99 | + name: prometheus-config |
| 100 | + - mountPath: /prometheus |
| 101 | + name: prometheus-data |
| 102 | + |
| 103 | + # Deploy alertmanager behind prometheus-alert-buffer behind an oauth proxy |
| 104 | + # use http port=4190 and https port=9943 to differ from prom-proxy |
| 105 | + - name: alerts-proxy |
| 106 | + image: ${IMAGE_PROXY} |
| 107 | + imagePullPolicy: IfNotPresent |
| 108 | + ports: |
| 109 | + - containerPort: 9443 |
| 110 | + name: web |
| 111 | + args: |
| 112 | + - -provider=openshift |
| 113 | + - -https-address=:9443 |
| 114 | + - -http-address=:4190 |
| 115 | + - -email-domain=* |
| 116 | + - -upstream=http://localhost:9099 |
| 117 | + - -client-id=system:serviceaccount:${NAMESPACE}:prometheus |
| 118 | + - '-openshift-sar={"resource": "namespaces", "verb": "get", "name": "${NAMESPACE}"}' |
| 119 | + - '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get", "name": "${NAMESPACE}"}}' |
| 120 | + - -tls-cert=/etc/tls/private/tls.crt |
| 121 | + - -tls-key=/etc/tls/private/tls.key |
| 122 | + - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token |
| 123 | + - -cookie-secret-file=/etc/proxy/secrets/session_secret |
| 124 | + volumeMounts: |
| 125 | + - mountPath: /etc/tls/private |
| 126 | + name: alerts-tls |
| 127 | + - mountPath: /etc/proxy/secrets |
| 128 | + name: alerts-secrets |
| 129 | + |
| 130 | + - name: alert-buffer |
| 131 | + args: |
| 132 | + - --storage-path=/alert-buffer/messages.db |
| 133 | + image: ${IMAGE_ALERT_BUFFER} |
| 134 | + imagePullPolicy: IfNotPresent |
| 135 | + volumeMounts: |
| 136 | + - mountPath: /alert-buffer |
| 137 | + name: alert-buffer-data |
| 138 | + ports: |
| 139 | + - containerPort: 9099 |
| 140 | + name: alert-buf |
| 141 | + |
| 142 | + - name: alertmanager |
| 143 | + args: |
| 144 | + - -config.file=/etc/alertmanager/alertmanager.yml |
| 145 | + image: ${IMAGE_ALERTMANAGER} |
| 146 | + imagePullPolicy: IfNotPresent |
| 147 | + ports: |
| 148 | + - containerPort: 9093 |
| 149 | + name: web |
| 150 | + volumeMounts: |
| 151 | + - mountPath: /etc/alertmanager |
| 152 | + name: alertmanager-config |
| 153 | + - mountPath: /alertmanager |
| 154 | + name: alertmanager-data |
| 155 | + |
| 156 | + restartPolicy: Always |
| 157 | + volumes: |
| 158 | + - name: prometheus-config |
| 159 | + configMap: |
| 160 | + defaultMode: 420 |
| 161 | + name: prometheus |
| 162 | + - name: prometheus-secrets |
| 163 | + secret: |
| 164 | + secretName: prometheus-proxy |
| 165 | + - name: prometheus-tls |
| 166 | + secret: |
| 167 | + secretName: prometheus-tls |
| 168 | + - name: prometheus-data |
| 169 | + emptyDir: {} |
| 170 | + - name: alertmanager-config |
| 171 | + configMap: |
| 172 | + defaultMode: 420 |
| 173 | + name: prometheus-alerts |
| 174 | + - name: alerts-secrets |
| 175 | + secret: |
| 176 | + secretName: alerts-proxy |
| 177 | + - name: alerts-tls |
| 178 | + secret: |
| 179 | + secretName: prometheus-alerts-tls |
| 180 | + - name: alertmanager-data |
| 181 | + emptyDir: {} |
| 182 | + - name: alert-buffer-data #TODO: make persistent |
| 183 | + emptyDir: {} |
| 184 | + |
0 commit comments