-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Custom DC] Various setup improvements #2349
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,13 @@ | |
# 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. | ||
if [[ $LOCATION =~ ^[a-z]+-[a-z0-9]+$ ]]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: add a quick comment on what the regex is looking for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done. thanks! |
||
REGION=$LOCATION | ||
else | ||
ZONE=$LOCATION | ||
fi | ||
gcloud container clusters get-credentials $CLUSTER_NAME \ | ||
--region $REGION --project=$PROJECT_ID | ||
${REGION:+--region $REGION} ${ZONE:+--zone $ZONE} --project=$PROJECT_ID | ||
|
||
# Create namespace if it does not exist. | ||
kubectl create namespace website \ | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,24 +13,47 @@ | |
# limitations under the License. | ||
|
||
locals { | ||
# Example cluster name: datacommons-us-central1 | ||
cluster_name = format("%s-%s%s",var.cluster_name_prefix,var.region, var.resource_suffix) | ||
# Example cluster name: datacommons-us-central1 or datacommons-us-central1-a | ||
cluster_name = format("%s-%s%s",var.cluster_name_prefix,var.location, var.resource_suffix) | ||
} | ||
|
||
resource "null_resource" "gke_cluster" { | ||
provisioner "local-exec" { | ||
command = "sh create_cluster.sh" | ||
working_dir = path.module | ||
resource "google_container_cluster" "primary" { | ||
name = local.cluster_name | ||
location = var.location | ||
|
||
environment = { | ||
PROJECT_ID = var.project_id | ||
CLUSTER_NAME = local.cluster_name | ||
NODES = var.num_nodes | ||
REGION = var.region | ||
} | ||
# We can't create a cluster with no node pool defined, but we want to only use | ||
# separately managed node pools. So we create the smallest possible default | ||
# node pool and immediately delete it. | ||
remove_default_node_pool = true | ||
initial_node_count = 1 | ||
networking_mode = "VPC_NATIVE" | ||
|
||
workload_identity_config { | ||
workload_pool = "${var.project_id}.svc.id.goog" | ||
} | ||
|
||
ip_allocation_policy { | ||
cluster_ipv4_cidr_block = "/14" | ||
} | ||
} | ||
|
||
resource "google_container_node_pool" "gke_node_pools" { | ||
name = local.cluster_name | ||
location = var.location | ||
cluster = google_container_cluster.primary.name | ||
node_count = var.num_nodes | ||
|
||
node_config { | ||
machine_type = "e2-highmem-4" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you check if we can use a weaker machine_type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following our kustomize template, I'm changing the memory from website container 8G -> 3G, ESP 2G -> 1G. Which will be something like 12.75G occupied of 15.X G available in a e2-standard-4. However, the cost saving is only $30 or so (from ~$132 to ~$98). If there's anything that we shouldn't cheap out on imo it's the machine type, because k8s under pressure will give all sorts of weird errors. We may also need more resources for new services. I think keeping this machine type is appropriate but will leave the final desicion to you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then sounds good to keep this. In that case, can revert the mem change above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping the mem changes for now to conserve resources for other potential pods (like argo). Please see the response to Julia's comment. |
||
oauth_scopes = [ | ||
"https://www.googleapis.com/auth/cloud-platform" | ||
] | ||
} | ||
|
||
depends_on = [ | ||
google_container_cluster.primary | ||
] | ||
} | ||
|
||
resource "null_resource" "gke_cluster_configuration" { | ||
provisioner "local-exec" { | ||
|
@@ -40,12 +63,13 @@ resource "null_resource" "gke_cluster_configuration" { | |
environment = { | ||
PROJECT_ID = var.project_id | ||
CLUSTER_NAME = local.cluster_name | ||
REGION = var.region | ||
LOCATION = var.location | ||
WEB_ROBOT_SA_EMAIL = var.web_robot_sa_email | ||
} | ||
} | ||
|
||
depends_on = [ | ||
null_resource.gke_cluster | ||
google_container_cluster.primary, | ||
google_container_node_pool.gke_node_pools | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is good, would be nice to have more static resources like this (so it's easier to know what it is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, will follow this style from now on!