Terraform code to deploy GKS cluster with Apache Kafka using a static IP
-
Enabling Kubernetes Engine API and IAM Service Account Credentials API in Google Cloud
-
Create a service account: Click Create Service Account at the top of the page. You will be prompted to enter details like the Service account name, Service account ID, and a description.
-
Grant service account permissions:
- Compute Admin
- Compute Network Admin
- Compute Public IP Admin
- Editor
- Kubernetes Engine Admin
- Kubernetes Engine Cluster Admin
- Secret Manager Secret Accessor
- Service Account Admin
- Service Account User
- Secret Manager Admin
- Generate a key file: Once the service account is created, you can create a JSON key file for it. Click on the three dots under Actions, then Manage keys, and then Add Key > Create new key. Make sure JSON is selected as the Key type, and then click Create. The JSON key file will be downloaded to your computer.
cd terraform/gke
terraform apply -auto-approve
cd terraform/kafka
terraform apply -auto-approve
gcloud compute addresses describe kafka-static-ip --region=us-east1
gcloud container clusters get-credentials training-cluster --region=us-east1-b
You will need to create a secret in Google Cloud called BEARER_TOKEN
which contains the token to use with Twitter
Likely you will need to grant access to service account to access to MASTODON_ACCESS_TOKEN
secret in GCP
# Get service account email in from gke output
terraform output google_service_account_sa_email
# Before grant access, login with an account with `setIamPolicy` privileges
gcloud config set account admin_account
# Grant access to the service account to access to GCP Secret Manager
gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
--member=serviceAccount:YOUR_SERVICE_ACCOUNT_EMAIL \
--role=roles/secretmanager.secretAccessor
docker run -d \
--name kafka-ui \
-p 8080:8080 \
-e DYNAMIC_CONFIG_ENABLED='true' \
-v /Users/miguel/Training/training-kafka/kafka-ui/config.yml:/etc/kafkaui/dynamic_config.yaml \
provectuslabs/kafka-ui:latest
gcloud auth print-access-token --impersonate-service-account=google-app-service-account@training-386613.iam.gserviceaccount.com