diff --git a/add-ons/rocketchat/README.md b/add-ons/rocketchat/README.md new file mode 100644 index 0000000..6c86601 --- /dev/null +++ b/add-ons/rocketchat/README.md @@ -0,0 +1,39 @@ + +# Rocket.Chat Add-on + +This addon install rocket.chat so that developer teams can have an privately-hosted http chat room + +## Prerequisites + +Start minishift with Openshift >= v3.7 and memory 4 GB or more + + +``` +git clone https://github.com/minishift/minishift-addon +cd minishift-addon/add-ons/rocketchat && export ROCKETCHAT=$pwd +minishift addon install $ROCKETCHAT +``` + +## Deploy Rocket.Chat + +To deploy rocket chat do: + +``` +$ minishift addon apply rocketchat --addon-env namespace=rocketchat +``` + +_NOTE_: namespace is a required environment variable for the add-on to run. Refer [addon-dynamic-variables](https://docs.openshift.org/latest/minishift/using/addons.html#addon-dynamic-variables) documentation. + +## Use Rocket.Chat +rocket chat will be available at: + +``` +$ minishift openshift service rocket-chat -n rocketchat +``` + +## Uninstall rocketchat +Delete rocketchat with: + +``` +$ oc delete project -n rocketchat --as=system:admin +``` diff --git a/add-ons/rocketchat/rocket-chat-ephemeral.json b/add-ons/rocketchat/rocket-chat-ephemeral.json new file mode 100644 index 0000000..dd25e87 --- /dev/null +++ b/add-ons/rocketchat/rocket-chat-ephemeral.json @@ -0,0 +1,443 @@ +{ + "kind": "Template", + "apiVersion": "v1", + "metadata": { + "name": "rocket-chat-ephemeral", + "annotations": { + "description": "Rocket.Chat with a MongoDB database running with an Ephemeral storage.", + "tags": "quickstart,nodejs,mongodb,instant-app", + "iconClass": "icon-nodejs" + } + }, + "objects": [ + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "mongodb", + "labels": { + "template": "mongodb-ephemeral-template" + } + }, + "spec": { + "strategy": { + "type": "Recreate", + "recreateParams": { + "timeoutSeconds": 600 + } + }, + "triggers": [ + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "mongodb" + ], + "from": { + "kind": "ImageStreamTag", + "namespace": "openshift", + "name": "mongodb:latest" + } + } + }, + { + "type": "ConfigChange" + } + ], + "replicas": 1, + "test": false, + "selector": { + "name": "mongodb" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "name": "mongodb" + } + }, + "spec": { + "volumes": [ + { + "name": "mongodb-data", + "emptyDir": {} + } + ], + "containers": [ + { + "name": "mongodb", + "image": "registry.access.redhat.com/rhscl/mongodb-26-rhel7:latest", + "ports": [ + { + "containerPort": 27017, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "MONGODB_USER", + "value": "${MONGODB_USER}" + }, + { + "name": "MONGODB_PASSWORD", + "value": "${MONGODB_PASSWORD}" + }, + { + "name": "MONGODB_DATABASE", + "value": "${MONGODB_DATABASE}" + }, + { + "name": "MONGODB_ADMIN_PASSWORD", + "value": "${MONGODB_ADMIN_PASSWORD}" + } + ], + "resources": { + "limits": { + "memory": "${MEMORY_LIMIT}" + } + }, + "volumeMounts": [ + { + "name": "mongodb-data", + "mountPath": "/var/lib/mongodb/data" + } + ], + "livenessProbe": { + "tcpSocket": { + "port": 27017 + }, + "initialDelaySeconds": 30, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "readinessProbe": { + "exec": { + "command": [ + "/bin/sh", + "-i", + "-c", + "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\"" + ] + }, + "initialDelaySeconds": 3, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "IfNotPresent", + "securityContext": { + "capabilities": {}, + "privileged": false + } + } + ], + "restartPolicy": "Always", + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "securityContext": {} + } + } + } + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat" + }, + "spec": { + "dockerImageRepository": "${ROCKETCHAT_IMAGE}", + "tags": [ + { + "name": "latest", + "annotations": { + "description": "Provides a Rocket.Chat application", + "iconClass": "icon-nodejs", + "tags": "rocketchat" + }, + "from": { + "kind": "ImageStreamTag", + "name": "latest" + }, + "generation": 1, + "importPolicy": {} + } + ] + } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat", + "creationTimestamp": null, + "labels": { + "app": "rocketchat" + }, + "annotations": { + "openshift.io/generated-by": "OpenShiftNewApp" + } + }, + "spec": { + "strategy": { + "type": "Rolling", + "rollingParams": { + "updatePeriodSeconds": 1, + "intervalSeconds": 1, + "timeoutSeconds": 600, + "maxUnavailable": "25%", + "maxSurge": "25%" + }, + "resources": {} + }, + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "rocketchat" + ], + "from": { + "kind": "ImageStreamTag", + "name": "rocketchat:latest" + } + } + } + ], + "replicas": 1, + "test": false, + "selector": { + "app": "rocketchat", + "deploymentconfig": "rocketchat" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app": "rocketchat", + "deploymentconfig": "rocketchat" + }, + "annotations": { + "openshift.io/container.rocketchat.image.entrypoint": "[\"node\",\"main.js\"]", + "openshift.io/generated-by": "OpenShiftNewApp" + } + }, + "spec": { + "volumes": [ + { + "name": "rocketchat-volume-1", + "emptyDir": {} + } + ], + "containers": [ + { + "name": "rocketchat", + "image": "${ROCKETCHAT_IMAGE}:latest", + "ports": [ + { + "containerPort": 3000, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "MONGO_URL", + "value": "mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@mongodb:27017/${MONGODB_DATABASE}" + } + ], + "resources": {}, + "volumeMounts": [ + { + "name": "rocketchat-volume-1", + "mountPath": "/app/uploads" + } + ], + "readinessProbe": { + "httpGet": { + "path": "/api/v1/info", + "port": 3000, + "scheme": "HTTP" + }, + "initialDelaySeconds": 5, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "livenessProbe": { + "httpGet": { + "path": "/api/v1/info", + "port": 3000, + "scheme": "HTTP" + }, + "initialDelaySeconds": 30, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "Always" + } + ], + "restartPolicy": "Always", + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "securityContext": {} + } + } + }, + "status": {} + }, + { + "kind": "Route", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat", + "creationTimestamp": null, + "labels": { + "app": "rocketchat" + }, + "annotations": { + "openshift.io/host.generated": "true" + } + }, + "spec": { + "to": { + "kind": "Service", + "name": "rocketchat" + }, + "port": { + "targetPort": "3000-tcp" + } + }, + "status": { + "ingress": null + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "mongodb", + "creationTimestamp": null, + "labels": { + "template": "mongodb-ephemeral-template" + } + }, + "spec": { + "ports": [ + { + "name": "mongo", + "protocol": "TCP", + "port": 27017, + "targetPort": 27017 + } + ], + "selector": { + "name": "mongodb" + }, + "type": "ClusterIP", + "sessionAffinity": "None" + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat", + "creationTimestamp": null, + "labels": { + "app": "rocketchat" + }, + "annotations": { + "openshift.io/generated-by": "OpenShiftNewApp" + } + }, + "spec": { + "ports": [ + { + "name": "3000-tcp", + "protocol": "TCP", + "port": 3000, + "targetPort": 3000 + } + ], + "selector": { + "app": "rocketchat", + "deploymentconfig": "rocketchat" + }, + "type": "ClusterIP", + "sessionAffinity": "None" + }, + "status": { + "loadBalancer": {} + } + } + ], + "parameters": [ + { + "name": "MEMORY_LIMIT", + "displayName": "Memory Limit", + "description": "Maximum amount of memory the container can use.", + "value": "512Mi" + }, + { + "name": "DATABASE_SERVICE_NAME", + "displayName": "Database Service Name", + "description": "The name of the OpenShift Service exposed for the database.", + "value": "mongodb", + "required": true + }, + { + "name": "MONGODB_USER", + "displayName": "MongoDB User", + "description": "Username for MongoDB user that will be used for accessing the database.", + "generate": "expression", + "from": "user[A-Z0-9]{3}", + "required": true + }, + { + "name": "MONGODB_PASSWORD", + "displayName": "MongoDB Password", + "description": "Password for the MongoDB user.", + "generate": "expression", + "from": "[a-zA-Z0-9]{16}", + "required": true + }, + { + "name": "MONGODB_DATABASE", + "displayName": "MongoDB Database Name", + "description": "Name of the MongoDB database accessed.", + "value": "rocketchatdb", + "required": true + }, + { + "name": "ROCKETCHAT_IMAGE", + "displayName": "RocketChat Image", + "description": "The RocketChat image to use for this deployment", + "required": true, + "value": "rocketchat/rocket.chat" + }, + { + "name": "MONGODB_ADMIN_PASSWORD", + "displayName": "MongoDB Admin Password", + "description": "Password for the database admin user.", + "generate": "expression", + "from": "[a-zA-Z0-9]{16}", + "required": true + } + ] +} diff --git a/add-ons/rocketchat/rocket-chat-persistent.json b/add-ons/rocketchat/rocket-chat-persistent.json new file mode 100644 index 0000000..fe2a992 --- /dev/null +++ b/add-ons/rocketchat/rocket-chat-persistent.json @@ -0,0 +1,470 @@ +{ + "kind": "Template", + "apiVersion": "v1", + "metadata": { + "name": "rocket-chat", + "annotations": { + "description": "Rocket.Chat with a MongoDB database running with a Persistent storage. Use this template if you want to run Rocket.Chat in production.", + "tags": "quickstart,nodejs,mongodb,instant-app", + "iconClass": "icon-nodejs" + } + }, + "objects": [ + { + "kind": "PersistentVolumeClaim", + "apiVersion": "v1", + "metadata": { + "name": "${DATABASE_SERVICE_NAME}" + }, + "spec": { + "accessModes": [ + "ReadWriteOnce" + ], + "resources": { + "requests": { + "storage": "${VOLUME_CAPACITY}" + } + } + } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "mongodb", + "labels": { + "template": "mongodb-persistent-template" + } + }, + "spec": { + "strategy": { + "type": "Recreate", + "recreateParams": { + "timeoutSeconds": 600 + } + }, + "triggers": [ + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "mongodb" + ], + "from": { + "kind": "ImageStreamTag", + "namespace": "openshift", + "name": "mongodb:latest" + } + } + }, + { + "type": "ConfigChange" + } + ], + "replicas": 1, + "test": false, + "selector": { + "name": "mongodb" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "name": "mongodb" + } + }, + "spec": { + "containers": [ + { + "name": "mongodb", + "image": "registry.access.redhat.com/rhscl/mongodb-26-rhel7:latest", + "ports": [ + { + "containerPort": 27017, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "MONGODB_USER", + "value": "${MONGODB_USER}" + }, + { + "name": "MONGODB_PASSWORD", + "value": "${MONGODB_PASSWORD}" + }, + { + "name": "MONGODB_DATABASE", + "value": "${MONGODB_DATABASE}" + }, + { + "name": "MONGODB_ADMIN_PASSWORD", + "value": "${MONGODB_ADMIN_PASSWORD}" + } + ], + "resources": { + "limits": { + "memory": "${MEMORY_LIMIT}" + } + }, + "volumeMounts": [ + { + "name": "mongodb-data", + "mountPath": "/var/lib/mongodb/data" + } + ], + "livenessProbe": { + "tcpSocket": { + "port": 27017 + }, + "initialDelaySeconds": 30, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "readinessProbe": { + "exec": { + "command": [ + "/bin/sh", + "-i", + "-c", + "mongo 127.0.0.1:27017/$MONGODB_DATABASE -u $MONGODB_USER -p $MONGODB_PASSWORD --eval=\"quit()\"" + ] + }, + "initialDelaySeconds": 3, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "IfNotPresent", + "securityContext": { + "capabilities": {}, + "privileged": false + } + } + ], + "volumes": [ + { + "name": "${DATABASE_SERVICE_NAME}-data", + "persistentVolumeClaim": { + "claimName": "${DATABASE_SERVICE_NAME}" + } + } + ], + "restartPolicy": "Always", + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "securityContext": {} + } + } + }, + "status": {} + }, + { + "kind": "ImageStream", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat" + }, + "spec": { + "dockerImageRepository": "${ROCKETCHAT_IMAGE}", + "tags": [ + { + "name": "latest", + "annotations": { + "description": "Provides a Rocket.Chat application", + "iconClass": "icon-nodejs", + "tags": "rocketchat" + }, + "from": { + "kind": "ImageStreamTag", + "name": "latest" + }, + "generation": 1, + "importPolicy": {} + } + ] + } + }, + { + "kind": "DeploymentConfig", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat", + "creationTimestamp": null, + "labels": { + "app": "rocketchat" + }, + "annotations": { + "openshift.io/generated-by": "OpenShiftNewApp" + } + }, + "spec": { + "strategy": { + "type": "Rolling", + "rollingParams": { + "updatePeriodSeconds": 1, + "intervalSeconds": 1, + "timeoutSeconds": 600, + "maxUnavailable": "25%", + "maxSurge": "25%" + }, + "resources": {} + }, + "triggers": [ + { + "type": "ConfigChange" + }, + { + "type": "ImageChange", + "imageChangeParams": { + "automatic": true, + "containerNames": [ + "rocketchat" + ], + "from": { + "kind": "ImageStreamTag", + "name": "rocketchat:latest" + } + } + } + ], + "replicas": 1, + "test": false, + "selector": { + "app": "rocketchat", + "deploymentconfig": "rocketchat" + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app": "rocketchat", + "deploymentconfig": "rocketchat" + }, + "annotations": { + "openshift.io/container.rocketchat.image.entrypoint": "[\"node\",\"main.js\"]", + "openshift.io/generated-by": "OpenShiftNewApp" + } + }, + "spec": { + "volumes": [ + { + "name": "rocketchat-volume-1", + "emptyDir": {} + } + ], + "containers": [ + { + "name": "rocketchat", + "image": "${ROCKETCHAT_IMAGE}:latest", + "ports": [ + { + "containerPort": 3000, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "MONGO_URL", + "value": "mongodb://${MONGODB_USER}:${MONGODB_PASSWORD}@mongodb:27017/${MONGODB_DATABASE}" + } + ], + "resources": {}, + "volumeMounts": [ + { + "name": "rocketchat-volume-1", + "mountPath": "/app/uploads" + } + ], + "readinessProbe": { + "httpGet": { + "path": "/api/v1/info", + "port": 3000, + "scheme": "HTTP" + }, + "initialDelaySeconds": 5, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "livenessProbe": { + "httpGet": { + "path": "/api/v1/info", + "port": 3000, + "scheme": "HTTP" + }, + "initialDelaySeconds": 30, + "timeoutSeconds": 1, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "terminationMessagePath": "/dev/termination-log", + "imagePullPolicy": "Always" + } + ], + "restartPolicy": "Always", + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "securityContext": {} + } + } + }, + "status": {} + }, + { + "kind": "Route", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat", + "creationTimestamp": null, + "labels": { + "app": "rocketchat" + }, + "annotations": { + "openshift.io/host.generated": "true" + } + }, + "spec": { + "to": { + "kind": "Service", + "name": "rocketchat" + }, + "port": { + "targetPort": "3000-tcp" + } + }, + "status": { + "ingress": null + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "mongodb", + "creationTimestamp": null, + "labels": { + "template": "mongodb-persistent-template" + } + }, + "spec": { + "ports": [ + { + "name": "mongo", + "protocol": "TCP", + "port": 27017, + "targetPort": 27017 + } + ], + "selector": { + "name": "mongodb" + }, + "type": "ClusterIP", + "sessionAffinity": "None" + }, + "status": { + "loadBalancer": {} + } + }, + { + "kind": "Service", + "apiVersion": "v1", + "metadata": { + "name": "rocketchat", + "creationTimestamp": null, + "labels": { + "app": "rocketchat" + }, + "annotations": { + "openshift.io/generated-by": "OpenShiftNewApp" + } + }, + "spec": { + "ports": [ + { + "name": "3000-tcp", + "protocol": "TCP", + "port": 3000, + "targetPort": 3000 + } + ], + "selector": { + "app": "rocketchat", + "deploymentconfig": "rocketchat" + }, + "type": "ClusterIP", + "sessionAffinity": "None" + }, + "status": { + "loadBalancer": {} + } + } + ], + "parameters": [ + { + "name": "MEMORY_LIMIT", + "displayName": "Memory Limit", + "description": "Maximum amount of memory the container can use.", + "value": "512Mi" + }, + { + "name": "DATABASE_SERVICE_NAME", + "displayName": "Database Service Name", + "description": "The name of the OpenShift Service exposed for the database.", + "value": "mongodb", + "required": true + }, + { + "name": "MONGODB_USER", + "displayName": "MongoDB User", + "description": "Username for MongoDB user that will be used for accessing the database.", + "generate": "expression", + "from": "user[A-Z0-9]{3}", + "required": true + }, + { + "name": "MONGODB_PASSWORD", + "displayName": "MongoDB Password", + "description": "Password for the MongoDB user.", + "generate": "expression", + "from": "[a-zA-Z0-9]{16}", + "required": true + }, + { + "name": "MONGODB_DATABASE", + "displayName": "MongoDB Database Name", + "description": "Name of the MongoDB database accessed.", + "value": "rocketchatdb", + "required": true + }, + { + "name": "MONGODB_ADMIN_PASSWORD", + "displayName": "MongoDB Admin Password", + "description": "Password for the database admin user.", + "generate": "expression", + "from": "[a-zA-Z0-9]{16}", + "required": true + }, + { + "name": "ROCKETCHAT_IMAGE", + "displayName": "RocketChat Image", + "description": "The RocketChat image to use for this deployment", + "required": true, + "value": "rocketchat/rocket.chat" + }, + { + "name": "VOLUME_CAPACITY", + "displayName": "Volume Capacity", + "description": "Volume space available for data, e.g. 512Mi, 2Gi.", + "value": "1Gi", + "required": true + } + ] +} diff --git a/add-ons/rocketchat/rocketchat.addon b/add-ons/rocketchat/rocketchat.addon new file mode 100644 index 0000000..8811613 --- /dev/null +++ b/add-ons/rocketchat/rocketchat.addon @@ -0,0 +1,10 @@ +# Name: rocketchat +# Description: This template creates a RocketChat namespace, app for the local cluster openshift +# Url: https://rocket.chat/ + +oc new-project rocketchat --description="RocketChat rooms for Dev Teams' privacy" + +oc create -f rocket-chat-ephemeral.json +oc create -f rocket-chat-persistent.json + +oc new-app rocket-chat -p MONGODB_DATABASE=rocketchat -p MONGODB_USER=rocketchat-admin -p MONGODB_PASSWORD=rocketchat