Late Initialization: Reconciliation control loop of Crossplane controllers will fill default values assigned by the infrastructure API for the features not provided in the configuration YAML.
Providers
Providers are a group of related MRs packaged together as bundle
Each cloud vendor, other infrastructure services or software tools such as Helm have a provider package
Format of these packages is nothing, but a container image
Installing of a provider can be done either with a configuration YAMl or using a Helm package
If requires a ProviderConfig configuration
ProviderConfig
Helps in setting up the infrastructure vendor credentials
Provider View
Composite Resources
Composing is a way to build our custom infrastructure APIs above one or more MR APIs
These APIs are called Composite Resources (XRs)
Composition and Composite Resource Definition(XRD) are the configurations that we use to compose a higher-level XR API.
Composition is the configuration that provides a mapping between the new CRD schema and the existing MRs
One the new XR resource is available, we can start provisioning the infrastructure recipes using a Resource Claim object
The Claim API is something that gets created when we add a new XR API, provided we have asked for it in the XRD configuration
The Claim and XR APIs are almost the same with minor differences
A composite resource
The composing layer is for platform teams to build such abstraction
Product and platform team interaction
Crossplane core
All the pieces of Crossplane
CRD stands for Custom Resource Definition, a way to extend the Kubernetes API to support new resource types.
CRs are the resources defined with the CRD. CR stands for Custom Resource.
XRM stands for Crossplane Resource Model, an extension of the Kubernetes Resource Model. It is a set of rules set by Crossplane on how to build an XR or MR.
MRs are nothing but Managed Resources, a combination of a CRD and custom controllers in a one-to-one mapping with external infrastructure resources.
XRD stands for Composite Resource Definition, a definition for building a custom infrastructure API above Crossplane.
XR stands for Composite Resource, which represents a custom infrastructure API built with Crossplane.
Installing Crossplane
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update
helm install crossplane \
--namespace crossplane-system \
--create-namespace crossplane-stable/crossplane
k get all -n crossplane-system
NAME READY STATUS RESTARTS AGE
pod/crossplane-57cb498b78-2kkv9 1/1 Running 0 29s
pod/crossplane-rbac-manager-584dc64dd6-g2c7p 1/1 Running 0 29s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/crossplane-webhooks ClusterIP 10.96.66.26 <none> 9443/TCP 29s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/crossplane 1/1 1 1 29s
deployment.apps/crossplane-rbac-manager 1/1 1 1 29s
NAME DESIRED CURRENT READY AGE
replicaset.apps/crossplane-57cb498b78 1 1 1 29s
replicaset.apps/crossplane-rbac-manager-584dc64dd6 1 1 1 29s
Next, will have to create service account and extract the credentials required to set up the GCP Crossplane provider
Get the project ID:
gcloud projects list
PROJECT_ID NAME PROJECT_NUMBER
crossplane-419023 crossplane 1036492210105
global-road-172213 pheni 494163941067
silicon-pointer-419123 My First Project 634125584066
Create Service Account and enable the required roles on the SA
gcloud iam service-accounts create crossplane-service-account --display-name "crossplane service account" --project=crossplane-419023
Created service account [crossplane-service-account].
gcloud iam service-accounts list --filter="email ~ ^crossplane-service-account" --format='value(email)'
crossplane-service-account@crossplane-419023.iam.gserviceaccount.com
gcloud iam service-accounts keys create crossplane-service-account.json --iam-account crossplane-service-account@crossplane-419023.iam.gserviceaccount.com
created key [ff28a13280bef5fc83ce9fef90f0560d7923c4e4] of type [json] as [crossplane-service-account.json] for [crossplane-service-account@crossplane-419023.iam.gserviceaccount.com]
cat crossplane-service-account.json
Create Kubernetes Secret using the Service Account
k get po -n crossplane-system
NAME READY STATUS RESTARTS AGE
crossplane-57cb498b78-2kkv9 1/1 Running 1 (2d16h ago) 3d7h
crossplane-rbac-manager-584dc64dd6-g2c7p 1/1 Running 1 (2d16h ago) 3d7h
provider-gcp-63e92883e260-776757658-crmlr 1/1 Running 0 10h
Configuring Provider
Next step is to set up provider configuration for authentication using the ProviderConfig Crossplane API.
Credentials can be different for each provider, depending on the construct for authentication by infrastructure vendor.
GCP, uses Service Account, in Azure its Service Principle, IAM in AWS etc.
k get providerconfig
NAME PROJECT-ID AGE
gcp-credentials-project-1 crossplane-419023 63m
Multiple Provider configuration
Multiple ProviderConfig can be configured against a provider.
Which is like having multiple credentials or cloud accounts to access the cloud platform and choosing the appropriate credentials based on the given context
When provisioning MR or XR, we specify providerConfigRef to determine which ProviderConfig to use
If providerConfigRef is not provided in Mr or XR, Crossplane refers to the ProviderConfig named default
If you want to create the resource in the vendor infrastructure with a name different from that of the Crossplane resource claim, use the crossplane.io/external-name:my-special-name annotation in the metadata section.