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

update: crossplane to v1.16.0, use new Upjet AWS provider #197

Merged
merged 1 commit into from
Jul 25, 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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ The application catalog includes:
* `fluent-bit` — Container Insights Fluent Bit Logs
* `prometheus` — CloudWatch Container Insights monitoring for Prometheus
* `core-dump-handler` - Automatically saves core dumps to S3
* `crossplane` — Cloud Native Control Planes
* `crossplane` — The Cloud Native Control Plane
* `core` — Crossplane Core Components
* `s3-provider` — Crossplane S3 Provider
* `example` — Example Applications
* `eks-workshop` — EKS Workshop Example Microservices
* `game-2048` — Example Game 2048
Expand Down
2 changes: 1 addition & 1 deletion cmd/create/ack.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func NewAckCmd() *cobra.Command {
Short: "AWS Controllers for Kubernetes (ACK)",
}

// Don't show flag errors for `create ack`` without a subcommand
// Don't show flag errors for `create ack` without a subcommand
cmd.DisableFlagParsing = true

for _, r := range ack {
Expand Down
51 changes: 51 additions & 0 deletions cmd/install/crossplane.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package install

import (
"github.com/awslabs/eksdemo/pkg/application"
"github.com/awslabs/eksdemo/pkg/application/crossplane/core"
"github.com/awslabs/eksdemo/pkg/application/crossplane/s3"
"github.com/spf13/cobra"
)

var crossplane []func() *application.Application

func NewInstallCrossplaneCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "crossplane",
Short: "The Cloud Native Control Plane",
Aliases: []string{"cp"},
}

// Don't show flag errors for `install crossplane` without a subcommand
cmd.DisableFlagParsing = true

for _, cp := range crossplane {
cmd.AddCommand(cp().NewInstallCmd())
}

return cmd
}

func NewUninstallCrossplaneCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "crossplane",
Short: "The Cloud Native Control Plane",
Aliases: []string{"cp"},
}

// Don't show flag errors for `uninstall crossplane` without a subcommand
cmd.DisableFlagParsing = true

for _, cp := range crossplane {
cmd.AddCommand(cp().NewUninstallCmd())
}

return cmd
}

