--- stage: Configure group: Configure info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers --- # Crossplane configuration After [installing](applications.md#crossplane) Crossplane, you must configure it for use. The process of configuring Crossplane includes: 1. [Configure RBAC permissions](#configure-rbac-permissions). 1. [Configure Crossplane with a cloud provider](#configure-crossplane-with-a-cloud-provider). 1. [Configure managed service access](#configure-managed-service-access). 1. [Set up Resource classes](#setting-up-resource-classes). 1. Use [Auto DevOps configuration options](#auto-devops-configuration-options). 1. [Connect to the PostgreSQL instance](#connect-to-the-postgresql-instance). To allow Crossplane to provision cloud services such as PostgreSQL, the cloud provider stack must be configured with a user account. For example: - A service account for GCP. - An IAM user for AWS. Some important notes: - This guide uses GCP as an example, but the processes for AWS and Azure are similar. - Crossplane requires the Kubernetes cluster to be VPC native with Alias IPs enabled, so the IP addresses of the pods can be routed within the GCP network. First, declare some environment variables with configuration for use in this guide: ```shell export PROJECT_ID=crossplane-playground # the GCP project where all resources reside. export NETWORK_NAME=default # the GCP network where your GKE is provisioned. export REGION=us-central1 # the GCP region where the GKE cluster is provisioned. ``` ## Configure RBAC permissions For GitLab-managed clusters, role-based access control (RBAC) is configured automatically. For non-GitLab managed clusters, ensure that the service account for the token provided can manage resources in the `database.crossplane.io` API group: 1. Save the following YAML as `crossplane-database-role.yaml`: ```yaml apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: crossplane-database-role labels: rbac.authorization.k8s.io/aggregate-to-edit: "true" rules: - apiGroups: - database.crossplane.io resources: - postgresqlinstances verbs: - get - list - create - update - delete - patch - watch ``` 1. Apply the cluster role to the cluster: ```shell kubectl apply -f crossplane-database-role.yaml ``` ## Configure Crossplane with a cloud provider See [Configure Your Cloud Provider Account](https://crossplane.github.io/docs/v0.4/cloud-providers.html) to configure the installed cloud provider stack with a user account. NOTE: **Note:** The Secret, and the Provider resource referencing the Secret, must be applied to the `gitlab-managed-apps` namespace in the guide. Make sure you change that while following the process. ## Configure Managed Service Access Next, configure connectivity between the PostgreSQL database and the GKE cluster by either: - Using Crossplane as demonstrated below. - Directly in the GCP console by [configuring private services access](https://cloud.google.com/vpc/docs/configure-private-services-access). 1. Run the following command, which creates a `network.yaml` file, and configures `GlobalAddress` and connection resources: ```plaintext cat > network.yaml < gcp-postgres-standard.yaml < Annotations: crossplane.io/propagate-from-name: 108e460e-06c7-11ea-b907-42010a8000bd crossplane.io/propagate-from-namespace: gitlab-managed-apps crossplane.io/propagate-from-uid: 10c79605-06c7-11ea-b907-42010a8000bd Type: Opaque Data ==== privateIP: 8 bytes publicIP: 13 bytes serverCACertificateCert: 1272 bytes serverCACertificateCertSerialNumber: 1 bytes serverCACertificateCreateTime: 24 bytes serverCACertificateExpirationTime: 24 bytes username: 8 bytes endpoint: 8 bytes password: 27 bytes serverCACertificateCommonName: 98 bytes serverCACertificateInstance: 41 bytes serverCACertificateSha1Fingerprint: 40 bytes ``` ## Connect to the PostgreSQL instance Follow this [GCP guide](https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine) if you would like to connect to the newly provisioned PostgreSQL database instance on CloudSQL.