run all faucets on just one host

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-07-23 22:33:43 -04:00
parent b39720f7b1
commit a3e837297d
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
7 changed files with 83 additions and 111 deletions

View File

@ -14,6 +14,10 @@ This repo defines infrasctructure for Rinkeby and Ropsten Ethereum faucets.
For how to use this repo read the [Infra Repo Usage](https://github.com/status-im/infra-docs/blob/master/articles/infra_repo_usage.md) doc.
# Miners
Currently there are no miners. Mainly because we have plenty of ETH in Ropsten and both Rinkeby and Goerli are Proof-of-Authority neworks, so mining doesn't give rewards.
# Sub-Sections
Read up on the roles:

View File

@ -1,27 +1,35 @@
---
# stage contains the network name
faucet_network: '{{ stage }}'
faucet_domain: 'faucet-{{ stage }}.status.im'
# WARNING: this needs to be set
faucet_network: '{{ faucet_network | mandatory }}'
# faucet api settings
faucet_cont_name: 'faucet-{{ faucet_network }}-api'
faucet_domain: 'faucet-{{ faucet_network }}.status.im'
faucet_cors_rule: '^https?://.*\.infura\.status.im'
faucet_geth_cont_alias: 'faucet-geth'
faucet_geth_cont_name: '{{ geth_cont_name }}'
faucet_account_pass: '{{lookup("passwordstore", "services/faucet/account-pass")}}'
faucet_geth_cont_rpc_port: '{{ geth_rpc_port }}'
# geth necessary for Faucet to work
geth_network_name: '{{ faucet_network }}'
geth_rpc_port: '{{ faucet_geth_cont_rpc_port }}'
geth_cont_name: '{{ faucet_geth_cont_name }}'
geth_extra_alias: '{{ faucet_geth_cont_alias }}'
geth_sync_mode: '{{ (stage == "goerli") | ternary("full", "light") }}'
geth_cont_name: 'faucet-{{ faucet_network }}-geth'
geth_extra_alias: '{{ faucet_geth_cont_name }}'
geth_sync_mode: '{{ (faucet_network == "goerli") | ternary("full", "light") }}'
geth_log_level_name: info
# adjust cache size to available memory
mem_cache_ratio: 0.75
mem_cache_ratio: 0.3
geth_cache: '{{ (ansible_memtotal_mb * mem_cache_ratio|float) | int }}'
# has to be higher than mem_cache_ratio
cont_mem_ratio: 0.2
# credentials for the wallet
geth_account_pass: '{{lookup("passwordstore", "services/faucet/account-pass")}}'
geth_account_addr: '{{lookup("passwordstore", "services/faucet/account-addr")}}'
geth_account_json: '{{lookup("passwordstore", "services/faucet/account-json")}}'
# geth metrics
geth_source_cont_name: '{{ geth_cont_name }}'
geth_expo_cont_name: '{{ geth_cont_name }}-metrics'
geth_expo_cont_name: 'faucet-{{ faucet_network }}-metrics'
geth_expo_consul_name: '{{ geth_expo_cont_name }}'

View File

@ -1,22 +0,0 @@
---
# stage contains the network name
geth_network_name: '{{ stage }}'
geth_miner_enabled: true
geth_cont_name: 'geth-miner'
geth_extra_alias: 'miner'
geth_sync_mode: full
geth_log_level_name: info
# adjust cache size to available memory
mem_cache_ratio: 0.6
geth_cache: '{{ (ansible_memtotal_mb * mem_cache_ratio|float) | int }}'
# has to be higher than mem_cache_ratio
cont_mem_ratio: 0.8
geth_account_pass: '{{lookup("passwordstore", "services/faucet/account-pass")}}'
geth_account_addr: '{{lookup("passwordstore", "services/faucet/account-addr")}}'
geth_account_json: '{{lookup("passwordstore", "services/faucet/account-json")}}'
# geth metrics
geth_source_cont_name: '{{ geth_cont_name }}'
geth_expo_cont_name: '{{ geth_cont_name }}-metrics'

View File

@ -1,22 +1,48 @@
---
- name: Configure faucet proxy
- name: Install origin certificates
hosts: faucet-master
roles:
- role: origin-cert
tags: origin-cert
- role: infra-role-geth
tags: geth
- role: infra-role-geth-exporter
tags: metrics
- role: geth-peer-fix
tags: geth-peer-fix
- role: faucet-api
tags: faucet-api
- name: Configure faucet miners
hosts: faucet-miners
- name: Configure ropsten faucet
hosts: faucet-master
roles:
- role: infra-role-geth
tags: geth
- role: infra-role-geth-exporter
tags: metrics
- role: faucet-api
- role: geth-peer-fix
vars:
faucet_network: ropsten
faucet_http_port: 3000
geth_port: 30303
geth_rpc_port: 8545
geth_expo_cont_port: 9200
- name: Configure rinkeby faucet
hosts: faucet-master
roles:
- role: infra-role-geth
- role: infra-role-geth-exporter
- role: faucet-api
- role: geth-peer-fix
vars:
faucet_network: rinkeby
faucet_http_port: 3001
geth_port: 30304
geth_rpc_port: 8546
geth_expo_cont_port: 9201
- name: Configure rinkeby faucet
hosts: faucet-master
roles:
- role: infra-role-geth
- role: infra-role-geth-exporter
- role: faucet-api
- role: geth-peer-fix
vars:
faucet_network: goerli
faucet_http_port: 3002
geth_port: 30305
geth_rpc_port: 8547
geth_expo_cont_port: 9202

View File

@ -17,6 +17,7 @@
ports:
- '127.0.0.1:{{ faucet_http_port | mandatory }}:{{ faucet_http_port }}'
command: |
-endpoint=":{{ faucet_http_port }}"
-network={{ faucet_network | mandatory }}
-geth=http://{{ faucet_geth_cont_alias }}:{{ faucet_geth_cont_rpc_port }}/
-acc_pass={{ faucet_account_pass | mandatory }}

45
main.tf
View File

@ -25,22 +25,17 @@ terraform {
key_file = "ansible/files/consul-client.key"
}
}
/* WORKSPACES -----------------------------------*/
locals {
ws = "${merge(local.env["defaults"], local.env[terraform.workspace])}"
}
/* RESOURCES ------------------------------------*/
module "faucet-master" {
module "main" {
source = "github.com/status-im/infra-tf-google-cloud"
name = "master"
env = "faucet"
group = "faucet-master"
type = "n1-standard-1"
count = 1
vol_size = "${local.ws["master_volume_size"]}"
vol_size = 10
domain = "${var.domain}"
open_ports = [
"80-80", /* HTTP */
@ -49,26 +44,28 @@ module "faucet-master" {
]
}
resource "cloudflare_record" "api" {
/* DNS Entries for faucet APIs */
resource "cloudflare_record" "main-ropsten" {
domain = "${var.public_domain}"
name = "faucet-${terraform.workspace}"
value = "${module.faucet-master.public_ips[0]}"
name = "faucet-ropsten"
value = "${module.main.public_ips[0]}"
type = "A"
proxied = true
}
/* MINERS ---------------------------------------*/
module "faucet-miners" {
source = "github.com/status-im/infra-tf-google-cloud"
name = "miner"
env = "faucet"
group = "faucet-miners"
count = "${local.ws["miner_count"]}"
type = "${local.ws["miner_instance_type"]}"
vol_size = "${local.ws["miner_volume_size"]}"
domain = "${var.domain}"
open_ports = [
"30303" /* GETH */
]
resource "cloudflare_record" "main-rinkeby" {
domain = "${var.public_domain}"
name = "faucet-rinkeby"
value = "${module.main.public_ips[0]}"
type = "A"
proxied = true
}
resource "cloudflare_record" "main-goerli" {
domain = "${var.public_domain}"
name = "faucet-goerli"
value = "${module.main.public_ips[0]}"
type = "A"
proxied = true
}

View File

@ -1,42 +0,0 @@
/* WORKSPACES ---------------------------------------------*/
/**
* This is a hacky way of binding specific variable
* values to different Terraform workspaces.
*
* Details:
* https://github.com/hashicorp/terraform/issues/15966
*/
locals {
env = {
defaults = {
miner_count = 3
/* By default we use 2 CPU 7.5 GB RAM instances */
miner_instance_type = "n1-standard-2"
/* 100 GBs is fine for now */
miner_volume_size = 100
/* 10 Gbs is fine, master usually syncs with LES */
master_volume_size = 10
}
/* Default settings for Rinkeby */
rinkeby = {
/* Proof-of-Authority neworks don't give mining rewards */
miner_count = 0
}
/* Ropsten is memory intensive, 13 GB of RAM given */
ropsten = {
miner_instance_type = "n1-highmem-2"
/* Currently we have ~64k ETH on Ropsten, no need for miners */
miner_count = 0
}
goerli = {
master_volume_size = 50
/* Proof-of-Authority neworks don't give mining rewards */
miner_count = 0
}
}
}
/*---------------------------------------------------------*/