Skip to content

Commit

Permalink
fix: revert "feat: add option to use connect gateway (#155)" (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody authored Sep 13, 2023
1 parent 65106af commit 345e4e5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
1 change: 0 additions & 1 deletion modules/kubectl-wrapper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ module "kubectl" {
| service\_account\_key\_file | Path to service account key file to auth as for running `gcloud container clusters get-credentials`. | `string` | `""` | no |
| skip\_download | Whether to skip downloading gcloud (assumes gcloud and kubectl is already available outside the module) | `bool` | `true` | no |
| upgrade | Whether to upgrade gcloud at runtime | `bool` | `true` | no |
| use\_connect\_gateway | Use Connect Gateway to obtain credentials. The provided cluster\_name will be used as the fleet membership name. | `bool` | `false` | no |
| use\_existing\_context | Use existing kubecontext to auth kube-api. | `bool` | `false` | no |
| use\_tf\_google\_credentials\_env\_var | Use `GOOGLE_CREDENTIALS` environment variable to run `gcloud auth activate-service-account` with. Optional. | `bool` | `false` | no |

Expand Down
5 changes: 2 additions & 3 deletions modules/kubectl-wrapper/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020-2023 Google LLC
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,7 @@
*/

locals {
connect_cmd = var.use_connect_gateway ? "fleet memberships" : "clusters"
base_cmd = "${var.cluster_name} ${var.cluster_location} ${var.project_id} ${var.internal_ip} ${var.use_existing_context} ${local.connect_cmd}"
base_cmd = "${var.cluster_name} ${var.cluster_location} ${var.project_id} ${var.internal_ip} ${var.use_existing_context}"
}

module "gcloud_kubectl" {
Expand Down
13 changes: 6 additions & 7 deletions modules/kubectl-wrapper/scripts/kubectl_wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Copyright 2020-2023 Google LLC
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

set -xeo pipefail

if [ "$#" -lt 6 ]; then
if [ "$#" -lt 5 ]; then
>&2 echo "Not all expected arguments set."
exit 1
fi
Expand All @@ -26,11 +26,10 @@ LOCATION=$2
PROJECT_ID=$3
INTERNAL=$4
USE_EXISTING_CONTEXT=$5
CONNECT_CMD=$6
ENABLE_IMPERSONATE_SERVICE_ACCOUNT=$7
IMPERSONATE_SERVICE_ACCOUNT=$8
ENABLE_IMPERSONATE_SERVICE_ACCOUNT=$6
IMPERSONATE_SERVICE_ACCOUNT=$7

shift 6
shift 5

if $USE_EXISTING_CONTEXT ;then

Expand All @@ -52,7 +51,7 @@ else

LOCATION_TYPE=$(grep -o "-" <<< "${LOCATION}" | wc -l)

CMD="gcloud container ${CONNECT_CMD} get-credentials ${CLUSTER_NAME} --project ${PROJECT_ID}"
CMD="gcloud container clusters get-credentials ${CLUSTER_NAME} --project ${PROJECT_ID}"
if [[ "${ENABLE_IMPERSONATE_SERVICE_ACCOUNT}" == true ]]; then
CMD+=" --impersonate-service-account ${IMPERSONATE_SERVICE_ACCOUNT}"
shift 2
Expand Down
6 changes: 0 additions & 6 deletions modules/kubectl-wrapper/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,3 @@ variable "impersonate_service_account" {
description = "An optional service account to impersonate for gcloud commands. If this service account is not specified, the module will use Application Default Credentials."
default = ""
}

variable "use_connect_gateway" {
type = bool
description = "Use Connect Gateway to obtain credentials. The provided cluster_name will be used as the fleet membership name."
default = false
}

0 comments on commit 345e4e5

Please sign in to comment.