Skip to content

Commit

Permalink
Support unified cluster-aws app (#1324)
Browse files Browse the repository at this point in the history
* Add support for unified cluster-aws App
  • Loading branch information
nprokopic committed May 14, 2024
1 parent 5a30856 commit 6cd8887
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 289 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ and this project's packages adheres to [Semantic Versioning](http://semver.org/s

- Default value for CAPA Node Pool `rootVolumeSizeGB` was decreased from `300` to `8`.

### Added

- Support unified cluster-aws app. With cluster-aws v0.76.0 and newer, default apps are deployed with cluster-aws and default-apps-aws app is not deployed anymore.

## [2.53.0] - 2024-04-23

### Changed
Expand Down
34 changes: 22 additions & 12 deletions cmd/template/cluster/provider/capa.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"text/template"

"github.com/3th1nk/cidr"
"github.com/Masterminds/semver/v3"
"github.com/giantswarm/k8sclient/v7/pkg/k8sclient"
"github.com/giantswarm/microerror"
"github.com/pkg/errors"
Expand All @@ -33,20 +34,38 @@ const (
)

func WriteCAPATemplate(ctx context.Context, client k8sclient.Interface, output io.Writer, config ClusterConfig) error {
err := templateClusterCAPA(ctx, client, output, config)
appVersion := config.App.ClusterVersion
if appVersion == "" {
var err error
appVersion, err = getLatestVersion(ctx, client.CtrlClient(), ClusterAWSRepoName, config.App.ClusterCatalog)
if err != nil {
return microerror.Mask(err)
}
}

err := templateClusterCAPA(ctx, client, output, config, appVersion)
if err != nil {
return microerror.Mask(err)
}

err = templateDefaultAppsCAPA(ctx, client, output, config)
minUnifiedClusterAwsVersion := semver.New(0, 76, 0, "", "")
desiredClusterAwsVersion, err := semver.StrictNewVersion(appVersion)
if err != nil {
return microerror.Mask(err)
}

if desiredClusterAwsVersion.LessThan(minUnifiedClusterAwsVersion) {
// Render default-apps-aws only when cluster-aws version does not contain default apps.
err = templateDefaultAppsCAPA(ctx, client, output, config)
if err != nil {
return microerror.Mask(err)
}
}

return nil
}

func templateClusterCAPA(ctx context.Context, k8sClient k8sclient.Interface, output io.Writer, config ClusterConfig) error {
func templateClusterCAPA(ctx context.Context, k8sClient k8sclient.Interface, output io.Writer, config ClusterConfig, appVersion string) error {
appName := config.Name
configMapName := userConfigMapName(appName)

Expand Down Expand Up @@ -222,15 +241,6 @@ func templateClusterCAPA(ctx context.Context, k8sClient k8sclient.Interface, out

var appYAML []byte
{
appVersion := config.App.ClusterVersion
if appVersion == "" {
var err error
appVersion, err = getLatestVersion(ctx, k8sClient.CtrlClient(), ClusterAWSRepoName, config.App.ClusterCatalog)
if err != nil {
return microerror.Mask(err)
}
}

clusterAppConfig := templateapp.Config{
AppName: config.Name,
Catalog: config.App.ClusterCatalog,
Expand Down
46 changes: 0 additions & 46 deletions cmd/template/cluster/testdata/run_template_cluster_capa.golden
Original file line number Diff line number Diff line change
Expand Up @@ -83,49 +83,3 @@ spec:
name: test1-userconfig
namespace: org-test
version: 1.0.0
---
apiVersion: v1
data:
values: |
clusterName: test1
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test1
name: test1-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test1
giantswarm.io/managed-by: cluster
name: test1-default-apps
namespace: org-test
spec:
catalog: the-default-catalog
config:
configMap:
name: test1-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-aws
namespace: org-test
userConfig:
configMap:
name: test1-default-apps-userconfig
namespace: org-test
version: 2.0.0
46 changes: 0 additions & 46 deletions cmd/template/cluster/testdata/run_template_cluster_capa_2.golden
Original file line number Diff line number Diff line change
Expand Up @@ -85,49 +85,3 @@ spec:
name: test1-userconfig
namespace: org-test
version: 1.0.0
---
apiVersion: v1
data:
values: |
clusterName: test1
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test1
name: test1-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test1
giantswarm.io/managed-by: cluster
name: test1-default-apps
namespace: org-test
spec:
catalog: the-default-catalog
config:
configMap:
name: test1-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-aws
namespace: org-test
userConfig:
configMap:
name: test1-default-apps-userconfig
namespace: org-test
version: 2.0.0
46 changes: 0 additions & 46 deletions cmd/template/cluster/testdata/run_template_cluster_capa_3.golden
Original file line number Diff line number Diff line change
Expand Up @@ -88,49 +88,3 @@ spec:
name: test1-userconfig
namespace: org-test
version: 1.0.0
---
apiVersion: v1
data:
values: |
clusterName: test1
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test1
name: test1-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test1
giantswarm.io/managed-by: cluster
name: test1-default-apps
namespace: org-test
spec:
catalog: the-default-catalog
config:
configMap:
name: test1-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-aws
namespace: org-test
userConfig:
configMap:
name: test1-default-apps-userconfig
namespace: org-test
version: 2.0.0
46 changes: 0 additions & 46 deletions cmd/template/cluster/testdata/run_template_cluster_capa_6.golden
Original file line number Diff line number Diff line change
Expand Up @@ -79,49 +79,3 @@ spec:
name: test6-userconfig
namespace: org-test
version: 1.0.0
---
apiVersion: v1
data:
values: |
clusterName: test6
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test6
name: test6-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test6
giantswarm.io/managed-by: cluster
name: test6-default-apps
namespace: org-test
spec:
catalog: the-default-catalog
config:
configMap:
name: test6-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-aws
namespace: org-test
userConfig:
configMap:
name: test6-default-apps-userconfig
namespace: org-test
version: 2.0.0
46 changes: 0 additions & 46 deletions cmd/template/cluster/testdata/run_template_cluster_capa_7.golden
Original file line number Diff line number Diff line change
Expand Up @@ -83,49 +83,3 @@ spec:
name: test7-userconfig
namespace: org-test
version: 1.0.0
---
apiVersion: v1
data:
values: |
clusterName: test7
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test7
name: test7-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test7
giantswarm.io/managed-by: cluster
name: test7-default-apps
namespace: org-test
spec:
catalog: the-default-catalog
config:
configMap:
name: test7-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-aws
namespace: org-test
userConfig:
configMap:
name: test7-default-apps-userconfig
namespace: org-test
version: 2.0.0
46 changes: 0 additions & 46 deletions cmd/template/cluster/testdata/run_template_cluster_capa_8.golden
Original file line number Diff line number Diff line change
Expand Up @@ -75,49 +75,3 @@ spec:
name: test8-userconfig
namespace: org-test
version: 1.0.0
---
apiVersion: v1
data:
values: |
clusterName: test8
organization: test
kind: ConfigMap
metadata:
creationTimestamp: null
labels:
giantswarm.io/cluster: test8
name: test8-default-apps-userconfig
namespace: org-test
---
apiVersion: application.giantswarm.io/v1alpha1
kind: App
metadata:
labels:
app-operator.giantswarm.io/version: 0.0.0
giantswarm.io/cluster: test8
giantswarm.io/managed-by: cluster
name: test8-default-apps
namespace: org-test
spec:
catalog: the-default-catalog
config:
configMap:
name: test8-cluster-values
namespace: org-test
secret:
name: ""
namespace: ""
kubeConfig:
context:
name: ""
inCluster: true
secret:
name: ""
namespace: ""
name: default-apps-aws
namespace: org-test
userConfig:
configMap:
name: test8-default-apps-userconfig
namespace: org-test
version: 2.0.0
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21
require (
dario.cat/mergo v1.0.0
github.com/3th1nk/cidr v0.2.0
github.com/Masterminds/semver/v3 v3.2.1
github.com/Masterminds/sprig/v3 v3.2.3
github.com/ProtonMail/gopenpgp/v2 v2.7.5
github.com/blang/semver v3.5.1+incompatible
Expand Down Expand Up @@ -71,7 +72,6 @@ require (
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect
Expand Down

0 comments on commit 6cd8887

Please sign in to comment.