{"id":27962349,"url":"https://github.com/thoughtworks/byor-voting-infrastructure","last_synced_at":"2025-05-07T19:20:55.407Z","repository":{"id":44082547,"uuid":"187019086","full_name":"thoughtworks/byor-voting-infrastructure","owner":"thoughtworks","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-09T23:03:56.000Z","size":240,"stargazers_count":8,"open_issues_count":6,"forks_count":4,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-04-16T07:16:41.868Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thoughtworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null}},"created_at":"2019-05-16T12:01:07.000Z","updated_at":"2023-11-30T21:07:59.000Z","dependencies_parsed_at":"2023-01-25T17:15:30.446Z","dependency_job_id":null,"html_url":"https://github.com/thoughtworks/byor-voting-infrastructure","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtworks%2Fbyor-voting-infrastructure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtworks%2Fbyor-voting-infrastructure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtworks%2Fbyor-voting-infrastructure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoughtworks%2Fbyor-voting-infrastructure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoughtworks","download_url":"https://codeload.github.com/thoughtworks/byor-voting-infrastructure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252941360,"owners_count":21828860,"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":"2025-05-07T19:20:54.471Z","updated_at":"2025-05-07T19:20:55.388Z","avatar_url":"https://github.com/thoughtworks.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BYOR-VotingApp [infrastructure]\n\nWelcome to the repository for the infrastructure setup of **BYOR-VotingApp**!\n\nYou can find more information about the BYOR-VotingApp in the web-app Github [repository](https://github.com/thoughtworks/byor-voting-web-app).\n\n\n#### Table Of Contents\n\n[Running BYOR-VotingApp locally](#running-byor-votingapp-locally)\n\n[Deploy BYOR-VotingApp to AWS Lambda](#deploy-byor-votingapp-to-aws-lambda)\n-   [Prerequisites](#prerequisites)\n-   [Setting up an AWS account](#setting-up-an-aws-account)\n-   [Settting up MongoAtlas account and database](#settting–up-mongoatlas-account-and-database)\n-   [Deploying the application](#deploying-the-application-1)\n-   [Updating the application](#updating-the-application-1)\n\n[Deploy BYOR-VotingApp to Kubernetes](#deploy-byor-votingapp-to-kubernetes)\n-   [Provisioning AWS EKS Kubernetes cluster](#provisioning-aws-eks-kubernetes-cluster)\n    -   [Setting up AWS](#setting-up-aws-2)\n    -   [Provisioning with Terraform](#provisioning-with-terraform)\n-   [Setting up an already provisioned cluster](#setting-up-an-already-provisioned-cluster)\n-   [Deploying the application](#deploying-the-application-2)\n-   [Updating the application](#updating-the-application-2)\n-   [HOWTOs](#howtos)\n    -   [Access Kubernetes Dashboard](#access-kubernetes-dashboard)\n    -   [Validating certificate issuer](#validating-certificate-issuer)\n    -   [Generating certificates with Let's encrypt](#generating-certificates-with-lets-encrypt)\n    -   [How to manage secrets](#how-to-manage-secrets)\n\n[Run end to end tests based on Gauge](#run-end-to-end-tests-based-on-gauge)\n\n[How to contribute to the project](#how-to-contribute-to-the-project)\n\n## Running BYOR-VotingApp locally\n\n1) install [Docker](https://www.docker.com/get-started)\n1) open the terminal\n1) clone the project\n    ```shell\n    git clone https://github.com/thoughtworks/byor-voting-web-app.git\n    ```\n1) move into the project folder\n    ```shell\n    cd byor-voting-web-app\n    ```\n1) startup web app, server, and a local MongoDB\n    ```shell\n    docker-compose -f docker-compose.all.yml up\n    ```\n1) access the application front-end on [http://localhost:4201](http://localhost:4201)\n\n\u003e if needed, application back-end is accessible on [http://localhost:3001](http://localhost:3001) and application's mongo database is accessible at `localhost:27019`\n\n\u003e Please refer to [BYOR-VotingApp \\[web-app\\]](https://github.com/thoughtworks/byor-voting-web-app) Github repository for more options on running the application locally.\n\n## Deploy BYOR-VotingApp to AWS Lambda\n\n### Prerequisites\n\n-    install [GNU Bash](https://www.gnu.org/software/bash/)\n-    install [GNU Make](https://www.gnu.org/software/make/)\n-    install [npm](https://www.npmjs.com/get-npm)\n-    install [AWS Command Line interface](https://aws.amazon.com/cli/)\n-    clone **VotingApp [web-app]**\n```shell\ngit clone https://github.com/thoughtworks/byor-voting-web-app.git\n```\n-    clone **VotingApp [server]**\n```shell\ngit clone https://github.com/thoughtworks/byor-voting-server.git\n```\n-    clone **VotingApp [infrastructure]**\n```shell\ngit clone https://github.com/thoughtworks/byor-voting-infrastructure.git\n```\n\n### Setting up an AWS account\n\n1. sign-in or create a new account in [AWS](https://aws.amazon.com) \n1. go to `IAM` -\u003e `Users`\n1. create a new user to be used for deployment\n1. create an `Access key` for the user and download it\n   \u003e keep note of the `Access key ID` and `Secret access key` contained inside the file, they will be asked later by the deployment script.\n\n\n### Settting up MongoAtlas account and database\n1. sign-in or create a new account in [MongoAtlas](https://www.mongodb.com/cloud/atlas)\n1. create a new database using a lowercase name without spaces (e.g. production) and use `migrations` for the collection name\n1. go to `Database Access`\n1. create a user setting `add default privileges` to `readWrite` for the database defined above \n1. go to `Project`, click on `connect` and then on `Connect your application`\n1. select `Node.js` from `Driver` dropdown\n   \u003e keep note of the `Connection string only` (replace the `\u003cpassword\u003e` with the user password defined above), it will be asked later by the deployment script\n1. go to `Project`, click on `...` and then on `Command Line Tools`\n   \u003e keep note of the `--host` parameter value from the `mongorestore` example, it will be asked later by the deployment script\n\n### Deploying the application\nRun the `deploy_to_lambda.sh` script passing the name of the installation. Use a lowercase name, without spaces  (e.g. production).\nIf you want to deploy to several installation targets at once pass them as a comma separated list (e.g. test,production).\n\n```shell\ncd byor-voting-infrastructure\naws/deploy_to_lambda.sh \u003cinstallation_name1[,installation_nameX]\u003e\n```\n\nThe first time you run the script you will be asked to enter several informations. Afterwards, all the parameters will be stored inside the `config/byor_\u003cinstallation_name\u003e.sh` file. If you change some of the configuration values later, please either delete the file and let the script ask you again them, or update the file manually.\n\nRequested values:\n-    AWS access key id [`AWS_ACCESS_KEY_ID`]: the value of the `Access key ID` field contained downloaded file from point 4 of AWS instructions\n-    AWS secret access [`AWS_SECRET_ACCESS_KEY`]: the value of the `Secret access key` field contained downloaded file from point 4 of AWS instructions\n-    AWS region [`AWS_REGION`]: the AWS region where you want to host the application \n-    MongoDB connection string [`MONGO_HOME`]: the local path of your mongodb installation home (required if you want to perform backups)\n-    MongoDB database [`MONGO_HOST`]: the value from point 7 in the MongoAtlas instructions\n-    MongoDB host [`MONGO_USER`]: the value from point 4 in the MongoAtlas instructions\n-    MongoDB username [`MONGO_PWD`]: the value from point 4 in the MongoAtlas instructions\n-    MongoDB password [`MONGO_AUTH_DB`]: the default value (`admin`) is usually the right one\n-    MongoDB admin database [`MONGO_URI`]: he value from point 6 in the MongoAtlas instructions\n\nThe script will create S3 buckets with the following naming conventions:\n-   `\u003cinstallation_name\u003e--byor:` contains the build-your-own-radar SPA (single page application)\n-   `\u003cinstallation_name\u003e--byor-voting`: contains the byor-voting-server deployed as lambda\n-   `\u003cinstallation_name\u003e--byor-voting-web-app`: contains the byor-voting-web-app SPA (single page application)\n\nThe script will configure `\u003cinstallation_name\u003e--byor` and `\u003cinstallation_name\u003e--byor-voting-web-app` buckets as [static contents' web server](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html).\n\n### Updating the application\nTo update the **web-app** or the **server**, just execute again the `aws/deploy_to_lambda.sh` script as above.\n\n\n## Deploy BYOR-VotingApp to Kubernetes\n\n### Provisioning AWS EKS Kubernetes cluster\n\n-    install [AWS Command Line interface](https://aws.amazon.com/cli/)\n-    install [aws-iam-authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)\n-    install [Terraform](https://learn.hashicorp.com/terraform/getting-started/install.html)\n-    install [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)\n\n#### Setting up AWS\n\n1)    login into AWS console:\n        -    create [programmatic access](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create.html) for provisioning resources using Terraform and attach the right EC2 policies.\n        -   configure AWS [cli](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) to interact with AWS\n        -    [create EC2 keypair](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)\n        -    [create AMI](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/tkv-create-ami-from-instance.html)\n        -    create S3 bucket to store Terraform state file\n        \u003e   if you want you can use [aws/create_s3_bucket.sh](aws/create_s3_bucket.sh) script to perform the operation\n        -    set [permission on S3](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/create-configure-bucket.html) to ensure to be accessible only by your organization\n1)    inside [terraform.tf](terraform.tf)\n        -    replace ``\u003cterraform-state-storage\u003e`` with the S3 bucket you create above\n        -    replace ``\u003cregion\u003e`` with the AWS region of your choice\n1)    inside [variable.tf](variable.tf)\n        -    replace ``\u003cAMI-ID\u003e`` with the AMI ID\n        -    replace ``\u003ckeypair name\u003e`` with the Keypair name\n        -    customize other settings for eks (e.g. node_instance_type) based on your needs.\n1)    inside [terraform.tfvars](terraform.tfvars) replace ``\u003caws_access_key\u003e``, ``\u003caws_secret_key\u003e``,``\u003caws_zones\u003e`` with your AWS settings\n\n#### Provisioning with Terraform\n\n1)    open terminal and login into AWS\n1)    move into the **VotingApp [infrastructure]** project folder\n1)    duplicate terraform template files to replace sample variables:\n        ```shell\n        cp terraform.tf.sample terraform.tf\n        cp terraform.tfvars.sample terraform.tfvars\n        cp variables.rf.sample variables.rf\n        ```\n1)    if this is the first time you run terraform, execute:\n        ```shell\n        terraform init\n        ```\n1)    review the plan outputs:\n        ```shell\n        terraform plan\n        ```\n1)    if everything looks good, run:\n        ```shell\n        terraform apply\n        ```\n1)    if everything looks good, run:\n        ```shell\n        terraform apply\n        ```\n1)    to install Isto, Cert-Manager, Kiali secrets, and Let's encrypt secrets:\n        ```shell\n        source k8s/k8s_setup.sh\n        ```\n1)    if you want to delete all the resources managed by terraform, run:\n        ```shell\n        terraform destroy\n        ```\n\n## Setting up an already provisioned Kubernetes cluster\n\n1)    set the ``KUBECONFIG`` context\n        ```shell\n        export KUBECONFIG=\u003cpath-to-kubeconfig\u003e\n        echo \"export KUBECONFIG=${KUBECONFIG}\" \u003e\u003e ${HOME}/.bashrc\n        ```\n1)    if you don't have already installed Isto, Cert-Manager, Kiali secrets, and Let's encrypt secrets, you can do it running:\n        ```shell\n        k8s/k8s_setup.sh\n        ```\n\n\n## Deploying the application\n\n1)    install [helm](https://helm.sh/docs/using_helm/)\n1)    add the repositories for **web-app**, **server**, and **infrastructure**\n        ```shell\n        helm repo add byor-voting-web-app https://raw.githubusercontent.com/thoughtworks/byor-voting-web-app/master/charts\n        helm repo add byor-voting-server https://raw.githubusercontent.com/thoughtworks/byor-voting-server/master/charts\n        helm repo add byor-voting-infrastructure https://raw.githubusercontent.com/thoughtworks/byor-voting-infrastructure/master/charts\n        ```\n1)    deploy BYOR-VotingApp:\n        ```shell\n        helm install byor-voting-chart\n        ```\n\n### Updating the application\nTo update the **VotingApp**, just repeat the step 3 above.\n\n\n### HOWTOs\n\n#### Access Kubernetes Dashboard:\n\nAdmin Username : k8s-admin\n1)    get token\n        ```shell\n        kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep k8s-admin | awk '{print $1}')\n        ```\n1)    run the proxy\n        ```shell\n        kubectl proxy`` command in provision machine.\n        ```\n1)    access the dashboard at [http://localhost:8001/api/v1/namespaces/kube-system/services/](http://localhost:8001/api/v1/namespaces/kube-system/services/)\n\n\n#### Validating certificate issuer.\n```shell\nkubectl describe clusterissuer \u003ccluster issuer name\u003e\nkubectl -n istio-system describe certificate \u003ccertificate name\u003e\n```\n\n### Access Kiali dashboard\n```shell\nkubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=kiali -o jsonpath='{.items[0].metadata.name}') 20001:20001 \u0026\n```\n\n### Access Jaeger dashboard\n:warning: **[*TODO*]**  \n```shell\nkubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=jaeger -o jsonpath='{.items[0].metadata.name}') 16686:16686  \u0026\n```\n\n### Access Grafana dashboard\n:warning: **[*TODO*]**  \n```shell\nkubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 \u0026\n```\n\n### Generating certificates with Let's encrypt\n:warning: **[*TODO*]**\n\n### How to manage secrets\n:warning: **[*TODO*]**  \n\n## Run end to end tests based on Gauge\n\nThe **byor-gauge** folder contains the code that implements end to end tests using the [Gaugue](https://gauge.org/) test framework.\n\nThe tests required the installation of the Gauge Testing Framework which can be accomplished with the command \n```shell\nnpm install -g @getgauge/cli\n```\n\nBefore launching the tests make sure that there is a **byor-voting-server** instance up and running.\nCurrently the server has to run at *http://localhost:3000/*.\n\nTo execute the test run, from within **byor-gauge** folder, the command \n```shell\ngauge run specs\n```\n\n## How to contribute to the project\n\nPlease refer to [CONTRIBUTING.md](CONTRIBUTING.md) for all the information about how to contribute.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtworks%2Fbyor-voting-infrastructure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoughtworks%2Fbyor-voting-infrastructure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoughtworks%2Fbyor-voting-infrastructure/lists"}