Welcome to the repository for the infrastructure setup of BYOR-VotingApp!
You can find more information about the BYOR-VotingApp in the web-app Github repository.
Running BYOR-VotingApp locally
Deploy BYOR-VotingApp to AWS Lambda
Deploy BYOR-VotingApp to Kubernetes
- Provisioning AWS EKS Kubernetes cluster
- Setting up an already provisioned cluster
- Deploying the application
- Updating the application
- HOWTOs
How to contribute to the project
- install Docker
- open the terminal
- clone the project
git clone https://github.com/thoughtworks/byor-voting-web-app.git
- move into the project folder
cd byor-voting-web-app
⚠️ [TODO] startup web app, server, and a local MongoDBdocker-compose up
- access the application on http://localhost:4200
Please refer to CONTRIBUTING.md for more options on running the web app locally.
Please refer to BYOR-VotingApp [server] Github repository for more options on running the server locally and connect to a MongoDB database.
- install GNU Bash
- install GNU Make
- install npm
- install AWS Command Line interface
- clone VotingApp [web-app]
git clone https://github.com/thoughtworks/byor-voting-web-app.git
- clone VotingApp [server]
git clone https://github.com/thoughtworks/byor-voting-server.git
- create a S3 bucket for deploying the web-app
if you want you can use aws/create_s3_bucket.sh script to perform the operation
- configure the S3 bucket to act as static contents' web server
- open terminal and login into AWS
-
- move into the VotingApp [server] project folder
- get last updates
git pull
- install the required packages
make install
- deploy on AWS infrastructure via Serverless framework:
make deploy
By default, the target stage is
dev
, but, at the user prompt you can specify any other stages as target for the deployment.At the user prompt, you'll also have to enter your AWSkeys.
For any stage, the following variables are expected toexist as parameters in AWS Systems Manager Parameter Store:
- <stage>ByorMongoUri (secure): the fullURI to let the application connecting to MongoDB
- <stage>ByorMongoUriAdmin (secure): thefull URI to perform admin operations on MongoDB (createdelete collections and indexes)
- <stage>ByorMongoDbName: the mongo databasename
After a successful deploy, pending database migrations(if any) are automatically run against the target stage'sdatabase.
- take note of the backend url generated during deploy
- move into the VotingApp [web-app] project folder
- get last updates
git pull
- install the required packages
make install
- build the application for production
make build
The script will ask for the backend url, paste the value captured at step 6.
Please refer to BYOR-VotingApp [web-app] for more options about how to build for production
- clear the existing content of the S3 bucket with:
aws s3 rm s3://<your-bucket-name-here>/ --recursive
- deploy the new files with:
aws s3 cp dist/ng-build-your-own-radar s3://<your-bucket-name-here>/ --recursive
To update the web-app or the server, just repeat the steps above.
- install AWS Command Line interface
- install aws-iam-authenticator
- install Terraform
- install kubectl
- login into AWS console:
- create programmatic access for provisioning resources using Terraform and attach the right EC2 policies.
- configure AWS cli to interact with AWS
- create EC2 keypair
- create AMI
- create S3 bucket to store Terraform state file
if you want you can use aws/create_s3_bucket.sh script to perform the operation
- set permission on S3 to ensure to be accessible only by your organization
- inside terraform.tf
- replace
<terraform-state-storage>
with the S3 bucket you create above - replace
<region>
with the AWS region of your choice
- replace
- inside variable.tf
- replace
<AMI-ID>
with the AMI ID - replace
<keypair name>
with the Keypair name - customize other settings for eks (e.g. node_instance_type) based on your needs.
- replace
- inside terraform.tfvars replace
<aws_access_key>
,<aws_secret_key>
,<aws_zones>
with your AWS settings
- open terminal and login into AWS
- move into the VotingApp [infrastructure] project folder
- duplicate terraform template files to replace sample variables:
cp terraform.tf.sample terraform.tf cp terraform.tfvars.sample terraform.tfvars cp variables.rf.sample variables.rf
- if this is the first time you run terraform, execute:
terraform init
- review the plan outputs:
terraform plan
- if everything looks good, run:
terraform apply
- if everything looks good, run:
terraform apply
- to install Isto, Cert-Manager, Kiali secrets, and Let's encrypt secrets:
source k8s/k8s_setup.sh
- if you want to delete all the resources managed by terraform, run:
terraform destroy
- set the
KUBECONFIG
contextexport KUBECONFIG=<path-to-kubeconfig> echo "export KUBECONFIG=${KUBECONFIG}" >> ${HOME}/.bashrc
- if you don't have already installed Isto, Cert-Manager, Kiali secrets, and Let's encrypt secrets, you can do it running:
k8s/k8s_setup.sh
- install helm
- add the repositories for web-app, server, and infrastructure
helm repo add byor-voting-web-app https://raw.githubusercontent.com/thoughtworks/byor-voting-web-app/master/charts helm repo add byor-voting-server https://raw.githubusercontent.com/thoughtworks/byor-voting-server/master/charts helm repo add byor-voting-infrastructure https://raw.githubusercontent.com/thoughtworks/byor-voting-infrastructure/master/charts
- deploy BYOR-VotingApp:
helm install byor-voting-chart
To update the VotingApp, just repeat the step 3 above.
Admin Username : k8s-admin
- get token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep k8s-admin | awk '{print $1}')
- run the proxy
kubectl proxy`` command in provision machine.
- access the dashboard at http://localhost:8001/api/v1/namespaces/kube-system/services/
kubectl describe clusterissuer <cluster issuer name>
kubectl -n istio-system describe certificate <certificate name>
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=kiali -o jsonpath='{.items[0].metadata.name}') 20001:20001 &
kubectl port-forward -n istio-system $(kubectl get pod -n istio-system -l app=jaeger -o jsonpath='{.items[0].metadata.name}') 16686:16686 &
kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 &
Please refer to CONTRIBUTING.md for all the information about how to contribute.