Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: ACK controllers #241

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions cmd/install/ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ package install
import (
"github.com/awslabs/eksdemo/pkg/application"
"github.com/awslabs/eksdemo/pkg/application/ack"
"github.com/awslabs/eksdemo/pkg/application/ack/apigatewayv2_controller"
"github.com/awslabs/eksdemo/pkg/application/ack/ec2_controller"
"github.com/awslabs/eksdemo/pkg/application/ack/ecr_controller"
"github.com/awslabs/eksdemo/pkg/application/ack/eks_controller"
"github.com/awslabs/eksdemo/pkg/application/ack/iam_controller"
"github.com/awslabs/eksdemo/pkg/application/ack/prometheusservice_controller"
"github.com/awslabs/eksdemo/pkg/application/ack/s3_controller"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -49,13 +42,13 @@ func NewUninstallAckCmd() *cobra.Command {

func init() {
ackControllers = []func() *application.Application{
apigatewayv2_controller.NewApp,
ec2_controller.NewApp,
ecr_controller.NewApp,
eks_controller.NewApp,
iam_controller.NewApp,
prometheusservice_controller.NewApp,
ack.NewAPIGatewayv2Controller,
ack.NewEC2Controller,
ack.NewECRController,
ack.NewEKSController,
ack.NewIAMController,
ack.NewPrometheusServiceController,
ack.NewRDSController,
s3_controller.NewApp,
ack.NewS3Controller,
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package apigatewayv2_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/apigatewayv2-controller
// Version: Latest is v1.0.16 (as of 9/5/24)

func NewApp() *application.Application {
func NewAPIGatewayv2Controller() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand Down Expand Up @@ -55,14 +55,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-apigatewayv2-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/apigatewayv2-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: apiGatewayv2ValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/apigatewayv2-controller/blob/main/helm/values.yaml
const valuesTemplate = `---
const apiGatewayv2ValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-apigatewayv2-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ec2_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/ec2-controller
// Version: Latest is v1.2.20 (as of 9/4/24)

func NewApp() *application.Application {
func NewEC2Controller() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand Down Expand Up @@ -52,14 +52,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-ec2-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/ec2-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: ec2ValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/ec2-controller/blob/main/helm/values.yaml
const valuesTemplate = `---
const ec2ValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-ec2-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ecr_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/ecr-controller
// Version: Latest is v1.0.18 (as of 9/5/24)

func NewApp() *application.Application {
func NewECRController() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand Down Expand Up @@ -52,14 +52,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-ecr-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/ecr-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: ecrValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/ecr-controller/blob/main/helm/values.yaml
const valuesTemplate = `---
const ecrValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-ecr-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eks_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/eks-controller
// Version: Latest is v1.4.5 (as of 9/5/24)

func NewApp() *application.Application {
func NewEKSController() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand All @@ -34,7 +34,7 @@ func NewApp() *application.Application {
},
PolicyType: irsa.PolicyDocument,
PolicyDocTemplate: &template.TextTemplate{
Template: policyDocTemplate,
Template: eksPolicyDocTemplate,
},
}),
},
Expand All @@ -54,14 +54,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-eks-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/eks-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: eksValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/eks-controller/blob/main/config/iam/recommended-inline-policy
const policyDocTemplate = `
const eksPolicyDocTemplate = `
Version: '2012-10-17'
Statement:
- Effect: Allow
Expand All @@ -78,7 +78,7 @@ Statement:
Resource: arn:{{ .Partition }}:iam::{{ .Account }}:role/eksdemo.{{ .ClusterName }}.fargate-pod-execution-role
`

const valuesTemplate = `---
const eksValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-eks-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eks_controller
package ack

import (
"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
Expand All @@ -8,7 +8,7 @@ import (
)

func fargatePodExecutionRole() *resource.Resource {
res := &resource.Resource{
return &resource.Resource{
Options: &resource.CommonOptions{
Name: "fargate-pod-execution-role",
},
Expand All @@ -20,7 +20,6 @@ func fargatePodExecutionRole() *resource.Resource {
},
},
}
return res
}

const cloudFormationTemplate = `
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package iam_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/iam-controller
// Version: Latest is v1.3.12 (as of 9/5/24)

func NewApp() *application.Application {
func NewIAMController() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand All @@ -33,7 +33,7 @@ func NewApp() *application.Application {
},
PolicyType: irsa.PolicyDocument,
PolicyDocTemplate: &template.TextTemplate{
Template: policyDocTemplate,
Template: iamPolicyDocTemplate,
},
}),
},
Expand All @@ -53,14 +53,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-iam-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/iam-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: iamValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/iam-controller/blob/main/config/iam/recommended-inline-policy
const policyDocTemplate = `
const iamPolicyDocTemplate = `
Version: '2012-10-17'
Statement:
- Effect: Allow
Expand Down Expand Up @@ -129,7 +129,7 @@ Statement:
`

// https://github.com/aws-controllers-k8s/iam-controller/blob/main/helm/values.yaml
const valuesTemplate = `---
const iamValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-iam-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package prometheusservice_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/prometheusservice-controller
// Version: Latest is v1.2.13 (as of 9/6/24)

func NewApp() *application.Application {
func NewPrometheusServiceController() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand All @@ -33,7 +33,7 @@ func NewApp() *application.Application {
},
PolicyType: irsa.PolicyDocument,
PolicyDocTemplate: &template.TextTemplate{
Template: policyDocTemplate,
Template: ampPolicyDocTemplate,
},
}),
},
Expand All @@ -53,14 +53,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-prometheusservice-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/prometheusservice-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: ampValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/prometheusservice-controller/blob/main/config/iam/recommended-inline-policy
const policyDocTemplate = `
const ampPolicyDocTemplate = `
Version: '2012-10-17'
Statement:
- Effect: Allow
Expand All @@ -74,7 +74,7 @@ Statement:
`

// https://github.com/aws-controllers-k8s/prometheusservice-controller/blob/main/helm/values.yaml
const valuesTemplate = `---
const ampValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-prometheusservice-controller
Expand Down
4 changes: 2 additions & 2 deletions pkg/application/ack/rds_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ func NewRDSController() *application.Application {
ReleaseName: "ack-rds-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/rds-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: rdsValuesTemplate,
},
},
}
}

// https://github.com/aws-controllers-k8s/rds-controller/blob/main/helm/values.yaml
const valuesTemplate = `---
const rdsValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-rds-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package s3_controller
package ack

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -17,7 +17,7 @@ import (
// Repo: https://gallery.ecr.aws/aws-controllers-k8s/s3-controller
// Version: Latest is v1.0.16 (as of 9/6/24)

func NewApp() *application.Application {
func NewS3Controller() *application.Application {
return &application.Application{
Command: cmd.Command{
Parent: "ack",
Expand Down Expand Up @@ -52,13 +52,14 @@ func NewApp() *application.Application {
ReleaseName: "ack-s3-controller",
RepositoryURL: "oci://public.ecr.aws/aws-controllers-k8s/s3-chart",
ValuesTemplate: &template.TextTemplate{
Template: valuesTemplate,
Template: s3ValuesTemplate,
},
},
}
}

const valuesTemplate = `---
// https://github.com/aws-controllers-k8s/s3-controller/blob/main/helm/values.yaml
const s3ValuesTemplate = `---
image:
tag: {{ .Version }}
fullnameOverride: ack-s3-controller
Expand Down