Skip to content

OMD on OpenShift

{% embed url="https://labs.consol.de/omd/" %}

Based on:

{% embed url="https://github.com/ConSol/omd-labs-docker.git" %}

Prepare project

1
2
oc new-project monitoring
oc adm policy add-scc-to-user anyuid -z default

Deploy template

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
{
    "kind": "Template",
    "apiVersion": "v1",
    "metadata": {
        "name": "omd",
        "creationTimestamp": null,
        "annotations": {
            "description": "omd",
            "iconClass": "icon-tomcat",
            "tags": "tomcat,tomcat7,java,jboss,xpaas,autoscaling,omd",
            "version": "0.0.1"
        }
    },
    "objects": [
          {
              "kind": "ImageStream",
              "apiVersion": "v1",
              "metadata": {
                  "name": "${APPLICATION_NAME}",
                  "labels": {
                      "application": "${APPLICATION_NAME}"
                  }
              }
          },
          {
              "kind": "BuildConfig",
              "apiVersion": "v1",
              "metadata": {
                  "name": "${APPLICATION_NAME}",
                  "labels": {
                      "application": "${APPLICATION_NAME}"
                  }
              },
              "spec": {
                  "source": {
                      "type": "Git",
                      "git": {
                          "uri": "${SOURCE_REPOSITORY_URL}",
                          "ref": "${SOURCE_REPOSITORY_REF}"
                      },
                      "contextDir": "${CONTEXT_DIR}"
                  },
                  "strategy": {
                      "dockerStrategy": {},
                      "type": "Docker"
                  },
                "output": {
                    "to": {
                        "kind": "ImageStreamTag",
                        "name": "${APPLICATION_NAME}:latest"
                    }
                },
                "triggers": [
                    {
                        "type": "GitHub",
                        "github": {
                            "secret": "${GITHUB_WEBHOOK_SECRET}"
                        }
                    },
                    {
                        "type": "Generic",
                        "generic": {
                            "secret": "${GENERIC_WEBHOOK_SECRET}"
                        }
                    },
                    {
                        "type": "ImageChange",
                        "imageChange": {}
                    },
                    {
                        "type": "ConfigChange"
                    }
                ]
            }
        },
        {
            "kind": "Service",
            "apiVersion": "v1",
            "spec": {
                "ports": [
                    {
                        "name": "http",
                        "port": 80,
                        "targetPort": 80
                    },
                    {
                        "name": "https",
                        "port": 443,
                        "targetPort": 443
                    }
                ],
                "selector": {
                    "deploymentConfig": "${APPLICATION_NAME}"
                }
            },
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                },
                "annotations": {
                    "description": "The web server's https port."
                }
            }
        },
        {
            "kind": "Route",
            "apiVersion": "v1",
            "id": "${APPLICATION_NAME}-https",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                },
                "annotations": {
                    "description": "Route for application's https service."
                }
            },
            "spec": {
                "host": "${HOSTNAME_HTTPS}",
                "to": {
                    "kind": "Service",
                    "name": "${APPLICATION_NAME}"
                },
                "port": {
                    "targetPort": "https"
                },
                "tls": {
                    "termination": "passthrough"
                },
                "wildcardPolicy": "None"
            }
        },

        {
            "kind": "DeploymentConfig",
            "apiVersion": "v1",
            "metadata": {
                "name": "${APPLICATION_NAME}",
                "labels": {
                    "application": "${APPLICATION_NAME}"
                }
            },
            "spec": {
                "strategy": {
                    "type": "Recreate"
                },
                "triggers": [
                    {
                        "type": "ImageChange",
                        "imageChangeParams": {
                            "automatic": true,
                            "containerNames": [
                                "${APPLICATION_NAME}"
                            ],
                            "from": {
                                "kind": "ImageStream",
                                "name": "${APPLICATION_NAME}"
                            }
                        }
                    },
                    {
                        "type": "ConfigChange"
                    }
                ],
                "replicas": 1,
                "selector": {
                    "deploymentConfig": "${APPLICATION_NAME}"
                },
                "template": {
                    "metadata": {
                        "name": "${APPLICATION_NAME}",
                        "labels": {
                            "deploymentConfig": "${APPLICATION_NAME}",
                            "application": "${APPLICATION_NAME}"
                        }
                    },
                    "spec": {
                        "terminationGracePeriodSeconds": 60,
                        "containers": [
                            {
                                "name": "${APPLICATION_NAME}",
                                "image": "${APPLICATION_NAME}",
                                "securityContext": { "anyuid": true },
                                "imagePullPolicy": "Always",
                                "ports": [
                                    {
                                        "name": "https",
                                        "containerPort": 443,
                                        "protocol": "TCP"
                                    },
                                    {
                                        "name": "http",
                                        "containerPort": 80,
                                        "protocol": "TCP"
                                    },
                                    {
                                        "name": "ssh",
                                        "containerPort": 22,
                                        "protocol": "TCP"
                                    },
                                    {
                                        "name": "gearmand",
                                        "containerPort": 4730,
                                        "protocol": "TCP"
                                    },
                                    {
                                        "name": "nrpe",
                                        "containerPort": 5666,
                                        "protocol": "TCP"
                                    }
                                ]
                            }
                        ]
                    }
                }
            }
        }
    ],
    "parameters": [
        {
            "name": "APPLICATION_NAME",
            "description": "The name for the application.",
            "value": "omd",
            "required": true
        },
        {
            "name": "HOSTNAME_HTTPS",
            "description": "Custom hostname for https service route.  Leave blank for default hostname, e.g.: \u003capplication-name\u003e-\u003cproject\u003e.\u003cdefault-domain-suffix\u003e"
        },
        {
            "name": "SOURCE_REPOSITORY_URL",
            "description": "Git source URI for application",
            "value": "https://github.com/ConSol/omd-labs-docker.git",
            "required": true
        },
        {
            "name": "SOURCE_REPOSITORY_REF",
            "description": "Git branch/tag reference",
            "value": "usermod-github-204-docker-cloud"
        },
        {
            "name": "CONTEXT_DIR",
            "description": "Path within Git project to build; empty for root project directory.",
            "value": "omd-labs-centos"
        },
        {
            "name": "GITHUB_WEBHOOK_SECRET",
            "description": "GitHub trigger secret",
            "generate": "expression",
            "from": "[a-zA-Z0-9]{8}",
            "required": true
        },
        {
            "name": "GENERIC_WEBHOOK_SECRET",
            "description": "Generic build trigger secret",
            "generate": "expression",
            "from": "[a-zA-Z0-9]{8}",
            "required": true
        }
    ],
    "labels": {
        "template": "omd"
    }
}

Deploy OMD

1
oc process omd | oc create -f -

Last update: April 12, 2020