func init() {
crossplane = []func() *application.Application{
core.NewApp,
s3.NewApp,
}
}
5 changes: 3 additions & 2 deletions cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/awslabs/eksdemo/pkg/application/cilium"
"github.com/awslabs/eksdemo/pkg/application/consul"
"github.com/awslabs/eksdemo/pkg/application/coredumphandler"
"github.com/awslabs/eksdemo/pkg/application/crossplane"
"github.com/awslabs/eksdemo/pkg/application/external_dns"
"github.com/awslabs/eksdemo/pkg/application/falco"
"github.com/awslabs/eksdemo/pkg/application/harbor"
Expand Down Expand Up @@ -59,7 +58,9 @@ func NewInstallCmd() *cobra.Command {
cmd.AddCommand(NewInstallAliasCmds(containerInsightsApps, "container-insights-")...)
cmd.AddCommand(NewInstallAliasCmds(containerInsightsApps, "ci-")...)
cmd.AddCommand(coredumphandler.NewApp().NewInstallCmd())
cmd.AddCommand(crossplane.NewApp().NewInstallCmd())
cmd.AddCommand(NewInstallCrossplaneCmd())
cmd.AddCommand(NewInstallAliasCmds(crossplane, "crossplane-")...)
cmd.AddCommand(NewInstallAliasCmds(crossplane, "cp-")...)
cmd.AddCommand(NewInstallExampleCmd())
cmd.AddCommand(NewInstallAliasCmds(exampleApps, "example-")...)
cmd.AddCommand(NewInstallAliasCmds(exampleApps, "ex-")...)
Expand Down
5 changes: 3 additions & 2 deletions cmd/install/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/awslabs/eksdemo/pkg/application/cilium"
"github.com/awslabs/eksdemo/pkg/application/consul"
"github.com/awslabs/eksdemo/pkg/application/coredumphandler"
"github.com/awslabs/eksdemo/pkg/application/crossplane"
"github.com/awslabs/eksdemo/pkg/application/external_dns"
"github.com/awslabs/eksdemo/pkg/application/falco"
"github.com/awslabs/eksdemo/pkg/application/harbor"
Expand Down Expand Up @@ -59,7 +58,9 @@ func NewUninstallCmd() *cobra.Command {
cmd.AddCommand(NewUninstallAliasCmds(containerInsightsApps, "container-insights-")...)
cmd.AddCommand(NewUninstallAliasCmds(containerInsightsApps, "ci-")...)
cmd.AddCommand(coredumphandler.NewApp().NewUninstallCmd())
cmd.AddCommand(crossplane.NewApp().NewUninstallCmd())
cmd.AddCommand(NewUninstallCrossplaneCmd())
cmd.AddCommand(NewUninstallAliasCmds(crossplane, "crossplane-")...)
cmd.AddCommand(NewUninstallAliasCmds(crossplane, "cp-")...)
cmd.AddCommand(NewUninstallExampleCmd())
cmd.AddCommand(NewUninstallAliasCmds(exampleApps, "example-")...)
cmd.AddCommand(NewUninstallAliasCmds(exampleApps, "ex-")...)
Expand Down
57 changes: 0 additions & 57 deletions pkg/application/crossplane/aws_provider.go

This file was deleted.

80 changes: 80 additions & 0 deletions pkg/application/crossplane/check_core.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package crossplane

import (
"context"
"fmt"

"github.com/awslabs/eksdemo/pkg/kubernetes"
"github.com/awslabs/eksdemo/pkg/resource"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
)

func CheckCore() *resource.Resource {
return &resource.Resource{
Options: &resource.CommonOptions{
Name: "check-for-crossplane-core",
},

Manager: &CheckResourceManager{
Name: "Crossplane Core",
Message: "please install \"crossplane-core\" first",
Group: "pkg.crossplane.io",
Resource: "providers",
Version: "v1",
},
}
}

type CheckResourceManager struct {
DryRun bool
Name string
Message string

Group string
Resource string
Version string
resource.EmptyInit
}

func (m *CheckResourceManager) Create(options resource.Options) error {
if m.DryRun {
fmt.Println("\nCheck Resource Manager Dry Run:")
fmt.Println("Will check for: ", m.Name)
fmt.Printf("Check performs a List operaton on Group: %q, Resource: %q, Version: %q\n", m.Group, m.Resource, m.Version)
return nil
}

client, err := kubernetes.DynamicClient(options.Common().KubeContext)
if err != nil {
return err
}

providerConfig := schema.GroupVersionResource{
Group: m.Group,
Resource: m.Resource,
Version: m.Version,
}

_, err = client.Resource(providerConfig).List(context.Background(), metav1.ListOptions{})
if err != nil {
return fmt.Errorf(m.Message)
}

fmt.Printf("%q found\n", m.Name)

return nil
}

func (m *CheckResourceManager) Delete(_ resource.Options) error {
return nil
}

func (m *CheckResourceManager) SetDryRun() {
m.DryRun = true
}

func (m *CheckResourceManager) Update(_ resource.Options, _ *cobra.Command) error {
return fmt.Errorf("feature not supported")
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package crossplane
package core

import (
"github.com/awslabs/eksdemo/pkg/application"
Expand All @@ -8,26 +8,23 @@ import (
"github.com/awslabs/eksdemo/pkg/template"
)

// Docs: https://crossplane.io/docs/
// Docs: https://docs.crossplane.io
// GitHub: https://github.com/crossplane/crossplane
// Helm: https://github.com/crossplane/crossplane/tree/master/cluster/charts/crossplane
// Repo: crossplane/crossplane
// Version: Latest is Chart/App v1.9.0, Provider AWS v0.29.0 (as of 08/07/22)
// Repo: xpkg.upbound.io/crossplane/crossplane
// Version: Latest is Chart/App v1.16.0 (as of 7/21/24)

func NewApp() *application.Application {
options, flags := newOptions()

app := &application.Application{
return &application.Application{
Command: cmd.Command{
Name: "crossplane",
Description: "Cloud Native Control Planes",
Parent: "crossplane",
Name: "core",
Description: "Crossplane Core Components",
},

Dependencies: []*resource.Resource{
crossplaneIrsa(options),
},

Options: &application.ApplicationOptions{},
Flags: flags,

Installer: &installer.HelmInstaller{
ChartName: "crossplane",
Expand All @@ -38,17 +35,15 @@ func NewApp() *application.Application {
},
},

Options: options,

PostInstallResources: []*resource.Resource{
waitForControllerConfigCRD(),
awsProvider(options),
waitForProviderCRD(),
providerFamilyAWS(options),
waitForProviderConfigCRD(),
defaultProviderConfig(),
},
}
app.Options = options
app.Flags = flags

return app
}

const valuesTemplate = `---
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
package crossplane
package core

import (
"github.com/awslabs/eksdemo/pkg/application"
"github.com/awslabs/eksdemo/pkg/cmd"
)

type CrossplaneOptions struct {
type Options struct {
application.ApplicationOptions
ProviderVersion string
}

func newOptions() (options *CrossplaneOptions, flags cmd.Flags) {
options = &CrossplaneOptions{
func newOptions() (options *Options, flags cmd.Flags) {
options = &Options{
ApplicationOptions: application.ApplicationOptions{
DefaultVersion: &application.LatestPrevious{
LatestChart: "1.9.0",
Latest: "v1.9.0",
PreviousChart: "1.9.0",
Previous: "v1.9.0",
LatestChart: "1.16.0",
Latest: "v1.16.0",
PreviousChart: "1.16.0",
Previous: "v1.16.0",
},
DisableServiceAccountFlag: true,
Namespace: "crossplane-system",
// Used for role name in custom IRSA
ServiceAccount: "provider-aws",
Namespace: "crossplane",
},
ProviderVersion: "v0.29.0",
ProviderVersion: "v1.9.0",
}

flags = cmd.Flags{
&cmd.StringFlag{
CommandFlag: cmd.CommandFlag{
Name: "provider-version",
Description: "version of provider-aws",
Description: "version of provider-family-aws",
},
Option: &options.ProviderVersion,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package crossplane
package core

import (
"github.com/awslabs/eksdemo/pkg/manifest"
Expand All @@ -22,11 +22,11 @@ func defaultProviderConfig() *resource.Resource {
}

const providerConfigManifest = `---
apiVersion: aws.crossplane.io/v1beta1
apiVersion: aws.upbound.io/v1beta1
kind: ProviderConfig
metadata:
name: default
spec:
credentials:
source: InjectedIdentity
source: IRSA
`
Loading