Skip to content
Snippets Groups Projects
Commit ea173579 authored by Viktor Nagy's avatar Viktor Nagy
Browse files

Update README.md, variables.tf, group_cluster.tf files

parent fb6c31bf
No related branches found
No related tags found
No related merge requests found
......@@ -35,12 +35,24 @@ them in your code.
## Configure your deployment
Some defaults in this sample need to be configured to match your desired infrastructure.
Some variables need to be configured to match your desired infrastructure. These values can be set as Terraform variables. Optional variables have a default set already. See [`variables.tf`](./variables.tf) for these defaults.
- In the [`gke.tf`](gke.tf) file.
- **(required)** Override the GCP `project` name under the [`gke.tf`](gke.rf) file.
- **(optional)** Choose also the `region` and `zone` that you would like to deploy your cluster to.
- In the [`group_cluster.tf`](group_cluster.tf) file.
- **(required)** Override the full_path to point to your GitLab desired group name.
### Required
Set the following environment variables or edit the default values in [`variables.tf`](./variables.tf)
- `TF_VAR_gcp_project`: Override the GCP `project` name.
- `TF_VAR_gitlab_group`: Set the GitLab group to attach the cluster to GitLab.
### Optional
- `TF_VAR_gcp_region`: Set the region for your cluster.
- `TF_VAR_cluster_name`: Set the name of the cluster.
- `TF_VAR_machine_type`: Set the machine type for the Kubernetes nodes.
- `TF_VAR_cluster_description`: Set a description for the cluster. We recommend setting this to `$CI_PROJECT_URL`.
- `TF_VAR_base_domain`: Set to the base domain to provision resources under.
- `TF_VAR_environment_scope`: Set to the GitLab environment name to associate the cluster with.
## More info
You can refer to the [GitLab Terraform provider](https://registry.terraform.io/providers/gitlabhq/gitlab/latest/docs) and the [Google Terraform provider](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference) for further resource options.
data "gitlab_group" "iac-demo-apps" {
full_path = "iac-demo/apps"
data "gitlab_group" "iac-group" {
full_path = var.gitlab_group
}
resource "gitlab_group_cluster" "gke_cluster" {
group = data.gitlab_group.iac-demo-apps.id
group = data.gitlab_group.iac-group.id
name = google_container_cluster.primary.name
domain = "example.com"
environment_scope = "*"
domain = var.base_domain
environment_scope = var.environment_scope
kubernetes_api_url = "https://${google_container_cluster.primary.endpoint}"
kubernetes_token = data.kubernetes_secret.gitlab-admin-token.data.token
kubernetes_ca_cert = trimspace(base64decode(google_container_cluster.primary.master_auth.0.cluster_ca_certificate))
......
variable "gcp_project" {
type = string
default = "gcp-project"
description = "The name of the Google Cloud Project where the cluster is to be provisioned"
}
variable "gitlab_group" {
type = string
description = "Override the full_path to point to your GitLab desired group name"
}
variable "gcp_region" {
type = string
default = "us-central1"
......@@ -27,3 +31,15 @@ variable "cluster_description" {
default = "This cluster is defined in GitLab"
description = "A description for the cluster. We recommend adding the \$CI_PROJECT_URL variable to describe where the cluster is configured."
}
variable "base_domain" {
type = string
default = "example.com"
description = "The base domain to configure with this cluster in GitLab"
}
variable "environment_scope" {
type = string
default = "*"
description = "The GitLab environment name to associate this cluster with"
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment