Skip to content

Commit 8e8158e

Browse files
committed
update to tutorials
1 parent a4caac3 commit 8e8158e

File tree

2 files changed

+67
-29
lines changed

2 files changed

+67
-29
lines changed

example-custom-machine-types/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Install Terraform if it is not already installed (visit [terraform.io](https://t
1616
./terraform-install.sh
1717
```
1818

19-
## Setup Environment
19+
## Set up the environment
2020

2121
```
2222
cd example-custom-machine-types/
@@ -25,11 +25,12 @@ cd example-custom-machine-types/
2525
Set the project, replace `YOUR_PROJECT` with your project ID:
2626

2727
```
28-
gcloud config set project YOUR_PROJECT
28+
PROJECT=YOUR_PROJECT
29+
gcloud config set project ${PROJECT}
2930
```
3031

3132
```
32-
test -z DEVSHELL_GCLOUD_CONFIG && gcloud auth application-default login
33+
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
3334
export GOOGLE_PROJECT=$(gcloud config get-value project)
3435
```
3536

example-gke-k8s-helm/README.md

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,58 @@
77

88
## Install Terraform
99

10-
Install Terraform if it is not already installed (visit [terraform.io](https://terraform.io) for other distributions):
10+
1. Install Terraform if it is not already installed (visit [terraform.io](https://terraform.io) for other distributions):
1111

1212
```
1313
./terraform-install.sh
1414
```
1515

16+
## Change to the example directory
17+
18+
```
19+
cd example-gke-k8s-helm/
20+
```
21+
1622
## Set up the environment
1723

24+
1. Set the project, replace `YOUR_PROJECT` with your project ID:
25+
1826
```
19-
gcloud auth application-default login
27+
PROJECT=YOUR_PROJECT
28+
gcloud config set project ${PROJECT}
29+
```
30+
31+
2. Configure the environment for Terraform:
32+
33+
```
34+
[[ $CLOUD_SHELL ]] || gcloud auth application-default login
2035
export GOOGLE_PROJECT=$(gcloud config get-value project)
2136
```
2237

38+
3. Create the terraform.tfvars file:
39+
40+
```
41+
cat > terraform.tfvars <<EOF
42+
helm_version = "$(helm version -c --short | egrep -o 'v[0-9].[0-9].[0-9]')"
43+
acme_email = "$(gcloud config get-value account)"
44+
EOF
45+
46+
cat terraform.tfvars
47+
```
48+
2349
## Enable service management API
2450

2551
This example creates a Cloud Endpoints service and requires that the Service Manangement API is enabled.
2652

53+
1. Enable the Service Management API:
54+
2755
```
2856
gcloud services enable servicemanagement.googleapis.com
2957
```
3058

31-
## Install helm
59+
## Install Helm
60+
61+
1. Install the latest version of Helm:
3262

3363
```
3464
curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get > get_helm.sh
@@ -38,48 +68,49 @@ chmod 700 get_helm.sh
3868
helm init --client-only
3969
```
4070

41-
## Install the helm provider
42-
43-
```
44-
wget https://github.com/mcuadros/terraform-provider-helm/releases/download/v0.5.1/terraform-provider-helm_v0.5.1_$(uname | tr '[:upper:]' '[:lower:]')_amd64.tar.gz
45-
tar -xvf terraform-provider-helm*.tar.gz
46-
47-
mkdir -p ~/.terraform.d/plugins/
48-
mv terraform-provider-helm*/terraform-provider-helm ~/.terraform.d/plugins/
49-
```
50-
51-
## Create the `terraform.tfvars` file
71+
2. Install the Terraform Helm provider:
5272

5373
```
54-
cat > terraform.tfvars <<EOF
55-
helm_version = "$(helm version -c --short | egrep -o 'v[0-9].[0-9].[0-9]')"
56-
acme_email = "$(gcloud config get-value account)"
57-
EOF
74+
(
75+
set -x; cd "$(mktemp -d)" &&
76+
curl -fsSLO "https://github.com/mcuadros/terraform-provider-helm/releases/download/v0.5.1/terraform-provider-helm_v0.5.1_$(uname | tr '[:upper:]' '[:lower:]')_amd64.tar.gz" &&
77+
tar -xvf terraform-provider-helm*.tar.gz &&
78+
mkdir -p ~/.terraform.d/plugins/ &&
79+
mv terraform-provider-helm*/terraform-provider-helm ~/.terraform.d/plugins/
80+
)
5881
```
5982

6083
## Run Terraform
6184

62-
If you have run this example before within the last 30 days, undelete the Cloud Endpoints service named `drupal`:
85+
1. If you have run this example before within the last 30 days, undelete the Cloud Endpoints service named `drupal`:
6386

6487
```
6588
gcloud endpoints services undelete drupal.endpoints.$(gcloud config get-value project).cloud.goog
6689
```
6790

91+
2. Run Terraform:
92+
6893
```
6994
terraform init
70-
terraform plan
71-
terraform apply
95+
terraform plan -out terraform.tfplan
96+
terraform apply terraform.tfplan
7297
```
7398

7499
## Testing
75100

76-
After the Drupal pods start and are ready, open the interface by navigating to the URL:
101+
1. Wait for the load balancer to be provisioned:
102+
103+
```
104+
./test.sh
105+
```
106+
107+
2. After the Drupal pods start and are ready, open the interface by navigating to the URL:
77108

78109
```
79-
echo https://$(terraform output endpoint)
110+
echo $(terraform output endpoint)
80111
```
81112

82-
Login with the credentials displayed in the following commands:
113+
3. Login with the credentials displayed in the following commands:
83114

84115
```
85116
echo User: $(terraform output drupal_user)
@@ -88,19 +119,25 @@ echo Password: $(terraform output drupal_password)
88119

89120
## Connecting with kubectl and helm
90121

122+
1. Get the cluster credentials and configure kubectl:
123+
91124
```
92125
gcloud container clusters get-credentials $(terraform output cluster_name) --zone $(terraform output cluster_zone)
126+
```
93127

128+
2. Verify kubectl connectivity:
129+
130+
```
94131
kubectl get pods
95132
96133
helm list
97134
```
98135

99136
## Cleanup
100137

101-
Delete the `nginx-ingress` helm release first so that the forwarding rule and firewall rule are cleaned up by the GCE controller:
138+
1. Delete the `nginx-ingress` helm release first so that the forwarding rule and firewall rule are cleaned up by the GCE controller:
102139

103140
```
104-
terraform destroy -target helm_release.nginx-ingress && sleep 60 && \
141+
terraform destroy -input=false -auto-approve -target helm_release.nginx-ingress && sleep 60 && \
105142
terraform destroy
106143
```

0 commit comments

Comments
 (0)