{"id":17143150,"url":"https://github.com/debianmaster/microservices-on-openshift-old","last_synced_at":"2025-07-10T11:08:45.831Z","repository":{"id":84987617,"uuid":"53077040","full_name":"debianmaster/microservices-on-openshift-old","owner":"debianmaster","description":"This example is no longer in use , please use this instead https://github.com/debianmaster/microservices-on-openshift","archived":false,"fork":false,"pushed_at":"2016-03-30T23:58:03.000Z","size":21952,"stargazers_count":6,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-06T10:09:31.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/debianmaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-03-03T19:27:18.000Z","updated_at":"2025-01-06T05:52:37.000Z","dependencies_parsed_at":"2023-03-02T20:16:11.673Z","dependency_job_id":null,"html_url":"https://github.com/debianmaster/microservices-on-openshift-old","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/debianmaster/microservices-on-openshift-old","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Fmicroservices-on-openshift-old","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Fmicroservices-on-openshift-old/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Fmicroservices-on-openshift-old/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Fmicroservices-on-openshift-old/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/debianmaster","download_url":"https://codeload.github.com/debianmaster/microservices-on-openshift-old/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/debianmaster%2Fmicroservices-on-openshift-old/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264569444,"owners_count":23629602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T20:33:51.292Z","updated_at":"2025-07-10T11:08:45.825Z","avatar_url":"https://github.com/debianmaster.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"This repo demonstrates simple development and deployment of polyglot microservices on OpenShift V3.  The diagram below is the architecture of the application that is made up of three sample micro services. \n1. UserRegistration Backend: This microservices exposes REST APIs to register users, display user list etc. The code is written in NodeJS and it persists the data into a MongoDB database\n2. UserRegistration: This is frontend UI built using PHP. The job of this microservice is confined to creating web pages.\n3. Email Service: This is a generic email service that receives a request and sends an email. This code is written in Python. We will also add an email log (thinking of MySQL DB).\n\n![alt tag](https://raw.githubusercontent.com/debianmaster/microservices-on-openshift/master/Arch.jpeg)\n\n# \n## 0. Initial Setup\nCreate an OpenShift project where these microservices will be created for development purposes. As an example we are calling it msdev.\n```sh\noc new-project msdev\n```\n\nIf you wish to change the code, feel free to fork the code and use your git links instead.\n\n\nLet us create some environment variable that makes it easy to deal with some of the parameters we use in the subsequent commands\n```sh\nexport OSE_DOMAIN=\u003c\u003cyour apps domain name..ex: apps.osecloud.com\u003e \nexport OSE_PROJECT=\u003c\u003cyour openshift projectname. ex:msdev\u003e\n```\nEx:--   \n`$ export OSE_DOMAIN=apps.oseworkshop.sc.osecloud.com`  \n`$ export OSE_PROJECT=msdev`  \n\n## 1. Create the Email Micro Service\nThe below command creates a new application for email service. This code is written in Python and emails are archived in mysql. This service receives the email request and sends out the email.\n\n###### Create mysql backend   \n\n```sh\noc new-app -e MYSQL_USER='app_user',\\\nMYSQL_PASSWORD='password',\\\nMYSQL_DATABASE=microservices\\\n registry.access.redhat.com/openshift3/mysql-55-rhel7 --name='mysql'\n```\n\u003e Get into the mysql pod   \n\n\n```sh\n$ sleep 10 # wait till the mysql is pod is created\n$ oc rsh $(oc get pods | grep mysql | awk '{print $1}')    # rsh will ssh into the mysql pod\n$ mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -h $HOSTNAME $MYSQL_DATABASE   ##inside the pod \n```\n\u003e  Create schema and exit container\n\n```sql\ncreate table emails (from_add varchar(40), to_add varchar(40), subject varchar(40), body varchar(200), created_at date);   \n```\n```sh\n$ exit  # to exit from mysql prompt\n$ exit  # to exit from pod\n```\n\n###### Create email service  \n\n```sh\noc new-app --context-dir='python-email-api' \\\n  -e EMAIL_APPLICATION_DOMAIN=http://emailsvc:8080,\\\nMYSQL_USER='app_user',\\\nMYSQL_PASSWORD='password',\\\nMYSQL_DATABASE='microservices',\\\nMYSQL_SERVICE_HOST='MYSQL'\\\n  https://github.com/debianmaster/microservices-on-openshift.git \\\n  --name=emailsvc --image-stream='python:2.7'  -l microservice=emailsvc\n```\n\nAlthough we can expose this service using a URL, if we want this email service to be used by other applications over http using the command ``oc expose svc/python-email-api``, we are not doing it here as we intend to use this as an internal service. You will see in the next section that the User Registration service will use the internal service name ```emailsvc``` to send emails.\n\n## 2. Creating User Registration Backend Micro Service\nThis service contains two components. It has a database that saves the user data for which we are using MongoDB. It has business logic layer that exposes REST APIs to register a user, get userslist etc. This part of the application is written in NodeJS. We can deploy this microservice using one of the following two approaches. \n\nApproach 1\u003cbr\u003e\n1. Create a MongoDB database and expose it as an internal service\u003cbr\u003e\n2. Create a User Registration Service that talks to the database deployed in the previous step. We are going to name this as \"userregsvc\".\u003cbr\u003e\n\nApproach 2\nIf you want to create the whole microservice together we have provided a template that can be used to deploy the above two in a single step.\n\n### Using Approach 1\n1. Create a MongoDB database\n```sh\noc new-app -e MONGODB_USER=mongouser,MONGODB_PASSWORD=password,\\\nMONGODB_DATABASE=userdb,MONGODB_ADMIN_PASSWORD=password \\\n  registry.access.redhat.com/rhscl/mongodb-26-rhel7 --name mongodb -l microservice=userregsvc\n  \n```   \n\n2. Create the User Registration Service and expose the service so that we can use a URL to make calls to the REST APIs exposed by this service\n```sh\noc new-app -e EMAIL_APPLICATION_DOMAIN=http://emailsvc:8080,\\\nMONGODB_DATABASE=userdb,MONGODB_PASSWORD=password,\\\nMONGODB_USER=mongouser,DATABASE_SERVICE_NAME=mongodb \\\n--context-dir='nodejs-users-api' \\\nhttps://github.com/debianmaster/microservices-on-openshift.git --name='userregsvc' -l microservice=userregsvc\n\noc expose svc/userregsvc\n```\nNote that we are using internal emailsvc as the EMAIL_APPLICATION_DOMAIN\n\n### Using Approach 2\n\nDownload the template included at the root of this repository with name nodejs-mongodb-template. This has slight modifications to the default template/instant app supplied with OpenShift. We added APPLICATION_NAME so that you can choose the name you want and added the EMAIL_APPLICATION_DOMAIN parameter that supplies this environment variable to the User Registration service.\n\nNote: You can easily create this template after application is created using Approach 1.\n\n```sh\noc process -f nodejs-mongodb-template.json -v APPLICATION_NAME=userregsvc,SOURCE_REPOSITORY_URL=https://github.com/debianmaster/microservices-on-openshift.git,CONTEXT_DIR=nodejs-users-api,DATABASE_SERVICE_NAME=mongodb,DATABASE_USER=mongouser,DATABASE_PASSWORD=password,DATABASE_NAME=userdb,DATABASE_ADMIN_PASSWORD=password,EMAIL_APPLICATION_DOMAIN=http://emailsvc:8080 | oc create -f -\n```\n\n\n## 3. Create the frontend user registration application as a separate microservice \nThis microservice produces html+javascript to run in a browser and makes ajax calls to the backend User Registration service using REST APIs.\nNote that we are setting an environment variable for userregsvc to access the backend using REST APIs.\n\n```sh\noc new-app -e APPLICATION_DOMAIN=\"$OSE_PROJECT.$OSE_DOMAIN\" \\\n--context-dir='php-ui' https://github.com/debianmaster/microservices-on-openshift.git --name='userreg' -l microservice=userreg\n\noc expose svc/userreg\n```\nThe service exposed in the above step is our application front end. You can find the URL by running ```oc get route```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebianmaster%2Fmicroservices-on-openshift-old","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdebianmaster%2Fmicroservices-on-openshift-old","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdebianmaster%2Fmicroservices-on-openshift-old/lists"}