Skip to content

Commit

Permalink
feat: added aks option for enable app routing. Fix #288.
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Riobo <[email protected]>
  • Loading branch information
adrianriobo committed Oct 2, 2024
1 parent 82c865f commit 5dc1187
Show file tree
Hide file tree
Showing 580 changed files with 32,959 additions and 21,363 deletions.
16 changes: 10 additions & 6 deletions cmd/mapt/cmd/azure/services/aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ const (
cmdAKS = "aks"
cmdAKSDesc = "aks operations"

paramVersion = "version"
paramVersionDesc = "AKS K8s cluster version"
paramVMSizeDesc = "VMSize to be used on the user pool. Typically this is used to provision spot node pools"
defaultVersion = "1.30"
paramOnlySystemPool = "only-system-pool"
paramOnlySystemPoolDesc = "if we do not need bunch of resources we can run only the systempool. More info https://learn.microsoft.com/es-es/azure/aks/use-system-pools?tabs=azure-cli#system-and-user-node-pools"
paramVersion = "version"
paramVersionDesc = "AKS K8s cluster version"
paramVMSizeDesc = "VMSize to be used on the user pool. Typically this is used to provision spot node pools"
defaultVersion = "1.30"
paramOnlySystemPool = "only-system-pool"
paramOnlySystemPoolDesc = "if we do not need bunch of resources we can run only the systempool. More info https://learn.microsoft.com/es-es/azure/aks/use-system-pools?tabs=azure-cli#system-and-user-node-pools"
paramEnableAppRouting = "enable-app-routing"
paramEnableAppRoutingDesc = "enable application routing add-on with NGINX"
)

