Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omerap12/crossplane-ec2-provisioning
This project demonstrates how to provision EC2 instances on AWS using Crossplane.
https://github.com/omerap12/crossplane-ec2-provisioning
crossplane kubernetes
Last synced: 20 days ago
JSON representation
This project demonstrates how to provision EC2 instances on AWS using Crossplane.
- Host: GitHub
- URL: https://github.com/omerap12/crossplane-ec2-provisioning
- Owner: omerap12
- Created: 2024-03-30T11:09:37.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-14T06:26:59.000Z (9 months ago)
- Last Synced: 2024-10-29T23:44:01.130Z (2 months ago)
- Topics: crossplane, kubernetes
- Language: Shell
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Crossplane EC2 Provisioning
This project demonstrates how to provision EC2 instances on AWS using Crossplane.
## Overview
The project consists of several components:
- **CompositeResourceDefinition (CRD)**: Defines the custom resource `EC2` that users can create to request EC2 instances with specific configurations.
- **Composition**: Describes how to compose the `EC2` custom resource with the necessary patches to provision EC2 instances on AWS.
- **Provider Configuration**: Configures the AWS provider in Crossplane and sets up secrets for AWS credentials.
- **Initialization Script**: Bash script (`init.sh`) for installing Crossplane and the AWS provider, as well as setting up required configurations.
- **Example EC2 Resource**: An example `EC2` custom resource (`ec2-light.yaml`) showcasing how to request an EC2 instance with default parameters.## Prerequisites
Before running the initialization script, ensure the following:
- File aws-credentials.txt is filled with the right AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
- KUBECONFIG environment variable is set.
- kubectl and helm are installed.## Getting Started
To set up Crossplane and provision EC2 instances on AWS, follow these steps:
1. Clone this repository.
2. Set the required environment variables.
3. Run the initialization script: `./init.sh`.## Usage
Run the following command to install the CRD (CompositeResourceDefinition), and the composition:
```bash
kubectl apply -f CompositeResourceDefinitions/ec2_definition.yaml
kubectl apply -f Compositions/ec2_composition.yaml
```
Once the initialization is complete, you can create EC2 instances by applying the `EC2` custom resource YAML files. For example:
```yaml
apiVersion: omerap12.com/v1alpha1
kind: EC2
metadata:
name: ec2-light # Resource name
annotations:
creator: crossplane
author: omerap12
spec:
compositionSelector:
matchLabels:
provider: aws
parameters:
ec2type: cheap # cheap/memory/cpu/gpu/storage optimized (default cheap)
operatingSystem: linux # linux(AL),Windows, Ubuntu (default AL2)
subnetId: xxx # Must specify subnet id
publicIp: false # true/false (deafult false)
```
A new instance will be created and be managed by crossplane.## Mapping
### ec2type
- cheap: t2.micro
- memory: r5.large
- cpu: c5.large
- gpu: p3.xlarge
- storage: i3.large### operatingSystem
- linux: ami-0c101f26f147fa7fd
- windows: ami-03cd80cfebcbb4481
- ubuntu: ami-080e1f13689e07408