drunk-pulumi-azure

AksBuilder Class Documentation

1. Overview

The AksBuilder class is designed to streamline the process of creating and configuring Azure Kubernetes Service (AKS) clusters using Pulumi. This class uses a builder pattern to offer a fluent interface for defining various aspects of an AKS cluster, including network settings, node pools, identity configurations, SSH access, and more.

2. Key Properties and Methods

2.1. Properties
2.2. Methods
2.2.1. withSsh(props: SshBuilderProps)

Configures SSH access using an existing SSH key.

2.2.2. withNewSsh(props: { loginPrefix: string; maxUserNameLength: number; })

Generates a new SSH key and configures it for the AKS cluster.

2.2.3. withNetwork(props: AksNetworkProps)

Defines the network configuration for the AKS cluster.

2.2.4. withDefaultNodePool(props: NodePoolProps)

Configures the default node pool for the AKS cluster.

2.2.5. withFeatures(props: AskFeatureProps)

Enables specific features for the AKS cluster, such as monitoring and HTTP application routing.

2.2.6. withAddons(props: AskAddonProps)

Adds specific add-ons to the AKS cluster, such as Azure Policy and Ingress Application Gateway.

2.2.7. withImport(props: AksImportProps)

Imports an existing AKS cluster into the configuration.

**2.2.8. build(): Promise**

Deploys the AKS cluster based on the current configuration.

3. Example of Full Usage

Here’s a complete example demonstrating how to use the AksBuilder with all available properties:

const aksBuilder = new AksBuilder({
  resourceName: 'my-aks-cluster',
  resourceGroupName: 'my-resource-group',
  location: 'East US',
  envRoles: ['my-role'],
} as AksBuilderArgs);

aksBuilder
  .withSsh({
    username: 'adminuser',
    sshPublicKey: 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA...',
  } as SshBuilderProps)
  .withNewSsh({
    loginPrefix: 'drunk',
    maxUserNameLength: 15,
  })
  .withNetwork({
    subnetId: 'subnet-id',
    virtualHostSubnetName: 'virtual-host-subnet',
    extraVnetIds: ['vnet-id-1', 'vnet-id-2'],
    outboundIpAddress: {
      ipAddressId: 'ip-address-id',
      ipAddressPrefixId: 'ip-prefix-id',
    },
  } as AksNetworkProps)
  .withDefaultNodePool({
    name: 'defaultpool',
    nodeCount: 3,
    vmSize: 'Standard_DS2_v2',
    enableAutoScaling: true,
    minCount: 1,
    maxCount: 5,
  } as NodePoolProps)
  .withFeatures({
    httpApplicationRouting: true,
    monitoring: true,
  } as AskFeatureProps)
  .withAddons({
    azurePolicy: true,
    ingressApplicationGateway: {
      enabled: true,
      gatewayName: 'my-app-gateway',
    },
  } as AskAddonProps);

const aksCluster = await aksBuilder.build();

4. Conclusion

The AksBuilder class offers a robust and flexible approach to configuring and deploying Azure Kubernetes Service clusters. With detailed configuration options for SSH, networking, node pools, and more, developers can tailor their AKS deployments to meet a wide range of requirements.