Skip to content

Commit

Permalink
Merge branch 'main' into test-all/hello-world-gvisor
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody authored Jan 23, 2025
2 parents 670088e + 74af8c0 commit 19bc4d2
Show file tree
Hide file tree
Showing 71 changed files with 1,812 additions and 241 deletions.
56 changes: 56 additions & 0 deletions 2-multitenant/modules/env_baseline/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ locals {
subnets_to_cidr = {
for idx, subnet_key in keys(data.google_compute_subnetwork.default) : subnet_key => local.available_cidr_ranges[idx]
}

}

resource "google_project_service_identity" "compute_sa" {
Expand Down Expand Up @@ -242,6 +243,61 @@ module "gke-standard" {

}

resource "google_container_node_pool" "arm_node_pool" {
count = var.cluster_type != "AUTOPILOT" ? 1 : 0

name = "arm-node-pool"
project = local.cluster_project_id
cluster = module.gke-standard["0"].name
location = module.gke-standard["0"].location

node_count = 1

// locations with t2a nodes
node_locations = [
"us-central1-a",
"us-central1-b",
"us-central1-f"
]

autoscaling {
min_node_count = 1
max_node_count = 100
location_policy = "BALANCED"
}

management {
auto_repair = true
auto_upgrade = true
}

upgrade_settings {
strategy = "SURGE"
max_surge = 1
max_unavailable = 0
}

node_config {
machine_type = "t2a-standard-4"
disk_size_gb = 100
disk_type = "pd-standard"
image_type = "COS_CONTAINERD"
local_ssd_count = 0
oauth_scopes = ["https://www.googleapis.com/auth/cloud-platform"]
preemptible = false

shielded_instance_config {
enable_integrity_monitoring = true
enable_secure_boot = false
}

workload_metadata_config {
mode = "GKE_METADATA"
}
}
}


module "gke-autopilot" {
source = "terraform-google-modules/kubernetes-engine/google//modules/beta-autopilot-private-cluster"
version = "~> 35.0"
Expand Down
3 changes: 3 additions & 0 deletions 2-multitenant/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ apps = {
}
"acronym" = "cs",
}
"default-example" : {
"acronym" = "de",
}
}
5 changes: 5 additions & 0 deletions 4-appfactory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ It will also create an Application Folder to group your admin projects under it,

## Usage

You have 3 Git provider options for this step: Cloud Source Repositories (CSR), Github, and Gitlab. If you are using Github or Gitlab you will need to take additional steps that are described in the following sections:

- [Cloud Build with Github Pre-requisites](#cloud-build-with-github-pre-requisites)
- [Cloud Build with Gitlab Pre-requisites](#cloud-build-with-gitlab-pre-requisites)

#### Cloud Build with Github Pre-requisites

To proceed with GitHub as your git provider you will need:
Expand Down
2 changes: 1 addition & 1 deletion 4-appfactory/envs/shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| billing\_account | Billing Account ID for application admin project resources. | `string` | n/a | yes |
| bucket\_force\_destroy | When deleting a bucket, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects. | `bool` | `false` | no |
| bucket\_prefix | Name prefix to use for buckets created. | `string` | `"bkt"` | no |
| cloudbuildv2\_repository\_config | Configuration for integrating repositories with Cloud Build v2:<br> - repo\_type: Specifies the type of repository. Supported types are 'GITHUBv2', 'GITLABv2', and 'CSR'.<br> - repositories: A map of repositories to be created. The key must match the exact name of the repository. Each repository is defined by:<br> - repository\_name: The name of the repository.<br> - repository\_url: The URL of the repository.<br> - github\_secret\_id: (Optional) The personal access token for GitHub authentication.<br> - github\_app\_id\_secret\_id: (Optional) The application ID for a GitHub App used for authentication.<br> - gitlab\_read\_authorizer\_credential\_secret\_id: (Optional) The read authorizer credential for GitLab access.<br> - gitlab\_authorizer\_credential\_secret\_id: (Optional) The authorizer credential for GitLab access.<br> - gitlab\_webhook\_secret\_id: (Optional) The secret ID for the GitLab WebHook..<br>Note: When using GITLABv2, specify `gitlab_read_authorizer_credential` and `gitlab_authorizer_credential` and `gitlab_webhook_secret_id`.<br>Note: When using GITHUBv2, specify `github_pat` and `github_app_id`.<br>Note: If 'cloudbuildv2\_repository\_config' variable is not configured, CSR (Cloud Source Repositories) will be used by default. | <pre>object({<br> repo_type = string # Supported values are: GITHUBv2, GITLABv2 and CSR<br> # repositories to be created<br> repositories = map(<br> object({<br> repository_name = string<br> repository_url = string<br> })<br> )<br> # Credential Config for each repository type<br> github_secret_id = optional(string)<br> github_app_id_secret_id = optional(string)<br> gitlab_read_authorizer_credential_secret_id = optional(string)<br> gitlab_authorizer_credential_secret_id = optional(string)<br> gitlab_webhook_secret_id = optional(string)<br> })</pre> | <pre>{<br> "repo_type": "CSR",<br> "repositories": {}<br>}</pre> | no |
| cloudbuildv2\_repository\_config | Configuration for integrating repositories with Cloud Build v2:<br> - repo\_type: Specifies the type of repository. Supported types are 'GITHUBv2', 'GITLABv2', and 'CSR'.<br> - repositories: A map of repositories to be created. The key must match the exact name of the repository. Each repository is defined by:<br> - repository\_name: The name of the repository.<br> - repository\_url: The URL of the repository.<br> - github\_secret\_id: (Optional) The personal access token for GitHub authentication.<br> - github\_app\_id\_secret\_id: (Optional) The application ID for a GitHub App used for authentication.<br> - gitlab\_read\_authorizer\_credential\_secret\_id: (Optional) The read authorizer credential for GitLab access.<br> - gitlab\_authorizer\_credential\_secret\_id: (Optional) The authorizer credential for GitLab access.<br> - gitlab\_webhook\_secret\_id: (Optional) The secret ID for the GitLab WebHook.<br> - gitlab\_enterprise\_host\_uri: (Optional) The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.<br> - gitlab\_enterprise\_service\_directory: (Optional) Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.<br> - gitlab\_enterprise\_ca\_certificate: (Optional) SSL certificate to use for requests to GitLab Enterprise.<br>Note: When using GITLABv2, specify `gitlab_read_authorizer_credential` and `gitlab_authorizer_credential` and `gitlab_webhook_secret_id`.<br>Note: When using GITHUBv2, specify `github_pat` and `github_app_id`.<br>Note: If 'cloudbuildv2\_repository\_config' variable is not configured, CSR (Cloud Source Repositories) will be used by default. | <pre>object({<br> repo_type = string # Supported values are: GITHUBv2, GITLABv2 and CSR<br> # repositories to be created<br> repositories = map(<br> object({<br> repository_name = string<br> repository_url = string<br> })<br> )<br> # Credential Config for each repository type<br> github_secret_id = optional(string)<br> github_app_id_secret_id = optional(string)<br> gitlab_read_authorizer_credential_secret_id = optional(string)<br> gitlab_authorizer_credential_secret_id = optional(string)<br> gitlab_webhook_secret_id = optional(string)<br> gitlab_enterprise_host_uri = optional(string)<br> gitlab_enterprise_service_directory = optional(string)<br> gitlab_enterprise_ca_certificate = optional(string)<br> })</pre> | n/a | yes |
| common\_folder\_id | Folder ID in which to create all application admin projects, must be prefixed with 'folders/' | `string` | n/a | yes |
| envs | Environments | <pre>map(object({<br> billing_account = string<br> folder_id = string<br> network_project_id = string<br> network_self_link = string<br> org_id = string<br> subnets_self_links = list(string)<br> }))</pre> | n/a | yes |
| location | Location for build buckets. | `string` | `"us-central1"` | no |
Expand Down
14 changes: 7 additions & 7 deletions 4-appfactory/envs/shared/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ variable "cloudbuildv2_repository_config" {
- github_app_id_secret_id: (Optional) The application ID for a GitHub App used for authentication.
- gitlab_read_authorizer_credential_secret_id: (Optional) The read authorizer credential for GitLab access.
- gitlab_authorizer_credential_secret_id: (Optional) The authorizer credential for GitLab access.
- gitlab_webhook_secret_id: (Optional) The secret ID for the GitLab WebHook..
- gitlab_webhook_secret_id: (Optional) The secret ID for the GitLab WebHook.
- gitlab_enterprise_host_uri: (Optional) The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.
- gitlab_enterprise_service_directory: (Optional) Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
- gitlab_enterprise_ca_certificate: (Optional) SSL certificate to use for requests to GitLab Enterprise.
Note: When using GITLABv2, specify `gitlab_read_authorizer_credential` and `gitlab_authorizer_credential` and `gitlab_webhook_secret_id`.
Note: When using GITHUBv2, specify `github_pat` and `github_app_id`.
Note: If 'cloudbuildv2_repository_config' variable is not configured, CSR (Cloud Source Repositories) will be used by default.
Expand All @@ -141,14 +144,11 @@ variable "cloudbuildv2_repository_config" {
gitlab_read_authorizer_credential_secret_id = optional(string)
gitlab_authorizer_credential_secret_id = optional(string)
gitlab_webhook_secret_id = optional(string)
gitlab_enterprise_host_uri = optional(string)
gitlab_enterprise_service_directory = optional(string)
gitlab_enterprise_ca_certificate = optional(string)
})

# If cloudbuildv2 is not configured, then auto-creation with CSR will be used
default = {
repo_type = "CSR"
repositories = {}
}

validation {
condition = (
var.cloudbuildv2_repository_config.repo_type == "GITHUBv2" ? (
Expand Down
2 changes: 1 addition & 1 deletion 4-appfactory/modules/app-group-baseline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| bucket\_force\_destroy | When deleting a bucket, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects. | `bool` | `false` | no |
| bucket\_prefix | Name prefix to use for buckets created. | `string` | `"bkt"` | no |
| cloudbuild\_sa\_roles | Optional to assign to custom CloudBuild SA. Map of project name or any static key to object with list of roles. Keys much match keys from var.envs | <pre>map(object({<br> roles = list(string)<br> }))</pre> | `{}` | no |
| cloudbuildv2\_repository\_config | Configuration for integrating repositories with Cloud Build v2:<br> - repo\_type: Specifies the type of repository. Supported types are 'GITHUBv2', 'GITLABv2', and 'CSR'.<br> - repositories: A map of repositories to be created. The key must match the exact name of the repository. Each repository is defined by:<br> - repository\_name: The name of the repository.<br> - repository\_url: The URL of the repository.<br> - github\_secret\_id: (Optional) The personal access token for GitHub authentication.<br> - github\_app\_id\_secret\_id: (Optional) The application ID for a GitHub App used for authentication.<br> - gitlab\_read\_authorizer\_credential\_secret\_id: (Optional) The read authorizer credential for GitLab access.<br> - gitlab\_authorizer\_credential\_secret\_id: (Optional) The authorizer credential for GitLab access.<br> - gitlab\_webhook\_secret\_id: (Optional) The secret ID for the GitLab WebHook..<br>Note: When using GITLABv2, specify `gitlab_read_authorizer_credential` and `gitlab_authorizer_credential` and `gitlab_webhook_secret_id`.<br>Note: When using GITHUBv2, specify `github_pat` and `github_app_id`.<br>Note: If 'cloudbuildv2\_repository\_config' variable is not configured, CSR (Cloud Source Repositories) will be used by default. | <pre>object({<br> repo_type = string # Supported values are: GITHUBv2, GITLABv2 and CSR<br> # repositories to be created<br> repositories = map(<br> object({<br> repository_name = string<br> repository_url = string<br> })<br> )<br> # Credential Config for each repository type<br> github_secret_id = optional(string)<br> github_app_id_secret_id = optional(string)<br> gitlab_read_authorizer_credential_secret_id = optional(string)<br> gitlab_authorizer_credential_secret_id = optional(string)<br> gitlab_webhook_secret_id = optional(string)<br> })</pre> | n/a | yes |
| cloudbuildv2\_repository\_config | Configuration for integrating repositories with Cloud Build v2:<br> - repo\_type: Specifies the type of repository. Supported types are 'GITHUBv2', 'GITLABv2', and 'CSR'.<br> - repositories: A map of repositories to be created. The key must match the exact name of the repository. Each repository is defined by:<br> - repository\_name: The name of the repository.<br> - repository\_url: The URL of the repository.<br> - github\_secret\_id: (Optional) The personal access token for GitHub authentication.<br> - github\_app\_id\_secret\_id: (Optional) The application ID for a GitHub App used for authentication.<br> - gitlab\_read\_authorizer\_credential\_secret\_id: (Optional) The read authorizer credential for GitLab access.<br> - gitlab\_authorizer\_credential\_secret\_id: (Optional) The authorizer credential for GitLab access.<br> - gitlab\_webhook\_secret\_id: (Optional) The secret ID for the GitLab WebHook.<br> - gitlab\_enterprise\_host\_uri: (Optional) The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.<br> - gitlab\_enterprise\_service\_directory: (Optional) Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.<br> - gitlab\_enterprise\_ca\_certificate: (Optional) SSL certificate to use for requests to GitLab Enterprise.<br>Note: When using GITLABv2, specify `gitlab_read_authorizer_credential` and `gitlab_authorizer_credential` and `gitlab_webhook_secret_id`.<br>Note: When using GITHUBv2, specify `github_pat` and `github_app_id`.<br>Note: If 'cloudbuildv2\_repository\_config' variable is not configured, CSR (Cloud Source Repositories) will be used by default. | <pre>object({<br> repo_type = string # Supported values are: GITHUBv2, GITLABv2 and CSR<br> # repositories to be created<br> repositories = map(<br> object({<br> repository_name = string<br> repository_url = string<br> })<br> )<br> # Credential Config for each repository type<br> github_secret_id = optional(string)<br> github_app_id_secret_id = optional(string)<br> gitlab_read_authorizer_credential_secret_id = optional(string)<br> gitlab_authorizer_credential_secret_id = optional(string)<br> gitlab_webhook_secret_id = optional(string)<br> gitlab_enterprise_host_uri = optional(string)<br> gitlab_enterprise_service_directory = optional(string)<br> gitlab_enterprise_ca_certificate = optional(string)<br> })</pre> | n/a | yes |
| cluster\_projects\_ids | Cluster projects ids. | `list(string)` | n/a | yes |
| create\_admin\_project | Boolean value that indicates whether a admin project should be created for the microservice. | `bool` | n/a | yes |
| create\_infra\_project | Boolean value that indicates whether an infrastructure project should be created for the microservice. | `bool` | n/a | yes |
Expand Down
3 changes: 3 additions & 0 deletions 4-appfactory/modules/app-group-baseline/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module "cloudbuild_repositories" {
gitlab_read_authorizer_credential_secret_id = var.cloudbuildv2_repository_config.gitlab_read_authorizer_credential_secret_id
gitlab_authorizer_credential_secret_id = var.cloudbuildv2_repository_config.gitlab_authorizer_credential_secret_id
gitlab_webhook_secret_id = var.cloudbuildv2_repository_config.gitlab_webhook_secret_id
gitlab_enterprise_host_uri = var.cloudbuildv2_repository_config.gitlab_enterprise_host_uri
gitlab_enterprise_service_directory = var.cloudbuildv2_repository_config.gitlab_enterprise_service_directory
gitlab_enterprise_ca_certificate = var.cloudbuildv2_repository_config.gitlab_enterprise_ca_certificate
}
cloud_build_repositories = var.cloudbuildv2_repository_config.repositories
}
Expand Down
8 changes: 7 additions & 1 deletion 4-appfactory/modules/app-group-baseline/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ variable "cloudbuildv2_repository_config" {
- github_app_id_secret_id: (Optional) The application ID for a GitHub App used for authentication.
- gitlab_read_authorizer_credential_secret_id: (Optional) The read authorizer credential for GitLab access.
- gitlab_authorizer_credential_secret_id: (Optional) The authorizer credential for GitLab access.
- gitlab_webhook_secret_id: (Optional) The secret ID for the GitLab WebHook..
- gitlab_webhook_secret_id: (Optional) The secret ID for the GitLab WebHook.
- gitlab_enterprise_host_uri: (Optional) The URI of the GitLab Enterprise host this connection is for. If not specified, the default value is https://gitlab.com.
- gitlab_enterprise_service_directory: (Optional) Configuration for using Service Directory to privately connect to a GitLab Enterprise server. This should only be set if the GitLab Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, calls to the GitLab Enterprise server will be made over the public internet. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
- gitlab_enterprise_ca_certificate: (Optional) SSL certificate to use for requests to GitLab Enterprise.
Note: When using GITLABv2, specify `gitlab_read_authorizer_credential` and `gitlab_authorizer_credential` and `gitlab_webhook_secret_id`.
Note: When using GITHUBv2, specify `github_pat` and `github_app_id`.
Note: If 'cloudbuildv2_repository_config' variable is not configured, CSR (Cloud Source Repositories) will be used by default.
Expand All @@ -172,6 +175,9 @@ variable "cloudbuildv2_repository_config" {
gitlab_read_authorizer_credential_secret_id = optional(string)
gitlab_authorizer_credential_secret_id = optional(string)
gitlab_webhook_secret_id = optional(string)
gitlab_enterprise_host_uri = optional(string)
gitlab_enterprise_service_directory = optional(string)
gitlab_enterprise_ca_certificate = optional(string)
})

validation {
Expand Down
10 changes: 7 additions & 3 deletions 4-appfactory/terraform.example.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ applications = {
}

cloudbuildv2_repository_config = {
repo_type = "CSR"
repo_type = "GITLABv2"
repositories = {
"hello-world" = {
repository_name = "hello-world"
repository_url = ""
repository_name = "hello-world-i-r"
repository_url = "https://gitlab.com/<replace-with-user-or-group>/hello-world-i-r.git"
}
}
# The Secret ID format is: projects/PROJECT_NUMBER/secrets/SECRET_NAME
gitlab_authorizer_credential_secret_id = "REPLACE_WITH_READ_API_SECRET_ID"
gitlab_read_authorizer_credential_secret_id = "REPLACE_WITH_READ_USER_SECRET_ID"
gitlab_webhook_secret_id = "REPLACE_WITH_WEBHOOK_SECRET_ID"
}
Loading

0 comments on commit 19bc4d2

Please sign in to comment.