How to install UPYOG on AWS
The document assumes that you have the pre-requisites installed and AWS credentials set.
To provision infra and setup UPYOG, follow the below mentioned steps:
Clone the UPYOG-DevOps repository using the below command:
git clone https://github.com/upyog/UPYOG-DevOps.git
Once you clone the repository, cd into UPYOG-DevOps and then checkout UPYOG-Bootcamp branch using the command:
cd UPYOG-DevOps git checkout UPYOG-Bootcamp
At this step please check if correct credentials are configured using the command:aws configure list
Please make sure that the above command shows the proper AWS credentials which you have set. Please proceed only after confirming it.
(Refer to this AWS document in case of any doubts on how to set the credentials: Configuring settings for the AWS CLI - AWS Command Line Interface )Generate ssh key pairs (Use either method (a) or method (b)).
a. Using online website (not recommended in prod setup. To be only used for demo setups):
https://8gwifi.org/sshfunctions.jspb. Using openssl :
Add the public key to your github account (reference: https://www.youtube.com/watch?v=9C7_jBn9XJ0&ab_channel=AOSNote )
Open input.yaml file in vscode. You can use the below code to directly open it in VS code:
If the command does not work you can manually go and open the file in VS code. Once the file is open, fill the inputs. Please make sure the inputs that you add follow the regex mentioned in the comments for that input
(In case you are not using vscode, you can open it any editor of your choice)
Open egov-demo-secret.yaml and add DB password (line number 5), flywayPassword (line number 7) and private key. You can use the following command to open it in VS code:
Please keep the DB password and flywayPassword same. Private key has to be added inside git-sync key against ssh key (line number 37).
Next go to infra-as-code/terraform/sample-aws and run init.go script to enrich different files based on input.yaml. You can run the script using the following command:
Now go to remote-state folder and run terraform using the following commands. It will create a S3 bucket and DynamoDB to maintain terraform state.
Next cd back to sample-aws folder and run terraform to provision infra for UPYOG. Use the following command:
(Add the same DB password which you have added in egov-demo-secret.yaml when prompted after running terraform apply)
Execute the following command to generate a kubeConfig file and update the volumeIds, DB URL, and other relevant details in the egov-demo.yaml file.
Run the export KUBECONFIG command shown on terminal. (Note: The exact command to run will be printed on terminal. It will be something like this: export KUBECONFIG=<LOCAL_KUBECONFIGPATH> )
Next step is deployment of services. Run the digit-installer.go script to install UPYOG using the following command:
Once this is done you will get the CNAME of the nginx-ingress-controller using the following command:
The output of this will be the something like this:
ae210873da6ff4c03bde2ad22e18fe04-233d3411.ap-south-1.elb.amazonaws.com
You need to add it in your domain provider against your domain name.
Seed Data Setup:
Import the following postman collection - https://api.postman.com/collections/12892142-55ebe4d0-3869-4879-87e1-5ba3b60cc6b7?access_key=PMAT-01H27R18VPWXP2AE8812P0S12X
Port-forward user pod using the following command -
Hit super_user_creation cURL. This will create a super user with username as GRO and password as eGov@4321.
Now, open the accessToken_generation cURL. The credentials have already been populated. Change "{{YOUR_DOMAIN_NAME}}" placeholder to the domain name defined in input.yaml file while provisioning and hit the cURL.
In the response, you will get "access_token" field. Highlight this value, right click on it and set it as global "token "value.
Once done, you can execute rainmaker common, rainmaker locality, rainmaker PGR localization and PGR workflow cURLs by changing "{{YOUR_DOMAIN_NAME}}" placeholder to the domain name defined in input.yaml file to setup localization and workflow seed data.
Destroying the Cluster:
If you want to destroy(delete) the cluster after demo is done. You can use the following command:
For destroying the remote state bucket, set the lifecycle value to false in main.tf file in the remote-state folder
After that, go to AWS console and empty the S3 bucket. You can then proceed to destroy the remote state bucket using the terraform destroy command.