Installing a GCP connector on GKE using Terraform
Create a connector on Google Kubernetes Engine
Connectors are secure on-premises components that link Apono to your resources:
No secrets are read, cached, or stored
No account admin privileges need to be granted to Apono
The connector contacts your secret store or key vault to sync data or provision access
Once set up, this connector will enable you to sync data from cloud applications and grant and revoke access permissions through Google Kubernetes Engine (GKE).
Prerequisites
Apono Token
Account-specific Apono authentication value Use the following steps to obtain your token:
On the Connectors page, click Install Connector. The Install Connector page appears.
Click Cloud installation.
Click Cloud installation > GCP > Install and Connect GCP Project > CLI (GKE).
Copy the token listed on the page in step 1.
Google Cloud Command Line Interface (Google Cloud CLI)
Command-line interface used to manage Google Cloud resources
Google Cloud Information
Information for your Google Cloud instance:
(Organization) Organization ID
Google Cloud Region
GKE Cluster Name
GKE Cluster Region
Tag Key-Value Pairs (if used)
Optional:
Apono Connector ID
Service Account Name
Namespace
Owner Role
Google Cloud role that provides Owner permissions for the project or organization
Install a connector
Use the following sections to install a connector for either your Google Project or Google Organization.
Project
Follow these steps to install an Apono connector for a Google Project:
In your shell environment, log in to Google Cloud with an account possessing Owner permissions.
gcloud auth application-default login
At the shell prompt, set the environment variables.
export TF_VAR_PROJECT_ID="<GCP_PROJECT_ID>"
export TF_VAR_REGION="<GCP_REGION>"
export TF_VAR_NAME="<GKE_CLUSTER_NAME>"
export TF_VAR_LOCATION="<GCP_CLUSTER_REGION>"
export TF_VAR_APONO_TOKEN="<APONO_TOKEN>"
export TF_VAR_TAGS="<{tag1="value1"}>"
(Optional) Set the following optional environment variables.
export TF_VAR_CONNECTOR_ID="<APONO_CONNECTOR_NAME>"
export TF_VAR_SERVICE_ACCOUNT_NAME="<GCP_SERVICE_ACCOUNT_NAME>"
export TF_VAR_NAMESPACE="<NAMESPACE>"
In a new or existing Terraform (.tf) file, add the following provider and module information to create a connector.
provider "google" {
project = "{var.PROJECT_ID}"
region = "{var.REGION}"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "gke" {
name = "{var.NAME}"
location = "{var.LOCATION}"
}
provider "helm" {
kubernetes{
host = "https://${data.google_container_cluster.gke.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate,)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
module "apono-connector" {
source = "github.com/apono-io/terraform-modules//gcp/organization-wide-connector/gke/stacks/apono-connector"
connectorId = "{var.CONNECTOR_ID}" //OPTIONAL
aponoToken = "{var.APONO_TOKEN}"
projectId = "{var.PROJECT_ID}"
serviceAccountName = "{var.SERVICE_ACCOUNT_NAME}" //OPTIONAL
namespace = "{var.NAMESPACE}" //OPTIONAL
tags = "{var.TAGS}"
}
At the Terraform CLI, download and install the provider plugin and module.
terraform init
Apply the Terraform changes. The proposed changes and a confirmation prompt will be listed.
terraform apply
Enter yes to confirm deploying the changes to your Google Project instance.
On the Connectors page, verify that the connector has been deployed.
Organization
Follow these steps to install an Apono connector for a Google Organization:
In your shell environment, log in to Google Cloud with an account possessing Organization Administrator permissions.
gcloud alpha auth application-default login
At the shell prompt, set the environment variables.
export TF_VAR_PROJECT_ID="<GCP_PROJECT_ID>"
export TF_VAR_REGION="<GCP_REGION>"
export TF_VAR_NAME="<GKE_CLUSTER_NAME>"
export TF_VAR_LOCATION="<GCP_CLUSTER_REGION>"
export TF_VAR_APONO_TOKEN="<APONO_TOKEN>"
export TF_VAR_ORGANIZATION_ID="<GCP_ORGANIZATION_ID>"
export TF_VAR_TAGS="<{tag1="value1"}>"
(Optional) Set the following optional environment variables.
export TF_VAR_CONNECTOR_ID="<APONO_CONNECTOR_NAME>"
export TF_VAR_SERVICE_ACCOUNT_NAME="<GCP_SERVICE_ACCOUNT_NAME>"
export TF_VAR_NAMESPACE="<NAMESPACE>"
In a new or existing Terraform (.tf) file, add the following provider and module information to create a connector.
provider "google" {
project = "{var.PROJECT_ID}"
region = "{var.REGION}"
}
data "google_client_config" "provider" {}
data "google_container_cluster" "gke" {
name = "{var.NAME}"
location = "{var.LOCATION}"
}
provider "helm" {
kubernetes{
host = "https://${data.google_container_cluster.gke.endpoint}"
token = data.google_client_config.provider.access_token
cluster_ca_certificate = base64decode(
data.google_container_cluster.gke.master_auth[0].cluster_ca_certificate,)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
command = "gke-gcloud-auth-plugin"
}
}
}
module "apono-connector" {
source = "github.com/apono-io/terraform-modules//gcp/organization-wide-connector/gke/stacks/apono-connector"
connectorId = "{var.CONNECTOR_ID}" //OPTIONAL
aponoToken = "{var.APONO_TOKEN}"
projectId = "{var.PROJECT_ID}"
organizationId = "{var.ORGANIZATION_ID}"
serviceAccountName = "{var.SERVICE_ACCOUNT_NAME}" //OPTIONAL
namespace = "{var.NAMESPACE}" //OPTIONAL
tags = "{var.TAGS}"
}
At the Terraform CLI, download and install the provider plugin and module.
terraform init
Apply the Terraform changes. The proposed changes and a confirmation prompt will be listed.
terraform apply
Enter yes to confirm deploying the changes to your Google Organization instance.
On the Connectors page, verify that the connector has been deployed.
FAQ
Last updated
Was this helpful?