Install on Google Cloud
This page is the Google Cloud variant of Install on Kubernetes. The Authwise operator deploys the same workloads on Google Kubernetes Engine (GKE) as on any other cluster. What changes is where the database, the keys, and the uploaded assets live, and how pods get a Google Cloud identity. Read the Kubernetes page first; the sections here link to it rather than repeat it.
The operator runs an install’s platform service in one of two ways on Google
Cloud. You choose with a block under spec.platform:
- platform-hosted (
spec.platform.hosted). Keys live in a keyset Secret you generate, and assets live on a persistent disk. This is the shape the Kubernetes page describes. - platform-gcp (
spec.platform.gcp, operator v0.35.0 or later). Cloud KMS wraps the keys, and a Cloud Storage bucket holds the assets. The service authenticates with Workload Identity Federation for GKE, so no key material or credential is stored in the cluster. This is the shape the production planes run.
| platform-hosted | platform-gcp | |
|---|---|---|
| Deployed by | The operator | The operator |
| Issuer and secret keys | A keyset file in a Secret | A Cloud KMS key |
| Uploaded assets | A PersistentVolumeClaim | A Cloud Storage bucket |
| Pod identity | None needed | Workload Identity Federation for GKE, on the install’s ServiceAccount |
| SMTP relay, SendGrid or SES, configured in the install | The same |
Both run the identity server’s database on Cloud SQL.
Before you begin
Section titled “Before you begin”The Kubernetes prerequisites apply, with the database, object storage, and email items replaced by the following.
- A GKE cluster, Standard or Autopilot. For platform-gcp, the cluster
must have Workload Identity Federation for GKE enabled. Autopilot clusters
always do; a Standard cluster needs
--workload-pool=PROJECT_ID.svc.id.googand node pools that run the GKE metadata server. - A Cloud SQL for PostgreSQL instance with a private IP address on the cluster’s VPC network. The workloads connect to it directly. The operator’s pod template cannot add a Cloud SQL Auth Proxy sidecar, so public IP with the proxy is not an option for operator-managed workloads.
- An ingress controller. This page uses ingress-nginx, which provisions a passthrough Network Load Balancer on GKE. Point the three DNS records at its external IP address.
- Tools:
gcloud, authenticated to a project where you can administer Cloud SQL, Cloud KMS, Cloud Storage, and IAM, in addition tokubectl,kustomize,git,jq, and Docker.
The operator pulls platform-gcp from registry.authwise.com, with the same
registry credential as the install’s other images: a group deploy token
with the read_registry scope. The operator release pins the image
version.
Create the Google Cloud resources
Section titled “Create the Google Cloud resources”The placeholders are PROJECT_ID, the project; LOCATION, a region such as
us-central1; INSTANCE, the Cloud SQL instance name; NAMESPACE, the
Kubernetes namespace the install lives in; and BUCKET, a globally unique
bucket name.
-
Require encrypted connections to the instance, and save its server certificate authority (CA):
Terminal window gcloud sql instances patch INSTANCE --ssl-mode=ENCRYPTED_ONLYgcloud sql instances describe INSTANCE \--format='value(serverCaCert.cert)' > cloudsql-ca.pemgcloud sql instances describe INSTANCE --format='yaml(ipAddresses)'DB_HOSTis the address whosetypeisPRIVATE. Cloud SQL issues a per-instance CA whose server certificate names the instance connection name, not the IP address, so the platform service verifies it withverify-carather thanverify-full. -
Create the database user the install runs as:
Terminal window gcloud sql users create authwise --instance=INSTANCE --password=DB_PASSWORDA user created this way holds the
cloudsqlsuperuserrole, which carriesCREATEDBandCREATEROLE, so one user serves as the owner of both the identity server’s and the platform service’s databases. Splitting them is a hardening step, not a prerequisite. -
platform-gcp only. Create the key that wraps the issuer keys and the bucket that holds the assets:
Terminal window gcloud kms keyrings create authwise --location=LOCATIONgcloud kms keys create primary --keyring=authwise --location=LOCATION \--purpose=encryptiongcloud storage buckets create gs://BUCKET --location=LOCATION \--uniform-bucket-level-access --public-access-preventionThe key’s resource name is
projects/PROJECT_ID/locations/LOCATION/keyRings/authwise/cryptoKeys/primary. The install’sissuerKeys.keyNamecarries that whole string. Cloud KMS key rings and keys cannot be deleted, and the service writes the key name into every ciphertext it produces, so choose the names once. -
platform-gcp only. Grant the install’s Kubernetes ServiceAccount access to the key and the bucket. The operator creates that ServiceAccount and runs every workload of the install as it. Its name is
<install>-identity-server, which isauthwise-identity-serverfor the sample below, unlessspec.serviceAccount.namesets another. IAM accepts the binding before the ServiceAccount exists.Terminal window PROJECT_NUMBER=$(gcloud projects describe PROJECT_ID --format='value(projectNumber)')MEMBER="principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/PROJECT_ID.svc.id.goog/subject/ns/NAMESPACE/sa/authwise-identity-server"gcloud kms keys add-iam-policy-binding primary \--keyring=authwise --location=LOCATION \--member="$MEMBER" --role=roles/cloudkms.cryptoKeyEncrypterDecryptergcloud storage buckets add-iam-policy-binding gs://BUCKET \--member="$MEMBER" --role=roles/storage.objectAdminobjectAdmincovers the objects and nothing else, and it is all the service needs: it checks a bucket by listing an object and never reads the bucket’s metadata.The binding is direct: the Kubernetes ServiceAccount is the IAM principal, and it needs no annotation. To have the pod act as a Google service account instead, grant that account the roles. Then give the Kubernetes ServiceAccount
roles/iam.workloadIdentityUseron it, and set theiam.gke.io/gcp-service-accountannotation underspec.serviceAccount.annotations. Either way, every workload of the install shares the ServiceAccount, so the engine and api pods can reach the key and the bucket too.
Install the operator
Section titled “Install the operator”Nothing differs on GKE. Follow Install the operator.
Prepare the namespace
Section titled “Prepare the namespace”Follow Prepare the namespace with these changes:
-
One database Secret serves both repository blocks, because one Cloud SQL user owns both databases:
Terminal window kubectl -n NAMESPACE create secret generic authwise-db \--from-literal=owner-password=DB_PASSWORD -
Store the Cloud SQL CA for the platform service:
Terminal window kubectl -n NAMESPACE create secret generic cloudsql-ca \--from-file=ca.pem=cloudsql-ca.pem -
For platform-hosted, generate the keyset and create the
PersistentVolumeClaimas the Kubernetes page describes. GKE’s defaultStorageClassprovisions a persistent disk for it, which isReadWriteOnce; keep the platform service at one replica or move to platform-gcp. -
For platform-gcp, skip the keyset and the claim. The Cloud SQL CA Secret is still needed if the platform service gets a
repository.
Enrol the administrator’s password as on the Kubernetes page.
Write the install
Section titled “Write the install”The resource below is a complete install on Cloud SQL with the operator
deploying platform-hosted. Save it as authwise.yaml and replace every
placeholder. It differs from the
Kubernetes sample in the
database connections and in the platform service’s database TLS.
apiVersion: identity.authwise.com/v1alpha1kind: AuthwiseIdentityServermetadata: name: authwise namespace: NAMESPACEspec: preset: authwise-full
imagePullSecrets: - name: authwise-registry
bootstrap: admin: issuerHost: ADMIN_HOST username: ADMIN_EMAIL audienceURI: https://API_HOST credential: "PHC_STRING" machineCredential: {}
platform: hosted: key: keysetSecret: name: authwise-platform-keyset key: keyset.yaml bucketObject: buckets: [assets] volumeClaimName: authwise-platform-objects repository: mode: gorm tls: # Cloud SQL's per-instance CA names the instance connection name, # so verify the chain, not the hostname. sslMode: verify-ca caSecret: name: cloudsql-ca key: ca.pem gorm: app: &platformdb host: DB_HOST port: 5432 name: authwise_platform username: authwise passwordSecret: name: authwise-db key: owner-password # The owner connection creates the database, so it must name one that # exists: the server's maintenance database. owner: host: DB_HOST port: 5432 name: postgres username: authwise passwordSecret: name: authwise-db key: owner-password messaging: store: sql email: provider: smtp from: no-reply@EXAMPLE_DOMAIN smtp: host: SMTP_HOST port: 587 startTLS: true
console: clientId: c-01
networking: ingress: className: nginx issuer: hosts: [ADMIN_HOST] tlsSecretName: ADMIN_HOST_TLS_SECRET api: hosts: [API_HOST] tlsSecretName: API_HOST_TLS_SECRET console: hosts: [CONSOLE_HOST] tlsSecretName: CONSOLE_HOST_TLS_SECRET
config: baseURL: https://ADMIN_HOST serverSecret: name: authwise-server key: secret repository: mode: gorm gorm: app: &db host: DB_HOST port: 5432 name: authwise_identity username: authwise passwordSecret: name: authwise-db key: owner-password # The owner connection creates the database, so it must name one that # exists: the server's maintenance database. owner: host: DB_HOST port: 5432 name: postgres username: authwise passwordSecret: name: authwise-db key: owner-password issuerKeys: keyName: primary activeDays: 120 visibleAfterActiveDays: 60 asset: mode: ObjectStorage bucketName: assetsThe placeholders not listed here are the Kubernetes sample’s.
| Placeholder | Value |
|---|---|
DB_HOST | The Cloud SQL instance’s private IP address. |
DB_PASSWORD | The password you gave gcloud sql users create, stored in the authwise-db Secret. |
Google Cloud has no first-party transactional email service. The sample
sends through an SMTP relay; provider: sendgrid with an apiKeySecret
under sendgrid is the other operator-supported transport. Without a
transport the install sends nothing: an invitation prints its accept URL
for you to pass on, and a person who forgets their password has no way to
reset it.
The identity server’s own database connection has no TLS fields in the
resource. Its driver encrypts the connection when the server offers TLS,
which ENCRYPTED_ONLY guarantees, but it does not verify the server
certificate.
Use platform-gcp instead
Section titled “Use platform-gcp instead”Replace hosted with gcp, and change two config blocks. Everything else
stays as above, including the platform service’s repository and
messaging blocks: platform-gcp reads them as platform-hosted does.
spec: platform: gcp: projectId: PROJECT_ID dataflowPrefix: authwise repository: # ...as above messaging: # ...as above
config: issuerKeys: keyName: projects/PROJECT_ID/locations/LOCATION/keyRings/authwise/cryptoKeys/primary activeDays: 120 visibleAfterActiveDays: 60 asset: mode: ObjectStorage bucketName: BUCKETprojectId is the project the service’s Google clients bind to.
dataflowPrefix is required by the service at startup. An Authwise install
never publishes to Pub/Sub, so no topic has to exist, and any name works.
keyName is the Cloud KMS key’s full resource name: the service sends it to
Cloud KMS as the key to encrypt with. bucketName is the Cloud Storage
bucket. The service never creates one. The operator refuses the install at
admission if keyName is not a full key name (a key version is refused
too), or if asset.mode is not ObjectStorage with a bucket. Otherwise
the schema migration fails later with invalid key, after the database
exists.
The repository block is optional with platform-gcp, but only while the
install sends no mail. Messaging keeps its outbox in the platform database
by default, and the service refuses to start with messaging configured and
no repository. The operator refuses that combination at admission, unless
messaging.store is memory, which loses every queued message on restart.
The operator issues the platform service’s mutual TLS itself, as for
platform-hosted, and renders the shared configuration file. It passes
PROJECT_ID and DATAFLOW_PREFIX as environment variables and mounts no
key file: the pod authenticates as its ServiceAccount, and the IAM bindings
decide what it can reach.
Apply and watch
Section titled “Apply and watch”Follow Apply and watch and After the install.
Troubleshooting
Section titled “Troubleshooting”The Kubernetes troubleshooting table applies. These are the Google Cloud additions.
| Symptom | Cause and fix |
|---|---|
The install is refused: with platform.gcp the key is Cloud KMS's, named in full | Set issuerKeys.keyName to projects/PROJECT_ID/locations/LOCATION/keyRings/RING/cryptoKeys/KEY, without a cryptoKeyVersions suffix. |
The install is refused on spec.config.asset.mode | platform-gcp stores assets only in Cloud Storage. Set asset.mode: ObjectStorage and asset.bucketName. |
migrate fails with invalid key | The key is in a different project or location than its name says, or the ServiceAccount cannot use it. |
platform-gcp logs PermissionDenied from Cloud KMS or Cloud Storage | The IAM binding is missing or names a different namespace or ServiceAccount than the pod runs as, or Workload Identity Federation is not enabled on the cluster or node pool. |
Uploads fail with not found | asset.bucketName names a bucket that does not exist, or the ServiceAccount cannot list its objects. |
| platform-hosted crash-loops with a database TLS error | verify-full cannot match Cloud SQL’s certificate to an IP address. Use verify-ca. |
platform-hosted stays Pending with a volume error | The persistent disk is ReadWriteOnce; the platform runs more than one replica, or a previous pod still holds the disk. |