Skip to content

Commit

Permalink
tf fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rsgowman committed Mar 6, 2024
1 parent 9558d1b commit 5c6cd2d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ resource "kubernetes_namespace_v1" "custom-metrics" {
resource "kubernetes_service_account_v1" "custom-metrics-stackdriver-adapter-no-wi" {
count = var.workload_identity.enabled ? 0 : 1
metadata {
name = "custom-metrics-stackdriver-adapter"
name = "custom-metrics-stackdriver-adapter"
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
}
}

resource "kubernetes_service_account_v1" "custom-metrics-stackdriver-adapter-wi" {
count = var.workload_identity.enabled ? 1 : 0
metadata {
name = "custom-metrics-stackdriver-adapter"
name = "custom-metrics-stackdriver-adapter"
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
annotations = {
"iam.gke.io/gcp-service-account" = google_service_account.cmsa-sa[0].email
Expand All @@ -29,8 +29,8 @@ resource "kubernetes_cluster_role_binding_v1" "custom-metrics-system-auth-delega
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "system:auth-delegator"
kind = "ClusterRole"
name = "system:auth-delegator"
}
subject {
kind = "ServiceAccount"
Expand All @@ -44,13 +44,13 @@ resource "kubernetes_cluster_role_binding_v1" "custom-metrics-system-auth-delega

resource "kubernetes_role_binding_v1" "custom-metrics-auth-reader" {
metadata {
name = "custom-metrics-auth-reader"
name = "custom-metrics-auth-reader"
namespace = "kube-system"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "Role"
name = "extension-apiserver-authentication-reader"
kind = "Role"
name = "extension-apiserver-authentication-reader"
}
subject {
kind = "ServiceAccount"
Expand All @@ -68,8 +68,8 @@ resource "kubernetes_cluster_role_v1" "custom-metrics-resource-reader" {
}
rule {
api_groups = [""]
resources = ["pods", "nodes", "nodes/stats"]
verbs = ["get", "list", "watch"]
resources = ["pods", "nodes", "nodes/stats"]
verbs = ["get", "list", "watch"]
}
}

Expand All @@ -79,8 +79,8 @@ resource "kubernetes_cluster_role_binding_v1" "custom-metrics-resource-reader" {
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = kubernetes_cluster_role_v1.custom-metrics-resource-reader.metadata[0].name
kind = "ClusterRole"
name = kubernetes_cluster_role_v1.custom-metrics-resource-reader.metadata[0].name
}
subject {
kind = "ServiceAccount"
Expand All @@ -94,10 +94,10 @@ resource "kubernetes_cluster_role_binding_v1" "custom-metrics-resource-reader" {

resource "kubernetes_deployment_v1" "custom-metrics-stackdriver-adapter" {
metadata {
name = "custom-metrics-stackdriver-adapter"
name = "custom-metrics-stackdriver-adapter"
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
labels = {
run = "custom-metrics-stackdriver-adapter"
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
}
}
Expand All @@ -106,16 +106,16 @@ resource "kubernetes_deployment_v1" "custom-metrics-stackdriver-adapter" {

selector {
match_labels = {
run = "custom-metrics-stackdriver-adapter"
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
}
}

template {
metadata {
labels = {
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
"kubernetes.io/cluster-service" = "true"
}
}
Expand All @@ -127,17 +127,17 @@ resource "kubernetes_deployment_v1" "custom-metrics-stackdriver-adapter" {
)

container {
image = "gcr.io/gke-release/custom-metrics-stackdriver-adapter:v0.14.2-gke.0"
image = "gcr.io/gke-release/custom-metrics-stackdriver-adapter:v0.14.2-gke.0"
image_pull_policy = "Always"
name = "pod-custom-metrics-stackdriver-adapter"
command = ["/adapter", "--use-new-resource-model=true", "--fallback-for-container-metrics=true"]
name = "pod-custom-metrics-stackdriver-adapter"
command = ["/adapter", "--use-new-resource-model=true", "--fallback-for-container-metrics=true"]
resources {
limits = {
cpu = "250m"
cpu = "250m"
memory = "200Mi"
}
requests = {
cpu = "250m"
cpu = "250m"
memory = "200Mi"
}
}
Expand All @@ -149,23 +149,23 @@ resource "kubernetes_deployment_v1" "custom-metrics-stackdriver-adapter" {

resource "kubernetes_service_v1" "custom-metrics-stackdriver-adapter" {
metadata {
name = "custom-metrics-stackdriver-adapter"
name = "custom-metrics-stackdriver-adapter"
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
labels = {
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
"kubernetes.io/cluster-service" = "true"
"kubernetes.io/name" = "Adapter"
"kubernetes.io/name" = "Adapter"
}
}
spec {
selector = {
run = "custom-metrics-stackdriver-adapter"
run = "custom-metrics-stackdriver-adapter"
k8s-app = "custom-metrics-stackdriver-adapter"
}
port {
port = 443
protocol = "TCP"
port = 443
protocol = "TCP"
target_port = 443
}
type = "ClusterIP"
Expand All @@ -178,11 +178,11 @@ resource "kubernetes_api_service_v1" "v1beta1-custom-metrics-k8s-io" {
}
spec {
insecure_skip_tls_verify = true
group = "custom.metrics.k8s.io"
group_priority_minimum = 100
version_priority = 100
group = "custom.metrics.k8s.io"
group_priority_minimum = 100
version_priority = 100
service {
name = kubernetes_service_v1.custom-metrics-stackdriver-adapter.metadata[0].name
name = kubernetes_service_v1.custom-metrics-stackdriver-adapter.metadata[0].name
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
}
version = "v1beta1"
Expand All @@ -195,11 +195,11 @@ resource "kubernetes_api_service_v1" "v1beta2-custom-metrics-k8s-io" {
}
spec {
insecure_skip_tls_verify = true
group = "custom.metrics.k8s.io"
group_priority_minimum = 100
version_priority = 200
group = "custom.metrics.k8s.io"
group_priority_minimum = 100
version_priority = 200
service {
name = kubernetes_service_v1.custom-metrics-stackdriver-adapter.metadata[0].name
name = kubernetes_service_v1.custom-metrics-stackdriver-adapter.metadata[0].name
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
}
version = "v1beta2"
Expand All @@ -212,11 +212,11 @@ resource "kubernetes_api_service_v1" "v1beta1-external-metrics-k8s-io" {
}
spec {
insecure_skip_tls_verify = true
group = "external.metrics.k8s.io"
group_priority_minimum = 100
version_priority = 100
group = "external.metrics.k8s.io"
group_priority_minimum = 100
version_priority = 100
service {
name = kubernetes_service_v1.custom-metrics-stackdriver-adapter.metadata[0].name
name = kubernetes_service_v1.custom-metrics-stackdriver-adapter.metadata[0].name
namespace = kubernetes_namespace_v1.custom-metrics.metadata[0].name
}
version = "v1beta1"
Expand All @@ -229,12 +229,12 @@ resource "kubernetes_cluster_role_binding_v1" "external-metrics-reader" {
}
role_ref {
api_group = "rbac.authorization.k8s.io"
kind = "ClusterRole"
name = "external-metrics-reader"
kind = "ClusterRole"
name = "external-metrics-reader"
}
subject {
kind = "ServiceAccount"
name = "horizontal-pod-autoscaler"
kind = "ServiceAccount"
name = "horizontal-pod-autoscaler"
namespace = "kube-system"
}
}
Expand All @@ -247,19 +247,19 @@ resource "kubernetes_cluster_role_binding_v1" "external-metrics-reader" {
# - annotate the cmsa service account (done above)

resource "google_service_account" "cmsa-sa" {
count = var.workload_identity.enabled ? 1 : 0
count = var.workload_identity.enabled ? 1 : 0
account_id = "cmsa-sa"
project = var.workload_identity.project_id
project = var.workload_identity.project_id
}

# Equivalent to:
# gcloud projects add-iam-policy-binding PROJECT_ID \
# --member=serviceAccount:cmsa-sa@PROJECT_ID.iam.gserviceaccount.com \
# --role=roles/monitoring.viewer
resource "google_project_iam_binding" "cmsa-project-binding" {
count = var.workload_identity.enabled ? 1 : 0
count = var.workload_identity.enabled ? 1 : 0
project = var.workload_identity.project_id
role = "roles/monitoring.viewer"
role = "roles/monitoring.viewer"
members = [
"serviceAccount:${google_service_account.cmsa-sa[0].account_id}@${var.workload_identity.project_id}.iam.gserviceaccount.com"
]
Expand All @@ -271,8 +271,8 @@ resource "google_project_iam_binding" "cmsa-project-binding" {
# --member "serviceAccount:PROJECT_ID.svc.id.goog[custom-metrics/custom-metrics-stackdriver-adapter]" \
# cmsa-sa@PROJECT_ID.iam.gserviceaccount.com
resource "google_service_account_iam_member" "cmsa-bind-to-gsa" {
count = var.workload_identity.enabled ? 1 : 0
count = var.workload_identity.enabled ? 1 : 0
service_account_id = google_service_account.cmsa-sa[0].name
role = "roles/iam.workloadIdentityUser"
member = "serviceAccount:${var.workload_identity.project_id}.svc.id.goog[custom-metrics/custom-metrics-stackdriver-adapter]"
role = "roles/iam.workloadIdentityUser"
member = "serviceAccount:${var.workload_identity.project_id}.svc.id.goog[custom-metrics/custom-metrics-stackdriver-adapter]"
}
8 changes: 4 additions & 4 deletions benchmarks/inference-server/text-generation-inference/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ locals {
}

module "custom_metrics_stackdriver_adapter" {
count = local.custom_metrics_enabled ? 1 : 0
count = local.custom_metrics_enabled ? 1 : 0
source = "./custom-metrics-stackdriver-adapter"
workload_identity = {
enabled = true
enabled = true
project_id = var.project_id
}
}
Expand All @@ -78,8 +78,8 @@ resource "kubernetes_manifest" "hpa-cpu" {
manifest = yamldecode(templatefile(local.hpa_cpu_template, {
namespace = var.namespace
hpa_averagevalue_target = var.hpa_averagevalue_target
hpa_min_replicas = var.hpa_min_replicas
hpa_max_replicas = var.hpa_max_replicas
hpa_min_replicas = var.hpa_min_replicas
hpa_max_replicas = var.hpa_max_replicas
}))
}

Expand Down

0 comments on commit 5c6cd2d

Please sign in to comment.