func GetAKSCmd() *cobra.Command {
Expand Down Expand Up @@ -73,6 +75,7 @@ func getCreateAKS() *cobra.Command {
Location: viper.GetString(azparams.ParamLocation),
KubernetesVersion: viper.GetString(paramVersion),
OnlySystemPool: viper.IsSet(paramOnlySystemPool),
EnableAppRouting: viper.IsSet(paramEnableAppRouting),
VMSize: viper.GetString(azparams.ParamVMSize),
Spot: viper.IsSet(azparams.ParamSpot),
SpotTolerance: spotToleranceValue}); err != nil {
Expand All @@ -89,6 +92,7 @@ func getCreateAKS() *cobra.Command {
flagSet.StringP(paramVersion, "", defaultVersion, paramVersionDesc)
flagSet.Bool(azparams.ParamSpot, false, azparams.ParamSpotDesc)
flagSet.Bool(paramOnlySystemPool, false, paramOnlySystemPoolDesc)
flagSet.Bool(paramEnableAppRouting, false, paramEnableAppRoutingDesc)
flagSet.StringP(azparams.ParamSpotTolerance, "", azparams.DefaultSpotTolerance, azparams.ParamSpotToleranceDesc)
c.PersistentFlags().AddFlagSet(flagSet)
return c
Expand Down
2 changes: 2 additions & 0 deletions docs/azure/aks.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Usage:

Flags:
--conn-details-output string path to export host connection information (host, username and privateKey)
--enable-app-routing enable application routing add-on with NGINX
-h, --help help for create
--location string location for created resources in case spot flag (if available) is not passed (default "West US")
--only-system-pool if we do not need bunch of resources we can run only the systempool. More info https://learn.microsoft.com/es-es/azure/aks/use-system-pools?tabs=azure-cli#system-and-user-node-pools
Expand Down Expand Up @@ -52,6 +53,7 @@ podman run -d --rm \
--project-name "aks" \
--backed-url "file:///workspace" \
--conn-details-output "/workspace" \
--enable-app-routing \
--spot
```
Expand Down
17 changes: 8 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/coocood/freecache v1.2.4
github.com/pulumi/pulumi-command/sdk v0.11.1
github.com/pulumi/pulumi-random/sdk/v4 v4.16.2
github.com/pulumi/pulumi/sdk/v3 v3.128.0
github.com/pulumi/pulumi/sdk/v3 v3.135.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.8.0
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8
Expand All @@ -22,12 +22,12 @@ require (
github.com/aws/aws-sdk-go-v2/config v1.27.18
github.com/aws/aws-sdk-go-v2/service/ec2 v1.142.0
github.com/pulumi/pulumi-aws/sdk/v6 v6.39.0
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.53.0
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.45.0
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.53.0
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.45.0
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.45.0
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.45.0
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.64.2
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.64.2
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.64.2
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.64.2
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.64.2
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.64.2
github.com/pulumi/pulumi-tls/sdk/v5 v5.0.3
)

Expand Down Expand Up @@ -97,7 +97,7 @@ require (
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
github.com/pulumi/esc v0.9.1 // indirect
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.53.0 // indirect
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.64.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
Expand Down Expand Up @@ -149,7 +149,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 // indirect
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
Expand Down
34 changes: 16 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -254,30 +254,30 @@ github.com/pulumi/esc v0.9.1 h1:HH5eEv8sgyxSpY5a8yePyqFXzA8cvBvapfH8457+mIs=
github.com/pulumi/esc v0.9.1/go.mod h1:oEJ6bOsjYlQUpjf70GiX+CXn3VBmpwFDxUTlmtUN84c=
github.com/pulumi/pulumi-aws/sdk/v6 v6.39.0 h1:MVBKXVDr4As1B2LcAzWrPLn0ysR0oiCEQOBvnsrEOcY=
github.com/pulumi/pulumi-aws/sdk/v6 v6.39.0/go.mod h1:cV2EBfrvaS/YUKr9L0ua93vrSuAihpkhokzyYjj6NkQ=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.53.0 h1:7B7mN9R69GL+maOO/qjwT1u/eVag0mQItFaflO9B5kY=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.53.0/go.mod h1:r62G2PykMJ+j2uqvl9OjwxavtgiWijWcGGXEh70lSKw=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.45.0 h1:BcYPQlIP/oWv/g9rwfYqWzIHTW39g3kxAV0Z+TceFFY=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.45.0/go.mod h1:7qkKema4IyvzG0rcmHe6QzjpM4qhWDPzcm9ZV1qk1hg=
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.53.0 h1:i/52lLXiRh3pCjn8wKG5qq9sCXUQ6SOPSVQsCnXYNgU=
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.53.0/go.mod h1:h0TLC2XYohDDMvSf7MzCVTp6S9RzPl39lzzceJZ8YRE=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.64.2 h1:vJzGBj5viOFTCfYyKwc7p9b4rcW37bHAsbS5mka0uow=
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.64.2/go.mod h1:PWdAgtaVplvbqTGkqD3hR7AVTRTP8X/q9YDJQVVHNCM=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.64.2 h1:J74vg89UTseQAq9L2rYaf8RW7aVt+PAUj7SBRu1YG08=
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.64.2/go.mod h1:NNS9WhpTuiIftC0AFA1BlfHvqgeY1UOwyWeRSEMZg+A=
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.64.2 h1:ULOfuN9Iodvjgm9kG9YP5Ed22EOSRHRmZGRicPGLiCo=
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.64.2/go.mod h1:iGsy7/ehEDoD7ZLTlQRG0lTDRwARRho2Z3Vf3beYfUE=
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.53.0 h1:HctTS276Dl0hzqyioTuvLSfFO6xUy0DALtF3Kr2DrmI=
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.53.0/go.mod h1:qMFN9OZL50ARd8xi9zFMpCLflH/3YIT1MtXe5Qxu+54=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.45.0 h1:uUzU9o1JVKkeotHi3EVJSe2U42nTQUzW1rCLRxJjQUk=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.45.0/go.mod h1:idXEoECzvjGSRDj6acTDABtR8H65EVZ5l1IhwV5ApYU=
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.45.0 h1:Y199bwRu/YNAKvz6eOMw4elJQsVDbu/g9gjPUw7E0Ng=
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.45.0/go.mod h1:PFHqlzfFRyxU1BNRahKpQFXVNTbgasOatIjJuzjq8dM=
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.45.0 h1:Sl1ANAacpgRUPENu9NeDSN/7Y0vrhYXsvnU7dDztiZw=
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.45.0/go.mod h1:i0f7n5clAURlOqIEqcQQGYE04Ic6hU1gzf+Htwg51eY=
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.53.0 h1:TlzYzmrDVIHfUI9+R+WJA+81P490Ppq7mOBGRJpCqvI=
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.53.0/go.mod h1:4nh0eqK0xakTjrPcwfhqfql3odQFw+CUqxg1H87Ujy8=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.64.2 h1:QG2Wp1m/1C4fSzxbp/oWfitpfJ44k9T04nB0zjN4lRc=
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.64.2/go.mod h1:FGzP1UI3jXg5QI0cU3KZi4tyhD2Xx9K8fdgTQyg2/Ps=
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.64.2 h1:0qKMJsFgoqBXI93oMlNoHIT0HkLDhzsPqEB1DusmXR4=
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.64.2/go.mod h1:g3WeHy2U/COLYZ/W5v+EHwIwp66+Hm/0GBu2F0Zs/qE=
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.64.2 h1:qyKJs/0hX1+AlkC17PP46AIlC4WRHX2EB1MIuSkQ05g=
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.64.2/go.mod h1:XYgPtWQ277cdQaHiX6Ml1gFfN7FIKPLl8hEW/44Vrcg=
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.64.2 h1:kU2KoBPkbfP74RNQabLgGeB61fCLvt/dIDG8LEwvd4M=
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.64.2/go.mod h1:vFd7IQFHtss7v1j0906SwyLcANJer1O9SnkrVj4pRsw=
github.com/pulumi/pulumi-command/sdk v0.11.1 h1:5LCte8TvYlnOfD2Cn6Xm7ZA1fRtT74XAP0QvCPFpIcA=
github.com/pulumi/pulumi-command/sdk v0.11.1/go.mod h1:NfMh7+awKDW3r8Z91JkAN4/lRPsXcCsMqGID0YJHjkk=
github.com/pulumi/pulumi-random/sdk/v4 v4.16.2 h1:5el+INHB9exKLbuQMaz1OEmnasU1A6/GoOMFHCveXb8=
github.com/pulumi/pulumi-random/sdk/v4 v4.16.2/go.mod h1:FuKLicnDYepG3W/tGmqCYkgdML5GK9RE/Ti984E/Tq8=
github.com/pulumi/pulumi-tls/sdk/v5 v5.0.3 h1:kbdrJVO1PczQakfZZ2Ke2P5G4jlPgTw2geGHR2+7zYc=
github.com/pulumi/pulumi-tls/sdk/v5 v5.0.3/go.mod h1:onWsBMCIYPEHfGAQ24FRZ67JtJDkuUQQLd9zp5MDoTM=
github.com/pulumi/pulumi/sdk/v3 v3.128.0 h1:5VPFfygxt6rva0bEYVQZXxsGAo2/D1wsb9erGOtXxzk=
github.com/pulumi/pulumi/sdk/v3 v3.128.0/go.mod h1:p1U24en3zt51agx+WlNboSOV8eLlPWYAkxMzVEXKbnY=
github.com/pulumi/pulumi/sdk/v3 v3.135.0 h1:oBP7QsmZv6uUf3eJ9j6av0nrZpipV9IguNu6rVpHlFU=
github.com/pulumi/pulumi/sdk/v3 v3.135.0/go.mod h1:J5kQEX8v87aeUhk6NdQXnjCo1DbiOnOiL3Sf2DuDda8=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
Expand Down Expand Up @@ -334,8 +334,6 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/texttheater/golang-levenshtein v1.0.1 h1:+cRNoVrfiwufQPhoMzB6N0Yf/Mqajr6t1lOv8GyGE2U=
github.com/texttheater/golang-levenshtein v1.0.1/go.mod h1:PYAKrbF5sAiq9wd+H82hs7gNaen0CplQ9uvm6+enD/8=
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7 h1:X9dsIWPuuEJlPX//UmRKophhOKCGXc46RVIGuttks68=
github.com/tweekmonster/luser v0.0.0-20161003172636-3fa38070dbd7/go.mod h1:UxoP3EypF8JfGEjAII8jx1q8rQyDnX8qdTCs/UQBVIE=
github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o=
github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk=
github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg=
Expand Down
4 changes: 2 additions & 2 deletions oci/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ WORKDIR /workspace
COPY . .

# renovate: datasource=github-releases depName=pulumi/pulumi
ENV PULUMI_VERSION 3.119.0
ENV PULUMI_VERSION 3.135.0
ENV PULUMI_URL https://github.com/pulumi/pulumi/releases/download/v${PULUMI_VERSION}/pulumi-v${PULUMI_VERSION}-linux-x64.tar.gz

RUN make build \
Expand Down Expand Up @@ -39,7 +39,7 @@ ARG PULUMI_AWS_VERSION=v6.37.1
# renovate: datasource=github-releases depName=pulumi/pulumi-aws
ARG PULUMI_AWSX_VERSION=v2.3.0
# renovate: datasource=github-releases depName=pulumi/pulumi-azure-native
ARG PULUMI_AZURE_NATIVE_VERSION=v2.45.0
ARG PULUMI_AZURE_NATIVE_VERSION=v2.64.2
# renovate: datasource=github-releases depName=pulumi/pulumi-command
ARG PULUMI_COMMAND_VERSION=v0.11.1
# renovate: datasource=github-releases depName=pulumi/pulumi-tls
Expand Down
61 changes: 35 additions & 26 deletions pkg/provider/azure/action/aks/aks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/pulumi/pulumi-azure-native-sdk/authorization/v2"
"github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2"
containerservice "github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2/v20240801"
"github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2"
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
Expand All @@ -27,6 +27,7 @@ type AKSRequest struct {
// "1.26.3"
KubernetesVersion string
OnlySystemPool bool
EnableAppRouting bool
Spot bool
SpotTolerance spotAzure.EvictionRate
}
Expand Down Expand Up @@ -133,35 +134,43 @@ func (r *AKSRequest) deployer(ctx *pulumi.Context) error {
SpotMaxPrice: pulumi.Float64(*spotPrice)},
)
}
cluster, err := containerservice.NewManagedCluster(
ctx,
resourcesUtil.GetResourceName(r.Prefix, azureAKSID, "cluster"),
&containerservice.ManagedClusterArgs{
ResourceGroupName: rg.Name,
Location: rg.Location,
Identity: &containerservice.ManagedClusterIdentityArgs{
Type: containerservice.ResourceIdentityTypeUserAssigned,
UserAssignedIdentities: pulumi.StringArray{
identity.ID(),
},
managedClusterArgs := &containerservice.ManagedClusterArgs{
ResourceGroupName: rg.Name,
Location: rg.Location,
Identity: &containerservice.ManagedClusterIdentityArgs{
Type: containerservice.ResourceIdentityTypeUserAssigned,
UserAssignedIdentities: pulumi.StringArray{
identity.ID(),
},
KubernetesVersion: pulumi.String(r.KubernetesVersion),
DnsPrefix: pulumi.String("mapt"),
EnableRBAC: pulumi.Bool(true),
AgentPoolProfiles: agentPoolProfiles,
LinuxProfile: &containerservice.ContainerServiceLinuxProfileArgs{
AdminUsername: pulumi.String("aksuser"),
Ssh: &containerservice.ContainerServiceSshConfigurationArgs{
PublicKeys: containerservice.ContainerServiceSshPublicKeyArray{
&containerservice.ContainerServiceSshPublicKeyArgs{
KeyData: privateKey.PublicKeyOpenssh,
},
},
KubernetesVersion: pulumi.String(r.KubernetesVersion),
DnsPrefix: pulumi.String("mapt"),
EnableRBAC: pulumi.Bool(true),
AgentPoolProfiles: agentPoolProfiles,
LinuxProfile: &containerservice.ContainerServiceLinuxProfileArgs{
AdminUsername: pulumi.String("aksuser"),
Ssh: &containerservice.ContainerServiceSshConfigurationArgs{
PublicKeys: containerservice.ContainerServiceSshPublicKeyArray{
&containerservice.ContainerServiceSshPublicKeyArgs{
KeyData: privateKey.PublicKeyOpenssh,
},
},
},
Tags: maptContext.ResourceTags(),
})

},
Tags: maptContext.ResourceTags(),
}
// Enable app routing if required
if r.EnableAppRouting {
managedClusterArgs.IngressProfile = containerservice.ManagedClusterIngressProfileArgs{
WebAppRouting: containerservice.ManagedClusterIngressProfileWebAppRoutingArgs{
Enabled: pulumi.Bool(true),
},
}
}
cluster, err := containerservice.NewManagedCluster(
ctx,
resourcesUtil.GetResourceName(r.Prefix, azureAKSID, "cluster"),
managedClusterArgs)
if err != nil {
return err
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5dc1187

Please sign in to comment.