-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
135 lines (113 loc) · 3.71 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Copyright 2023 StreamNative, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
terraform {
required_version = ">=1.0.0"
required_providers {
google = {
source = "hashicorp/google"
version = "~>5.19"
}
google-beta = {
source = "hashicorp/google-beta"
version = "~> 5.19"
}
helm = {
source = "hashicorp/helm"
version = "2.2.0"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 2.27.0"
}
}
}
module "sn_crds" {
source = "streamnative/charts/helm//modules/crds"
version = "v0.8.4"
depends_on = [
module.sn_cluster
]
}
provider "google" {
project = var.project_id
region = var.region
}
provider "helm" {
kubernetes {
host = format("https://%s", data.google_container_cluster.cluster.endpoint)
cluster_ca_certificate = base64decode(data.google_container_cluster.cluster.master_auth[0].cluster_ca_certificate)
token = data.google_client_config.provider.access_token
}
}
provider "kubernetes" {
host = format("https://%s", data.google_container_cluster.cluster.endpoint)
cluster_ca_certificate = base64decode(data.google_container_cluster.cluster.master_auth[0].cluster_ca_certificate)
token = data.google_client_config.provider.access_token
}
# Configure variable defaults here, with a .tfvars file, or provide them to terraform when prompted.
variable "environment" {
default = "example"
description = ""
}
variable "project_id" {
description = "GCP project to deploy into"
}
variable "region" {
default = "northamerica-northeast1"
description = "GCP region to deploy in"
}
variable "domain" {
default = "g.example.dev."
description = "Google DNS domain for DNS records"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "cluster" {
name = module.sn_cluster.name
location = var.region
}
resource "random_pet" "cluster_name" {
length = 1
}
locals {
organization = "streamnative"
cluster_name = format("sn-%s-%s", random_pet.cluster_name.id, var.environment)
service_domain = format("%s.%s.%s", local.cluster_name, local.organization, var.domain)
}
data "google_container_engine_versions" "versions" {
location = var.region
version_prefix = "1.21."
}
# Add this repo as a git submodule and refer to its relative path (or clone and point to the location)
module "sn_cluster" {
source = "../../"
cluster_name = local.cluster_name
enable_func_pool = false
kubernetes_version = data.google_container_engine_versions.versions.latest_master_version
project_id = var.project_id
region = var.region
suffix = random_pet.cluster_name.id
vpc_network = "default"
vpc_subnet = "default"
}
# Note: If the func pool is enabled, you must wait for the cluster to be ready before running this module
module "sn_bootstrap" {
source = "streamnative/charts/helm"
version = "0.8.4"
# Note: OLM for GKE is still a WIP as we work on a long term solution for managing our operator images
enable_olm = true
olm_registry = "gcr.io/affable-ray-226821/streamnative/pulsar-operators/registry/pulsar-operators:production"
depends_on = [
module.sn_cluster
]
}