├── 01-web.MD ├── 02-mongodb.MD ├── 03-catalogue.MD ├── 04-redis.MD ├── 05-user.MD ├── 06-cart.MD ├── 07-mysql.MD ├── 08-shipping.MD ├── 09-rabbitmq.MD ├── 10-payment.MD ├── 11-dispatch.MD ├── README.md ├── nginx.MD ├── proxy.jpg └── roboshop.jpg /01-web.MD: -------------------------------------------------------------------------------- 1 | # 01-WEB 2 | 3 | * The Web/Frontend is the service in RoboShop to serve the web content over Nginx. 4 | * This will have the web page for the web application. 5 | * Developer has chosen Nginx as a web server and thus we will install Nginx Web Server. 6 | 7 | Install Nginx 8 | ``` 9 | yum install nginx -y 10 | ``` 11 | 12 | Start & Enable Nginx service 13 | ``` 14 | systemctl enable nginx 15 | ``` 16 | ``` 17 | systemctl start nginx 18 | ``` 19 | 20 | Try to access the service once over the browser and ensure you get some default content. 21 | ``` 22 | http://:80 23 | ``` 24 | 25 | Remove the default content that web server is serving. 26 | 27 | ``` 28 | rm -rf /usr/share/nginx/html/* 29 | ``` 30 | 31 | Download the frontend content 32 | 33 | ``` 34 | curl -o /tmp/web.zip https://roboshop-builds.s3.amazonaws.com/web.zip 35 | ``` 36 | 37 | Extract the frontend content. 38 | 39 | ``` 40 | cd /usr/share/nginx/html 41 | ``` 42 | ``` 43 | unzip /tmp/web.zip 44 | ``` 45 | 46 | Try to access the nginx service once more over the browser and ensure you get roboshop content. 47 | 48 | Create Nginx Reverse Proxy Configuration. 49 | 50 | ``` 51 | vim /etc/nginx/default.d/roboshop.conf 52 | ``` 53 | 54 | Add the following content 55 | ``` 56 | vim /etc/nginx/default.d/roboshop.conf 57 | ``` 58 | 59 | ``` 60 | proxy_http_version 1.1; 61 | location /images/ { 62 | expires 5s; 63 | root /usr/share/nginx/html; 64 | try_files $uri /images/placeholder.jpg; 65 | } 66 | location /api/catalogue/ { proxy_pass http://localhost:8080/; } 67 | location /api/user/ { proxy_pass http://localhost:8080/; } 68 | location /api/cart/ { proxy_pass http://localhost:8080/; } 69 | location /api/shipping/ { proxy_pass http://localhost:8080/; } 70 | location /api/payment/ { proxy_pass http://localhost:8080/; } 71 | 72 | location /health { 73 | stub_status on; 74 | access_log off; 75 | } 76 | ``` 77 | 78 | Ensure you replace the `localhost` with the actual ip address of those component server. Word `localhost` is just used to avoid the failures on the Nginx Server. 79 | 80 | Restart Nginx Service to load the changes of the configuration. 81 | 82 | ``` 83 | systemctl restart nginx 84 | ``` -------------------------------------------------------------------------------- /02-mongodb.MD: -------------------------------------------------------------------------------- 1 | ### MongoDB 2 | * Developer has chosen the database MongoDB. 3 | * Hence, we are trying to install it up and configure it.
4 | **NOTE: Versions of the DB Software you will get context from the developer, Meaning we need to check with developer. Developer has shared the version information as MongoDB-4.x** 5 | 6 | Setup the MongoDB repo file 7 | ``` 8 | vim /etc/yum.repos.d/mongo.repo 9 | ``` 10 | ``` 11 | [mongodb-org-4.2] 12 | name=MongoDB Repository 13 | baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ 14 | gpgcheck=0 15 | enabled=1 16 | ``` 17 | 18 | Install MongoDB 19 | ``` 20 | yum install mongodb-org -y 21 | ``` 22 | 23 | Start & Enable MongoDB Service 24 | 25 | ``` 26 | systemctl enable mongod 27 | ``` 28 | ``` 29 | systemctl start mongod 30 | ``` 31 | 32 | Usually MongoDB opens the port only to localhost(127.0.0.1), meaning this service can be accessed by the application that is hosted on this server only. However, we need to access this service to be accessed by another server(remote server), So we need to change the config accordingly. 33 | 34 | Update listen address from 127.0.0.1 to 0.0.0.0 in /etc/mongod.conf 35 | 36 | You can edit file by using 37 | ``` 38 | vim /etc/mongod.conf 39 | ``` 40 | 41 | Restart the service 42 | ``` 43 | systemctl restart mongod 44 | ``` -------------------------------------------------------------------------------- /03-catalogue.MD: -------------------------------------------------------------------------------- 1 | ### Catalogue 2 | Catalogue is a microservice that is responsible for serving the list of products that displays in roboshop application. 3 | 4 | Setup NodeJS repos. Vendor is providing a script to setup the repos. 5 | 6 | ``` 7 | curl -sL https://rpm.nodesource.com/setup_lts.x | bash 8 | ``` 9 | 10 | Install NodeJS 11 | 12 | ``` 13 | yum install nodejs -y 14 | ``` 15 | 16 | Configure the application. 17 | 18 | Our application developed by the developer of our company and it is not having any RPM software just like other softwares. So we need to configure every step manually 19 | 20 | Add application User 21 | 22 | ``` 23 | useradd roboshop 24 | ``` 25 | 26 | User roboshop is a function / daemon user to run the application. Apart from that we don't use this user to login to server. 27 | 28 | Also, username roboshop has been picked because it more suits to our project name. 29 | 30 | We keep application in one standard location. This is a usual practice that runs in the organization. 31 | 32 | Lets setup an app directory. 33 | 34 | ``` 35 | mkdir /app 36 | ``` 37 | 38 | Download the application code to created app directory. 39 | 40 | ``` 41 | curl -o /tmp/catalogue.zip https://roboshop-builds.s3.amazonaws.com/catalogue.zip 42 | ``` 43 | ``` 44 | cd /app 45 | ``` 46 | ``` 47 | unzip /tmp/catalogue.zip 48 | ``` 49 | 50 | Every application is developed by development team will have some common softwares that they use as libraries. This application also have the same way of defined dependencies in the application configuration. 51 | 52 | Lets download the dependencies. 53 | 54 | ``` 55 | cd /app 56 | ``` 57 | ``` 58 | npm install 59 | ``` 60 | 61 | We need to setup a new service in systemd so systemctl can manage this service 62 | 63 | Setup SystemD Catalogue Service 64 | 65 | ``` 66 | vim /etc/systemd/system/catalogue.service 67 | ``` 68 | 69 | ``` 70 | [Unit] 71 | Description = Catalogue Service 72 | 73 | [Service] 74 | User=roboshop 75 | Environment=MONGO=true 76 | Environment=MONGO_URL="mongodb://:27017/catalogue" 77 | ExecStart=/bin/node /app/server.js 78 | SyslogIdentifier=catalogue 79 | 80 | [Install] 81 | WantedBy=multi-user.target 82 | ``` 83 | 84 | Load the service. 85 | 86 | ``` 87 | systemctl daemon-reload 88 | ``` 89 | 90 | Start the service. 91 | 92 | ``` 93 | systemctl enable catalogue 94 | ``` 95 | ``` 96 | systemctl start catalogue 97 | ``` 98 | 99 | * For the application to work fully functional we need to load schema to the Database. 100 | * Schemas are usually part of application code and developer will provide them as part of development. 101 | 102 | 103 | We need to load the schema. To load schema we need to install mongodb client. 104 | 105 | To have it installed we can setup MongoDB repo and install mongodb-client 106 | 107 | ``` 108 | vim /etc/yum.repos.d/mongo.repo 109 | ``` 110 | 111 | ``` 112 | [mongodb-org-4.2] 113 | name=MongoDB Repository 114 | baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ 115 | gpgcheck=0 116 | enabled=1 117 | ``` 118 | ``` 119 | yum install mongodb-org-shell -y 120 | ``` 121 | 122 | Load Schema 123 | 124 | ``` 125 | mongo --host MONGODB-SERVER-IPADDRESS 68 | Environment=MONGO_URL="mongodb://:27017/users" 69 | ExecStart=/bin/node /app/server.js 70 | SyslogIdentifier=user 71 | 72 | [Install] 73 | WantedBy=multi-user.target 74 | ``` 75 | 76 | Load the service. 77 | 78 | ``` 79 | systemctl daemon-reload 80 | ``` 81 | 82 | ``` 83 | systemctl enable user 84 | ``` 85 | ``` 86 | systemctl start user 87 | ``` 88 | 89 | For the application to work fully functional we need to load schema to the Database. Then 90 | 91 | **NOTE: Schemas are usually part of application code and developer will provide them as part of development.** 92 | 93 | We need to load the schema. To load schema we need to install mongodb client. 94 | 95 | To have it installed we can setup MongoDB repo and install mongodb-client 96 | 97 | ``` 98 | vim /etc/yum.repos.d/mongo.repo 99 | ``` 100 | 101 | ``` 102 | [mongodb-org-4.2] 103 | name=MongoDB Repository 104 | baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ 105 | gpgcheck=0 106 | enabled=1 107 | ``` 108 | ``` 109 | yum install mongodb-org-shell -y 110 | ``` 111 | 112 | Load Schema 113 | 114 | ``` 115 | mongo --host MONGODB-SERVER-IPADDRESS 67 | Environment=CATALOGUE_HOST= 68 | Environment=CATALOGUE_PORT=8080 69 | ExecStart=/bin/node /app/server.js 70 | SyslogIdentifier=cart 71 | 72 | [Install] 73 | WantedBy=multi-user.target 74 | ``` 75 | 76 | Load the service. 77 | 78 | ``` 79 | systemctl daemon-reload 80 | ``` 81 | 82 | ``` 83 | systemctl enable cart 84 | ``` 85 | ``` 86 | systemctl start cart 87 | ``` -------------------------------------------------------------------------------- /07-mysql.MD: -------------------------------------------------------------------------------- 1 | ### MySQL 2 | Developer has chosen the database MySQL. Hence, we are trying to install it up and configure it. 3 | 4 | CentOS-8 Comes with MySQL 8 Version by default, However our application needs MySQL 5.7. So lets disable MySQL 8 version. 5 | 6 | ``` 7 | yum module disable mysql -y 8 | ``` 9 | 10 | Setup the MySQL5.7 repo file 11 | 12 | ``` 13 | vim /etc/yum.repos.d/mysql.repo 14 | ``` 15 | 16 | ``` 17 | [mysql] 18 | name=MySQL 5.7 Community Server 19 | baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ 20 | enabled=1 21 | gpgcheck=0 22 | ``` 23 | 24 | Install MySQL Server 25 | 26 | ``` 27 | yum install mysql-community-server -y 28 | ``` 29 | 30 | Start MySQL Service 31 | 32 | ``` 33 | systemctl enable mysqld 34 | ``` 35 | ``` 36 | systemctl start mysqld 37 | ``` 38 | 39 | Next, We need to change the default root password in order to start using the database service. Use password RoboShop@1 or any other as per your choice. 40 | 41 | ``` 42 | mysql_secure_installation --set-root-pass RoboShop@1 43 | ``` 44 | 45 | You can check the new password working or not using the following command in MySQL. 46 | 47 | ``` 48 | mysql -uroot -pRoboShop@1 49 | ``` -------------------------------------------------------------------------------- /08-shipping.MD: -------------------------------------------------------------------------------- 1 | ### Shipping 2 | 3 | Shipping service is responsible for finding the distance of the package to be shipped and calculate the price based on that. 4 | 5 | Shipping service is written in Java, Hence we need to install Java. 6 | 7 | Maven is a Java Packaging software, Hence we are going to install maven, This indeed takes care of java installation. 8 | 9 | ``` 10 | yum install maven -y 11 | ``` 12 | 13 | Configure the application. 14 | 15 | Add application User 16 | 17 | ``` 18 | useradd roboshop 19 | ``` 20 | 21 | Lets setup an app directory. 22 | 23 | ``` 24 | mkdir /app 25 | ``` 26 | 27 | Download the application code to created app directory. 28 | 29 | ``` 30 | curl -L -o /tmp/shipping.zip https://roboshop-builds.s3.amazonaws.com/shipping.zip 31 | ``` 32 | ``` 33 | cd /app 34 | ``` 35 | ``` 36 | unzip /tmp/shipping.zip 37 | ``` 38 | 39 | Every application is developed by development team will have some common softwares that they use as libraries. This application also have the same way of defined dependencies in the application configuration. 40 | 41 | Lets download the dependencies & build the application 42 | 43 | ``` 44 | cd /app 45 | ``` 46 | ``` 47 | mvn clean package 48 | ``` 49 | ``` 50 | mv target/shipping-1.0.jar shipping.jar 51 | ``` 52 | 53 | We need to setup a new service in systemd so systemctl can manage this service 54 | 55 | Setup SystemD Shipping Service 56 | 57 | ``` 58 | /etc/systemd/system/shipping.service 59 | ``` 60 | 61 | ``` 62 | [Unit] 63 | Description=Shipping Service 64 | 65 | [Service] 66 | User=roboshop 67 | Environment=CART_ENDPOINT=:8080 68 | Environment=DB_HOST= 69 | ExecStart=/bin/java -jar /app/shipping.jar 70 | SyslogIdentifier=shipping 71 | 72 | [Install] 73 | WantedBy=multi-user.target 74 | ``` 75 | 76 | Load the service. 77 | 78 | ``` 79 | systemctl daemon-reload 80 | ``` 81 | 82 | Start the service. 83 | 84 | ``` 85 | systemctl enable shipping 86 | ``` 87 | ``` 88 | systemctl start shipping 89 | ``` 90 | 91 | For this application to work fully functional we need to load schema to the Database. 92 | 93 | We need to load the schema. To load schema we need to install mysql client. 94 | 95 | To have it installed we can use 96 | 97 | ``` 98 | yum install mysql -y 99 | ``` 100 | 101 | Load Schema 102 | 103 | ``` 104 | mysql -h -uroot -pRoboShop@1 < /app/schema/shipping.sql 105 | ``` 106 | 107 | This service needs a restart because it is dependent on schema, After loading schema only it will work as expected, Hence we are restarting this service. This 108 | 109 | ``` 110 | systemctl restart shipping 111 | ``` -------------------------------------------------------------------------------- /09-rabbitmq.MD: -------------------------------------------------------------------------------- 1 | ### RabbitMQ 2 | 3 | RabbitMQ is a messaging Queue which is used by some components of the applications. 4 | 5 | Configure YUM Repos from the script provided by vendor. 6 | 7 | ``` 8 | curl -s https://packagecloud.io/install/repositories/rabbitmq/erlang/script.rpm.sh | bash 9 | ``` 10 | 11 | Configure YUM Repos for RabbitMQ. 12 | 13 | ``` 14 | curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.rpm.sh | bash 15 | ``` 16 | 17 | Install RabbitMQ 18 | 19 | ``` 20 | yum install rabbitmq-server -y 21 | ``` 22 | 23 | Start RabbitMQ Service 24 | 25 | ``` 26 | systemctl enable rabbitmq-server 27 | ``` 28 | 29 | ``` 30 | systemctl start rabbitmq-server 31 | ``` 32 | 33 | RabbitMQ comes with a default username / password as guest/guest. But this user cannot be used to connect. Hence, we need to create one user for the application. 34 | 35 | ``` 36 | rabbitmqctl add_user roboshop roboshop123 37 | ``` 38 | ``` 39 | rabbitmqctl set_permissions -p / roboshop ".*" ".*" ".*" 40 | ``` 41 | -------------------------------------------------------------------------------- /10-payment.MD: -------------------------------------------------------------------------------- 1 | ### Payment 2 | 3 | This service is responsible for payments in RoboShop e-commerce app. This service is written on Python 3.6, So need it to run this app. 4 | 5 | Install Python 3.6 6 | 7 | ``` 8 | yum install python36 gcc python3-devel -y 9 | ``` 10 | 11 | Configure the application. 12 | 13 | Add application User 14 | 15 | ``` 16 | useradd roboshop 17 | ``` 18 | 19 | Lets setup an app directory. 20 | 21 | ``` 22 | mkdir /app 23 | ``` 24 | 25 | Download the application code to created app directory. 26 | 27 | ``` 28 | curl -L -o /tmp/payment.zip https://roboshop-builds.s3.amazonaws.com/payment.zip 29 | ``` 30 | 31 | ``` 32 | cd /app 33 | ``` 34 | 35 | ``` 36 | unzip /tmp/payment.zip 37 | ``` 38 | 39 | Every application is developed by development team will have some common softwares that they use as libraries. This application also have the same way of defined dependencies in the application configuration. 40 | 41 | Lets download the dependencies. 42 | 43 | ``` 44 | cd /app 45 | ``` 46 | 47 | ``` 48 | pip3.6 install -r requirements.txt 49 | ``` 50 | 51 | We need to setup a new service in systemd so systemctl can manage this service 52 | 53 | Setup SystemD Payment Service 54 | 55 | ``` 56 | vim /etc/systemd/system/payment.service 57 | ``` 58 | 59 | ``` 60 | [Unit] 61 | Description=Payment Service 62 | 63 | [Service] 64 | User=root 65 | WorkingDirectory=/app 66 | Environment=CART_HOST= 67 | Environment=CART_PORT=8080 68 | Environment=USER_HOST= 69 | Environment=USER_PORT=8080 70 | Environment=AMQP_HOST= 71 | Environment=AMQP_USER=roboshop 72 | Environment=AMQP_PASS=roboshop123 73 | 74 | ExecStart=/usr/local/bin/uwsgi --ini payment.ini 75 | ExecStop=/bin/kill -9 $MAINPID 76 | SyslogIdentifier=payment 77 | 78 | [Install] 79 | WantedBy=multi-user.target 80 | ``` 81 | 82 | Load the service. 83 | 84 | ``` 85 | systemctl daemon-reload 86 | ``` 87 | 88 | Start the service. 89 | 90 | ``` 91 | systemctl enable payment 92 | ``` 93 | 94 | ``` 95 | systemctl start payment 96 | ``` -------------------------------------------------------------------------------- /11-dispatch.MD: -------------------------------------------------------------------------------- 1 | ### Dispatch 2 | Dispatch is the service which dispatches the product after purchase. It is written in GoLang, So wanted to install GoLang. 3 | 4 | Install GoLang 5 | 6 | ``` 7 | yum install golang -y 8 | ``` 9 | 10 | Configure the application. 11 | 12 | Add application User 13 | 14 | ``` 15 | useradd roboshop 16 | ``` 17 | 18 | Lets setup an app directory. 19 | 20 | ``` 21 | mkdir /app 22 | ``` 23 | 24 | Download the application code to created app directory. 25 | 26 | ``` 27 | curl -L -o /tmp/dispatch.zip https://roboshop-builds.s3.amazonaws.com/dispatch.zip 28 | cd /app 29 | unzip /tmp/dispatch.zip 30 | ``` 31 | 32 | Every application is developed by development team will have some common softwares that they use as libraries. This application also have the same way of defined dependencies in the application configuration. 33 | 34 | Lets download the dependencies & build the software. 35 | 36 | ``` 37 | cd /app 38 | go mod init dispatch 39 | go get 40 | go build 41 | ``` 42 | 43 | We need to setup a new service in systemd so systemctl can manage this service 44 | 45 | Setup SystemD Dispatch Service 46 | 47 | ``` 48 | vim /etc/systemd/system/dispatch.service 49 | ``` 50 | 51 | ``` 52 | [Unit] 53 | Description = Dispatch Service 54 | [Service] 55 | User=roboshop 56 | Environment=AMQP_HOST=RABBITMQ-IP 57 | Environment=AMQP_USER=roboshop 58 | Environment=AMQP_PASS=roboshop123 59 | ExecStart=/app/dispatch 60 | SyslogIdentifier=dispatch 61 | 62 | [Install] 63 | WantedBy=multi-user.target 64 | ``` 65 | 66 | Load the service. 67 | 68 | ``` 69 | systemctl daemon-reload 70 | ``` 71 | 72 | Start the service. 73 | 74 | ``` 75 | systemctl enable dispatch 76 | systemctl start dispatch 77 | ``` -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # roboshop-documentation 2 | 3 | Below is the communication between components and dependency. This dependency comes from **Development team**. Architects decide that, DevOps has no scope in this. 4 | 5 | ![alt text](roboshop.jpg) 6 | 7 | ### WEB TIER: 8 | * Usually web tier is the one which has frontend technologies like HTML, CSS, Java Script (React/Angular/Node). 9 | * We use web server to deploy these kind of applications. 10 | * Earlier Apache Server was popular, Now Nginx is the most popular web server. 11 | 12 | ### APP TIER: 13 | * APP/API Tier is the one which has backend technologies like Java, .NET, Python, Go, Php, etc. 14 | * Earlier Backend technologies had servers like tomcat, Jboss, IIS, etc. 15 | * Now all backend technologies are coming up with in built servers. 16 | * Usually API tier should not opened through internet, it should be only accessible through web tier. 17 | 18 | ### DB TIER: 19 | * Storage of the applications will be here like user data, products, orders data, etc. 20 | * We can use RDBMS like MySQL, MSSQL, Postgress, etc for row and column based data. 21 | * We can use NoSQL databases like MongoDB for storing the product information. 22 | * We can use Cache servers like Redis to access the data with lightening speed. 23 | * We can use MQ Servers like RabbitMQ, ActiveMQ, Kafka, etc for asynchronous communication. -------------------------------------------------------------------------------- /nginx.MD: -------------------------------------------------------------------------------- 1 | ### Nginx 2 | We officially pronounce it as **Engine-X** 3 | 4 | * It is popular web server. 5 | * It is popular reverse-proxy server. 6 | 7 | ### Directory Structure: 8 | 1. Nginx configuration is available in 9 | ``` 10 | /etc/nginx 11 | ``` 12 | 2. By default HTML files are available in 13 | ``` 14 | /usr/share/nginx/html 15 | ``` 16 | 3. Logs are available in 17 | ``` 18 | /var/log/nginx 19 | ``` 20 | 4. Main configuration file is 21 | ``` 22 | /etc/nginx/nginx.conf 23 | ``` 24 | 25 | We have 2 type of proxies. 26 | 1. Forward Proxy 27 | 2. Reverse Proxy 28 | 29 | ![alt text](proxy.jpg) 30 | 31 | #### Forward Proxy: 32 | * Client-Centric: Client is aware of existence of proxy, we intentionally send the traffic through proxy server. 33 | * Privacy and Anonymous: Forward proxy is used to hide the client IP address. 34 | * Content Filtering and Access Control: We can restrict traffic out of the network through proxy. 35 | * Caching: Frequently requested content can be cached here. 36 | 37 | #### Reverse Proxy: 38 | * Server-Centric: Clients are unaware of the existence of reverse proxy, for clients it the website they are connecting. 39 | * Load Balancing: Reverse proxies have load balancing capabilities. 40 | * Security: Reverse proxy servers are the best for security. They protect the backend server programming and their IP addresses. 41 | * SSL Termination: Reverse proxies can handle SSL/TLS encryption and decryption, relieving the backend servers from this resource-intensive task. -------------------------------------------------------------------------------- /proxy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivadevopsdaws74s/roboshop-documentation/cac3c59fbd7cc5db0dbd094f87079ff76b06385f/proxy.jpg -------------------------------------------------------------------------------- /roboshop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sivadevopsdaws74s/roboshop-documentation/cac3c59fbd7cc5db0dbd094f87079ff76b06385f/roboshop.jpg --------------------------------------------------------------------------------