Skip to content

Latest commit

 

History

History
129 lines (86 loc) · 3.64 KB

README.md

File metadata and controls

129 lines (86 loc) · 3.64 KB

demshin_infra

demshin Infra repository

homework Terraform-2

  • 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

homework Terraform-1

The main task. Simple infrastructure with variables

Tasks on page #49. Work with variables.

An additional task. Add few keys to project metadata

Добавление ключей при помощи google_compute_project_metadata. При добавлении ключа через веб-консоль GCP и последющей команде terraform apply добавленный ключ перезатирается.

An additional task. Http load balncer

Описание балансировщика для приложения в lb.tf, использованы google_compute_forwarding_rule, google_compute_target_pool, google_compute_http_health_check и параметр count для инстанса. Если инстансов приложения несколько, то при "падении" любого оно остается доступным.

homework Packer

The main task. Template User Variables

  • Creating template with user variables (with default values and reqired values).
  • Creating variables.json.example, set variables at variables.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.

An additional task. Immutable infrastructure

Creating template immutable.json with user variables variables-reddit.json, additional files at files directory.

An additional task. Create instance with script & gcloud

Use shell script ./config-scripts/create-reddit-vm.sh.

homework 4

The main task. Create scripts

testapp_IP = 35.234.120.58

testapp_port = 9292

An additional task. Create app from file or url

Create app with startup script from file

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

Create app with startup script from url

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

Create firewall rule for puma app

gcloud compute firewall-rules create default-puma-server\
  --allow=tcp:9292 \
  --target-tags=puma-server

homework 3

How to connect to someinternalhost with one command

This solution uses ProxyJump option.

ssh -i .ssh/id_rsa -A -J [email protected] 10.156.0.3

Additional task. How to connect with alias

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.

Setting up vpn server on bastion

bastion_IP = 35.198.185.22 someinternalhost_IP = 10.156.0.3

homework 2

Text for test travis and slack integration.