Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

nosportugal/terraforming-the-cloud-part2

Repository files navigation

terraforming the cloud - part 2

Terraforming the cloud architecture

Temas abordados neste modulo:

iniciar o tutorial (setup automatico)

Open in Cloud Shell

erro a abrir o tutorial

Se por acaso tiverem este erro:

tfc-cloushell-error-reserved-id

Devem fechar o tutorial:

tfc-cloushell-error-open-tutorial

E depois na cloudshell vamos reinicar o tutorial usando o seguinte comando:

teachme tutorial.md

setup do ambiente (manual)

Esta secção explica como preparar o IDE para poderem executar os comandos do tutorial.

Abaixo seguem dois guias para configuração em:

  1. Google Cloud Shell
  2. Visual Studio Code

configurar a cloud shell

Abrir o endereço https://console.cloud.google.com e autenticar.

De seguida, ativar a cloud shell:

tfc-cloudshell-activate

Abrir em nova janela:

tfc-cloushell-open-new

Abrir editor:

tfc-cloushell-open-editor

Fechar a janela do terminal no fundo:

tfc-cloushell-close-terminal

Abrir novo terminal (embebido no editor):

tfc-cloushell-new-terminal

Clonar o projeto:

git clone https://github.com/nosportugal/terraforming-the-cloud-part2 && cd terraforming-the-cloud-part2

Abrir o editor na pasta do projeto:

tfc-cloushell-open-folder

E agora que têm o editor pronto, podemos autenticar a consola com o GCP:

gcloud config set project tf-gke-lab-01-np-000001

configurar o vscode

apenas válido para vscode em WSL (windows-subsystem-linux) - instalações em powershell não são suportadas

Caso decidam usar o vscode, é necessário garantirem que têm os seguintes binários instalados. As instruções que seguem vão instalar as tools necessárias:

  1. terraform
  2. kubectl
  3. gcloud
# instalar as tools necessárias (podem skipar se já têm instaladas)
sudo ./scripts/install-terraform.sh        # terraform
sudo ./scripts/install-kubectl.sh          # kubectl
curl https://sdk.cloud.google.com | bash   # gcloud

# reinicializar a shell
exec -l $SHELL

# inicializar o cliente gcloud
gcloud init
gcloud auth application-default login

# definir o projeto por defeito (opcional)
gcloud config set project tf-gke-lab-01-np-000001

Por fim, podemos clonar o projeto:

git clone https://github.com/nosportugal/terraforming-the-cloud-part2 && cd terraforming-the-cloud-part2

Trabalhar com o projeto full (sem código comentado)

Se por ventura quiserem experimentar o projeto sem terem que andar a descomentar, podem obter uma versão descomentada do projeto a partir da workshop-full branch:

https://github.com/nosportugal/terraforming-the-cloud-part2/tree/workshop-full

Para poderem clonar o código na branch, deverão fazer o seguinte:

git clone https://github.com/nosportugal/terraforming-the-cloud-part2.git
git checkout workshop-full

Comandos úteis

# obter a lista de machine-types
gcloud compute machine-types list --zones=europe-west1-b --sort-by CPUS

# listar a lista de regioes disponiveis
gcloud compute regions list

# listar as zonas disponiveis para uma dada regiao
gcloud compute zones list | grep europe-west1

# listar network-endpoints
gcloud compute network-endpoint-groups list

# apagar network-endpoints
gcloud compute network-endpoint-groups delete <id>

# delete multiple negs at once
gcloud compute network-endpoint-groups delete $(gcloud compute network-endpoint-groups list --format="value(name)" --project tf-gke-lab-01-np-000001)

# verificar as versoes dos release channels
gcloud container get-server-config --format "yaml(channels)" --zone europe-west1-b

About

Part 2 of the terraform workshop

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages