1. Deploy the promtail-mixin helm chart on AWS EKS

    TypeScript

    Deploying the promtail-mixin Helm chart on AWS EKS involves several steps:

    1. Create an EKS cluster using the aws.eks.Cluster resource.
    2. Set up a Kubernetes provider to interact with the created EKS cluster.
    3. Deploy the promtail-mixin Helm chart on the EKS cluster using the kubernetes.helm.v3.Chart resource.

    Below is a Pulumi TypeScript program that accomplishes these steps:

    Program Explanation

    Before we proceed with the code, you need to ensure you have an AWS account and Pulumi CLI set up and configured correctly.

    1. EKS Cluster: We'll create an EKS cluster by declaring a aws.eks.Cluster resource. This is the foundational building block that will orchestrate our Kubernetes services.
    2. Kubernetes Provider: Once the EKS cluster is provisioned, we need to communicate with it. The Kubernetes provider allows us to interact with our cluster to deploy applications.
    3. Helm Chart Deployment: Finally, we will deploy the promtail-mixin Helm chart. Helm charts are packages for Kubernetes applications. By using the kubernetes.helm.v3.Chart resource, we instruct Pulumi to install the chart into our EKS cluster.

    Make sure to replace the placeholder values like <YOUR_CLUSTER_NAME> and <CHART_VERSION> with your desired values.

    Pulumi TypeScript Program

    import * as pulumi from '@pulumi/pulumi'; import * as aws from '@pulumi/aws'; import * as awsx from '@pulumi/awsx'; import * as eks from '@pulumi/eks'; import * as kubernetes from '@pulumi/kubernetes'; // Create an EKS cluster. const cluster = new eks.Cluster('<YOUR_CLUSTER_NAME>', { vpcId: '<VPC_ID>', // Specify your VPC ID publicSubnetIds: ['<SUBNET_ID_1>', '<SUBNET_ID_2>'], // Specify your Subnet IDs instanceType: 't2.medium', desiredCapacity: 2, minSize: 1, maxSize: 3, storageClasses: 'gp2', deployDashboard: false, }); // Export the cluster's kubeconfig. export const kubeconfig = cluster.kubeconfig; // Create a Kubernetes provider instance that uses our EKS cluster's kubeconfig. const k8sProvider = new kubernetes.Provider('k8s-provider', { kubeconfig: cluster.kubeconfig.apply(JSON.stringify), }); // Deploy the promtail-mixin helm chart to the EKS cluster using the k8s provider. const promtailMixinChart = new kubernetes.helm.v3.Chart('promtail-mixin', { chart: 'promtail-mixin', version: '<CHART_VERSION>', // Specify the chart version fetchOpts: { repo: 'https://grafana.github.io/helm-charts', // The chart repository }, }, { provider: k8sProvider }); // Export the Helm chart name so we know the deployment succeeded. export const helmChartName = promtailMixinChart.metadata.apply(m => m.name);

    How to Run This Program

    1. Save the program code in a file named index.ts.
    2. Run pulumi up in the command line from the directory where the file resides.
    3. Pulumi CLI will display a preview of the resources to be created and ask for confirmation before proceeding.
    4. Confirm the action, and Pulumi will begin creating the resources, outputting progress to the terminal.

    After executing the program successfully, your AWS EKS cluster will have the promtail-mixin Helm chart deployed, ready for use. Remember to manage your AWS and Helm configurations securely.

    Post-Deployment

    After deployment, you can interact with your Kubernetes cluster using kubectl by setting your kubeconfig environment variable:

    export KUBECONFIG=$(pulumi stack output kubeconfig)

    Now, you can use kubectl get pods and other Kubernetes commands to interact with your pods, including those managed by the promtail-mixin.