A Backstage Software Template for provisioning Kubernetes clusters using Crossplane.
This template creates the necessary Crossplane resources to provision a Kubernetes cluster in your cloud provider. It includes:
- XRD (Composite Resource Definition): Defines the Cluster API
- Composition: Implements the cluster provisioning logic
- Example Claim: Shows how to request a Kubernetes cluster
- 🚀 Multi-Cloud Support: Deploy to AWS, Azure, GCP, or on-premises
- ⚙️ Flexible Sizing: Choose from small, medium, or large node sizes
- 🔢 Scalable: Support for 3 to 100 nodes
- 🔧 Version Control: Deploy specific Kubernetes versions
- 🔒 Automatic Firewall: Security rules configured automatically
- 📊 Kubeconfig Access: Connection details available in resource status
Ensure Crossplane is installed in your cluster:
kubectl create namespace crossplane-system
helm repo add crossplane-stable https://charts.crossplane.io/stable
helm install crossplane --namespace crossplane-system crossplane-stable/crossplane
This template requires the following Crossplane providers:
- Provider NOP (for simulation/testing):
kubectl apply -f - <<EOF
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-nop
spec:
package: xpkg.upbound.io/crossplane-contrib/provider-nop:v0.2.0
EOF
Install the necessary Crossplane composition functions:
kubectl apply -f - <<EOF
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-go-templating
spec:
package: xpkg.upbound.io/crossplane-contrib/function-go-templating:v0.10.0
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-auto-ready
spec:
package: xpkg.upbound.io/crossplane-contrib/function-auto-ready:v0.2.1
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-sequencer
spec:
package: xpkg.upbound.io/crossplane-contrib/function-sequencer:v0.3.0
---
apiVersion: pkg.crossplane.io/v1beta1
kind: Function
metadata:
name: function-environment-configs
spec:
package: xpkg.upbound.io/crossplane-contrib/function-environment-configs:v0.1.0
EOF
- Navigate to the Software Catalog
- Click "Create Component"
- Select "Kubernetes Cluster"
- Fill in the required parameters:
- Cluster Name: Unique identifier for your cluster
- Namespace: Kubernetes namespace (default:
default
) - Node Size: Small, medium, or large
- Node Count: Number of nodes (3-100)
- Storage Size: Storage per node in GB
- Kubernetes Version: Select from available versions
- Cloud Provider: AWS, Azure, GCP, or on-premises
- Owner: Team or user who owns this resource
- Apply the XRD:
kubectl apply -f content/definition.yaml
- Apply the Composition:
kubectl apply -f content/composition.yaml
- Create a claim:
kubectl apply -f content/example.yaml
Parameter | Description | Type | Default | Required |
---|---|---|---|---|
name |
Cluster name | string | - | Yes |
namespace |
Kubernetes namespace | string | default |
No |
nodeSize |
Size of nodes | string | medium |
No |
nodeCount |
Number of nodes | integer | 3 |
No |
storageSize |
Storage per node (GB) | integer | 10 |
No |
version |
Kubernetes version | string | 1.31.1 |
Yes |
cloudProvider |
Cloud provider | string | azure |
No |
owner |
Resource owner | string | group:platform |
No |
Size | vCPU | Memory | Storage |
---|---|---|---|
Small | 2 | 4 GB | Configurable |
Medium | 4 | 8 GB | Configurable |
Large | 8 | 16 GB | Configurable |
The template creates a composite resource that provisions:
- ConfigMap: Stores cluster configuration
- Cluster Resource: The actual Kubernetes cluster (simulated)
- Firewall Rule: Network security configuration
- NOP Resource: Simulates cluster provisioning delay (30s)
After provisioning, retrieve the kubeconfig:
# Get the base64-encoded kubeconfig
kubectl get cluster <cluster-name> -n <namespace> -o jsonpath='{.status.kubeconfig}' | base64 -d > kubeconfig.yaml
# Use the kubeconfig
export KUBECONFIG=kubeconfig.yaml
kubectl get nodes
Get the cluster IP address:
kubectl get cluster <cluster-name> -n <namespace> -o jsonpath='{.status.ipaddress}'
- Clone this repository
- Install the template in Backstage:
catalog:
locations:
- type: url
target: https://github.com/open-service-portal/service-cluster-template/blob/main/template.yaml
To customize the cluster provisioning:
- Edit
content/definition.yaml
to add parameters - Modify
content/composition.yaml
to change provisioning logic - Update
template.yaml
to expose new parameters in Backstage
- 1.31.1 (latest)
- 1.30.5
- 1.29.x series
- 1.28.x series
Cluster stuck in Creating state
- Check if all required functions are installed
- Verify the NOP provider is running:
kubectl get providers
- Check composition status:
kubectl describe composition cluster
Kubeconfig not appearing
- Ensure environment config is properly set
- Check if cluster resource reached Ready state
- Verify composition pipeline completed successfully
Firewall rule errors
- Check if FirewallRule XRD is installed
- Verify network policies allow rule creation
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
MIT License - see LICENSE file for details
For issues and questions:
- GitHub Issues: open-service-portal/service-cluster-template
- Discussions: open-service-portal/discussions