demshin Infra repository
- Separate resources on different files
- Create modules for app, db, vpc
- Add remote tfstate for prod & stage
- Run code without tfstate files ad directory
- Run concurency
terraform apply
Tasks on page #49. Work with variables.
Добавление ключей при помощи google_compute_project_metadata.
При добавлении ключа через веб-консоль GCP и последющей команде terraform apply
добавленный ключ перезатирается.
Описание балансировщика для приложения в lb.tf
, использованы google_compute_forwarding_rule
, google_compute_target_pool
, google_compute_http_health_check
и параметр count
для инстанса. Если инстансов приложения несколько, то при "падении" любого оно остается доступным.
- Creating template with user variables (with default values and reqired values).
- Creating
variables.json.example
, set variables atvariables.json
(only local, not at remote git repository) - Add some other options of GCP.
To check run commands:
cd packer
packer validate -var-file=variables.json ubuntu16.json
packer build -var-file=variables.json ubuntu16.json
And view at GCP web console.
Creating template immutable.json
with user variables variables-reddit.json
, additional files at files
directory.
Use shell script ./config-scripts/create-reddit-vm.sh
.
testapp_IP = 35.234.120.58
testapp_port = 9292
gcloud compute instances create reddit-app-2\
--boot-disk-size=10GB \
--image-family ubuntu-1604-lts \
--image-project=ubuntu-os-cloud \
--machine-type=g1-small \
--tags puma-server \
--restart-on-failure \
--metadata-from-file startup-script=./startup.sh
gcloud compute instances create reddit-app-2\
--boot-disk-size=10GB \
--image-family ubuntu-1604-lts \
--image-project=ubuntu-os-cloud \
--machine-type=g1-small \
--tags puma-server \
--restart-on-failure \
--metadata startup-script-url=https://raw.githubusercontent.com/Otus-DevOps-2018-05/demshin_infra/cloud-testapp/startup.sh
gcloud compute firewall-rules create default-puma-server\
--allow=tcp:9292 \
--target-tags=puma-server
This solution uses ProxyJump option.
ssh -i .ssh/id_rsa -A -J [email protected] 10.156.0.3
This solution uses ProxyJump option too. Add some configuration to ssh config.
echo "Host someinternalhost
HostName 10.156.0.3
User demshin
ProxyJump [email protected]" >> ~/.ssh/config
And try to connect ssh someinternalhost
.
bastion_IP = 35.198.185.22 someinternalhost_IP = 10.156.0.3
Text for test travis and slack integration.