1. Deploy the mariadb-imagestreams helm chart on AWS EKS


    Deploying a Helm chart for MariaDB on AWS EKS using Pulumi involves several steps:

    1. Set up the EKS cluster.
    2. Define an IAM role for the EKS cluster.
    3. Create the necessary resources for the EKS cluster (like NodeGroups).
    4. Deploy the Helm chart onto the EKS cluster.

    To achieve this, we will utilize a combination of Pulumi AWS, Pulumi EKS, and Pulumi Kubernetes resources. We will start by creating the EKS cluster using eks.Cluster from the Pulumi EKS package. This high-level component simplifies the setup of an EKS cluster. Then, we will deploy the Helm chart for MariaDB using kubernetes.helm.v3.Chart from the Pulumi Kubernetes provider.

    Let's write the Pulumi program:

    import * as eks from "@pulumi/eks"; import * as k8s from "@pulumi/kubernetes"; import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; // Create an EKS cluster with the default configuration. const cluster = new eks.Cluster("myCluster", { instanceType: "t2.medium", desiredCapacity: 2, minSize: 1, maxSize: 2, providerCredentialOpts: { profileName: aws.config.profile, // Assumes AWS credentials are set in the Pulumi configuration. }, }); // Export the kubeconfig for the EKS cluster so that kubectl can interact with it. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses our EKS cluster. const k8sProvider = new k8s.Provider("k8sProvider", { kubeconfig: cluster.kubeconfig, }); // Deploy the MariaDB Helm chart onto the EKS cluster. const mariadbChart = new k8s.helm.v3.Chart("mariadb", { chart: "mariadb", version: "10.1.0", // Specify the version of the chart you want to deploy. fetchOpts: { repo: "https://charts.bitnami.com/bitnami", // The repository where the Helm chart is located. }, }, { provider: k8sProvider }); // Optional: You could customize the Helm chart by specifying additional configuration parameters. // For example: // const mariadbChart = new k8s.helm.v3.Chart("mariadb", { // chart: "mariadb", // version: "10.1.0", // fetchOpts: { // repo: "https://charts.bitnami.com/bitnami", // }, // values: { // auth: { // rootPassword: "mySuperSecretPassword", // // Other authentication parameters... // }, // }, // }, { provider: k8sProvider }); // Export the name of the MariaDB deployment. export const mariadbDeploymentName = mariadbChart.getResource("v1/Service", "mariadb-mariadb");

    This program performs the following actions:

    • Initializes an EKS cluster with a specified instance type and capacity.
    • Generates a kubeconfig file which is exported to allow interaction with the cluster outside of the Pulumi program.
    • Creates a Kubernetes provider using the kubeconfig obtained from the EKS cluster, which will configure the Helm chart deployment.
    • Deploys the MariaDB chart from the Bitnami Helm repository to the EKS cluster using the Helm v3 provider.
    • Optionally, we can pass a values object to customize the Helm chart deployment if desired (commented out in the example).

    Run the Pulumi program by executing the following command after saving the code to a file (e.g., index.ts):

    pulumi up

    If you are running this program for the first time, you will be prompted to create a new stack. Pulumi stacks are isolated environments for your code to operate in (like development, staging, and production). Once the stack creation process is completed, the resources defined in the program will be provisioned in your AWS account. Remember, you'll need to have Pulumi installed and configured correctly with your AWS credentials.