Skip to content

Commit 959db7d

Browse files
authored
feat!: Cloud composer v2 (#36)
* refactor: separate packages by Airflow version * feature: new cloud composer (v2) version * feature: license * feature: add roles/composer.ServiceAgentV2Ext to composer api agent * fix: rename simple composer env dir * fix: cloud build kitchen-tf test integration * fix: cloud build kitchen-tf test integration * fix: cloud build kitchen-tf test integration * refactor: license year + docs * fix: lint * fix: master_authorized_networks_config flag * update
1 parent 13813fc commit 959db7d

File tree

40 files changed

+1085
-22
lines changed

40 files changed

+1085
-22
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ The resources/services/activations/deletions that this module will create/trigge
77
- Create a GCP Composer Environment
88

99
## Usage
10+
Cloud Composer currently has two versions: V2 has greater flexibility in the Airflow core services
11+
(scheduler, webserver, worker) and has a more practical and scalable infrastructure. Therefore, we recommend prioritizing the
12+
use of V2 for new environments.
1013

11-
Basic usage of this module is as follows:
14+
You can find an overview of the product [here](https://cloud.google.com/composer/docs/composer-2/composer-overview)
15+
and the [list of major differences](https://cloud.google.com/composer/docs/concepts/versioning/composer-versioning-overview).
16+
17+
Simple usage is as follows:
1218

1319
```hcl
1420
module "composer" {

build/int.cloudbuild.yaml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,41 @@ steps:
2828
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
2929
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do create']
3030

31-
# ----- SUITE simple-composer-env-local
31+
# ----- SUITE simple-composer-env-v1-local
3232

33-
- id: converge simple-composer-env-local
33+
- id: converge simple-composer-env-v1-local
3434
waitFor:
3535
- create all
3636
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
37-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-composer-env-local']
38-
- id: verify simple-composer-env-local
37+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-composer-env-v1-local']
38+
- id: verify simple-composer-env-v1-local
3939
waitFor:
40-
- converge simple-composer-env-local
40+
- converge simple-composer-env-v1-local
4141
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
42-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-composer-env-local']
43-
- id: destroy simple-composer-env-local
42+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-composer-env-v1-local']
43+
- id: destroy simple-composer-env-v1-local
4444
waitFor:
45-
- verify simple-composer-env-local
45+
- verify simple-composer-env-v1-local
4646
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
47-
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-composer-env-local']
47+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-composer-env-v1-local']
48+
49+
# ----- SUITE simple-composer-env-v2-local
50+
51+
- id: converge simple-composer-env-v2-local
52+
waitFor:
53+
- create all
54+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
55+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do converge simple-composer-env-v2-local']
56+
- id: verify simple-composer-env-v2-local
57+
waitFor:
58+
- converge simple-composer-env-v2-local
59+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
60+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do verify simple-composer-env-v2-local']
61+
- id: destroy simple-composer-env-v2-local
62+
waitFor:
63+
- verify simple-composer-env-v2-local
64+
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
65+
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && kitchen_do destroy simple-composer-env-v2-local']
4866

4967
# ----- SUITE airflow-connection-local
5068

examples/airflow_connection/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ provider "external" {
3030
}
3131

3232
module "simple-composer-environment" {
33-
source = "../../modules/create_environment"
33+
source = "../../modules/create_environment_v1"
3434
project_id = var.project_id
3535
composer_env_name = var.composer_env_name
3636
region = var.region
@@ -40,6 +40,8 @@ module "simple-composer-environment" {
4040
use_ip_aliases = true
4141
pod_ip_allocation_range_name = var.pod_ip_allocation_range_name
4242
service_ip_allocation_range_name = var.service_ip_allocation_range_name
43+
node_count = 3
44+
machine_type = "n1-standard-1"
4345
}
4446

4547
# Making the k8s master globally available is only to make the integration testing portable and should be removed

examples/airflow_pool/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ provider "external" {
3030
}
3131

3232
module "simple-composer-environment" {
33-
source = "../../modules/create_environment"
33+
source = "../../modules/create_environment_v1"
3434
project_id = var.project_id
3535
composer_env_name = var.composer_env_name
3636
region = var.region
@@ -40,6 +40,8 @@ module "simple-composer-environment" {
4040
use_ip_aliases = true
4141
pod_ip_allocation_range_name = var.pod_ip_allocation_range_name
4242
service_ip_allocation_range_name = var.service_ip_allocation_range_name
43+
node_count = 3
44+
machine_type = "n1-standard-1"
4345
}
4446

4547
# Making the k8s master globally available is only to make the integration testing portable and should be removed

examples/simple_composer_env/README.md renamed to examples/simple_composer_env_v1/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Simple Cloud Composer Environment Example
1+
# Simple Cloud Composer Environment (V1) Example
22

33
This example illustrates how to use the `composer` module.
44

examples/simple_composer_env/main.tf renamed to examples/simple_composer_env_v1/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
module "simple-composer-environment" {
18-
source = "../../modules/create_environment"
18+
source = "../../modules/create_environment_v1"
1919
project_id = var.project_id
2020
composer_env_name = var.composer_env_name
2121
region = var.region
@@ -25,4 +25,6 @@ module "simple-composer-environment" {
2525
use_ip_aliases = true
2626
pod_ip_allocation_range_name = var.pod_ip_allocation_range_name
2727
service_ip_allocation_range_name = var.service_ip_allocation_range_name
28+
node_count = 3
29+
machine_type = "n1-standard-1"
2830
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Simple Cloud Composer Environment (V2) Example
2+
3+
This example illustrates how to use the `composer` module.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| composer\_env\_name | Name of Cloud Composer Environment. | `string` | `"ci-composer"` | no |
11+
| composer\_service\_account | Service Account to be used for running Cloud Composer Environment. | `string` | n/a | yes |
12+
| network | Network where Cloud Composer is created. | `string` | n/a | yes |
13+
| pod\_ip\_allocation\_range\_name | The name of the cluster's secondary range used to allocate IP addresses to pods. | `string` | n/a | yes |
14+
| project\_id | Project ID where Cloud Composer Environment is created. | `string` | n/a | yes |
15+
| region | Region where Cloud Composer Environment is created. | `string` | n/a | yes |
16+
| service\_ip\_allocation\_range\_name | The name of the services' secondary range used to allocate IP addresses to the cluster. | `string` | n/a | yes |
17+
| subnetwork | Subetwork where Cloud Composer is created. | `string` | n/a | yes |
18+
19+
## Outputs
20+
21+
| Name | Description |
22+
|------|-------------|
23+
| airflow\_uri | URI of the Apache Airflow Web UI hosted within the Cloud Composer Environment. |
24+
| composer\_env\_id | ID of Cloud Composer Environment. |
25+
| composer\_env\_name | Name of the Cloud Composer Environment. |
26+
| gcs\_bucket | Google Cloud Storage bucket which hosts DAGs for the Cloud Composer Environment. |
27+
| gke\_cluster | Google Kubernetes Engine cluster used to run the Cloud Composer Environment. |
28+
29+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
30+
31+
To provision this example, run the following from within this directory:
32+
- `terraform init` to get the plugins
33+
- `terraform plan` to see the infrastructure plan
34+
- `terraform apply` to apply the infrastructure build
35+
- `terraform destroy` to destroy the built infrastructure

0 commit comments

Comments
 (0)