This repository contains Python scripts to automate Kubernetes cluster creation and configuration on different cloud providers.
This Python script automates the creation of an Amazon EKS (Elastic Kubernetes Service) cluster, configures networking, sets up worker nodes, installs the AWS EBS CSI driver addon, and optionally deploys Solace PubSub+ using Helm.
The script performs the following steps:
- VPC Creation: Creates a new VPC with a specified CIDR block.
- Subnet Creation: Creates public subnets in two Availability Zones within the VPC.
- Internet Gateway & Routing: Sets up an Internet Gateway and a Route Table to allow internet access for the subnets.
- IAM Roles: Creates the necessary IAM roles for the EKS cluster (
EKSClusterRole) and worker nodes (EKSNodeGroupRole). - EKS Cluster Creation: Provisions the EKS control plane.
- Node Group Creation: Creates a managed node group with EC2 instances based on user input (instance type, node count).
- Kubeconfig Update: Configures
kubectlto connect to the newly created cluster. - EBS CSI Driver Addon:
- Checks for and attempts to associate the required IAM OIDC provider for the cluster using
eksctl. - Creates the necessary IAM Role (
AmazonEKS_EBS_CSI_DriverRole_*) with the correct trust policy for the driver's service account. - Installs or updates the
aws-ebs-csi-driverEKS managed addon using the AWS CLI. - Verifies the driver's controller deployment is ready within Kubernetes using
kubectl.
- Checks for and attempts to associate the required IAM OIDC provider for the cluster using
- EBS StorageClass: Creates a Kubernetes
StorageClassnamedebs-sc(usinggp2volume type) provisioned by the EBS CSI driver. - (Optional) Solace PubSub+ Deployment: Deploys the Solace PubSub+ event broker using its Helm chart, configured to use the
ebs-scStorageClass for persistence. Allows specifying HA mode and optionally using an image from ECR.
Before running support-eks-cluster.py, ensure you have the following installed and configured:
- Python 3: The script is written in Python 3.
- Python Modules:
boto3: The AWS SDK for Python (pip install boto3).
- AWS CLI: Installed and configured with appropriate AWS credentials (permissions to create VPC, EKS, IAM resources, EC2 instances, etc.).
kubectl: The Kubernetes command-line tool.eksctl: Required for the automatic IAM OIDC provider association attempt. If not installed, the script will prompt for manual association if needed. (Installation Guide)- (Optional) Helm: Required only if you choose to deploy Solace PubSub+. (Installation Guide)
- (Optional) Docker: Required only if deploying Solace using a custom image from ECR.
- AWS Credentials: Ensure your AWS CLI is configured with credentials that have sufficient permissions. This is typically done using the
aws configurecommand. - AWS Region: The script attempts to detect the AWS region automatically (from boto3 session, EC2 metadata). If detection fails, it will prompt the user.
- Clone the repository (if you haven't already).
- Navigate to the repository directory in your terminal.
- Install the required Python module:
pip install boto3
- Run the script:
python support-eks-cluster.py
- Follow the interactive prompts to configure the cluster name, nodegroup name, instance type, and node scaling parameters. Default values are provided.
- The script will output the progress of each step.
- If the IAM OIDC provider is missing, the script will attempt to create it using
eksctl. Ifeksctlis not found or fails, the script will exit with instructions for manual association. - After cluster creation, you will be asked if you want to deploy Solace PubSub+.
- The script creates resources in your AWS account, which may incur costs.
- Ensure you have the necessary permissions associated with your AWS credentials.
- The EBS CSI driver setup relies on the EKS managed addon feature via the AWS CLI.
- Error handling is included, but complex failures might require manual intervention via the AWS console or CLI.
This Python script automates the creation of Kubernetes clusters on Microsoft Azure (AKS) or Google Cloud Platform (GKE), configures kubectl, and optionally deploys Solace PubSub+ using Helm.
The script performs the following steps:
- Provider Selection: Prompts the user to choose between Azure (AKS) and Google Cloud (GKE).
- Cluster Creation: Creates the Kubernetes cluster using the respective cloud provider's CLI (
az aks createorgcloud container clusters create) based on user input (cluster name, resource group/zone, node count, VM size/machine type). - Kubeconfig Update: Configures
kubectlto connect to the newly created cluster using the provider's CLI (az aks get-credentialsorgcloud container clusters get-credentials). - (Optional) Solace PubSub+ Deployment: Deploys the Solace PubSub+ event broker using its Helm chart.
- Allows specifying HA mode.
- Optionally supports using a custom image from AWS ECR, handling ECR authentication and Kubernetes image pull secret creation (requires AWS credentials and
boto3).
Before running support-cluster-creation.py, ensure you have the following installed and configured:
- Python 3: The script is written in Python 3.
- Cloud Provider CLI:
- For Azure (AKS): Azure CLI (
az) installed and logged in (az login). - For Google Cloud (GKE): Google Cloud SDK (
gcloud) installed and initialized (gcloud init).
- For Azure (AKS): Azure CLI (
kubectl: The Kubernetes command-line tool.- (Optional) Helm: Required only if you choose to deploy Solace PubSub+. (Installation Guide)
- (Optional, for ECR):
- AWS CLI: Installed and configured (
aws configure) if using an ECR image. boto3: Python module (pip install boto3) if using an ECR image.- Docker: Required if using an ECR image (for authentication testing).
- AWS CLI: Installed and configured (
- Cloud Provider Login: Ensure you are logged into the respective cloud provider CLI (
az loginorgcloud init) with sufficient permissions to create Kubernetes clusters and related resources. - (Optional, for ECR) AWS Account ID: If using the ECR image option, the script currently has a hardcoded
AWS_ACCOUNT_IDvariable near the top. Verify this if necessary. - (Optional, for ECR) AWS Credentials: If using the ECR image option, ensure your AWS CLI is configured (
aws configure) with credentials that have ECR access permissions.
- Clone the repository (if you haven't already).
- Navigate to the repository directory in your terminal.
- Install
boto3if planning to use the ECR option:pip install boto3
- Run the script:
python support-cluster-creation.py
- Follow the interactive prompts to select the cloud provider and configure the cluster parameters.
- Choose whether to deploy Solace and if using an ECR image.
- The script will output the progress of each step.
- The script creates resources in your selected cloud provider account (Azure or GCP), which may incur costs.
- Ensure you have the necessary permissions associated with your cloud provider login.
- Error handling is included, but complex failures might require manual intervention via the cloud provider console or CLI.