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

feat: use kuma version when installing it #949

Merged
merged 6 commits into from
Feb 5, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

- `Kuma` addon now properly uses the Helm chart version passed in its builder's
`WithVersion` method.
[#949](https://github.com/Kong/kubernetes-testing-framework/pull/949)

## v0.44.0

- Added a call to `NegotiateAPIVersion` when creating a Docker client to
Expand Down
17 changes: 13 additions & 4 deletions pkg/clusters/addons/kuma/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Addon struct {
name string
logger *logrus.Logger

version semver.Version
version *semver.Version

mtlsEnabled bool
}
Expand All @@ -61,9 +61,14 @@ func (a *Addon) Namespace() string {
return Namespace
}

// Version indicates the Kuma version for this addon.
func (a *Addon) Version() semver.Version {
return a.version
// Version returns the version of the Kuma Helm chart deployed by the addon.
// If the version is not set, the second return value will be false and the latest local
// chart version will be used.
func (a *Addon) Version() (v semver.Version, ok bool) {
if a.version == nil {
return semver.Version{}, false
}
return *a.version, true
}

// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -144,6 +149,10 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
// if the dbmode is postgres, set several related values
args := []string{"--kubeconfig", kubeconfig.Name(), "install", DefaultReleaseName, "kuma/kuma"}

if a.version != nil {
args = append(args, "--version", a.version.String())
}

czeslavo marked this conversation as resolved.
Show resolved Hide resolved
// compile the helm installation values
args = append(args, "--create-namespace", "--namespace", Namespace)
a.logger.Debugf("helm install arguments: %+v", args)
Expand Down
4 changes: 2 additions & 2 deletions pkg/clusters/addons/kuma/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// Builder is a configuration tool to generate Kuma cluster addons.
type Builder struct {
name string
version semver.Version
version *semver.Version
logger *logrus.Logger

mtlsEnabled bool
Expand All @@ -29,7 +29,7 @@ func NewBuilder() *Builder {

// WithVersion configures the specific version of Kuma which should be deployed.
func (b *Builder) WithVersion(version semver.Version) *Builder {
b.version = version
b.version = &version
return b
}

Expand Down
11 changes: 8 additions & 3 deletions test/e2e/gke_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
"github.com/kong/kubernetes-testing-framework/pkg/utils/kubernetes/generators"
)

const (
gkeVersionMajor = 1
gkeVersionMinor = 29
)

var (
gkeCreds = os.Getenv(gke.GKECredsVar)
gkeProject = os.Getenv(gke.GKEProjectVar)
Expand Down Expand Up @@ -60,7 +65,7 @@ func testGKECluster(t *testing.T, createSubnet bool) {

t.Logf("configuring the GKE cluster PROJECT=(%s) LOCATION=(%s)", gkeProject, gkeLocation)
builder := gke.NewBuilder([]byte(gkeCreds), gkeProject, gkeLocation)
builder.WithClusterMinorVersion(1, 24)
builder.WithClusterMinorVersion(gkeVersionMajor, gkeVersionMinor)
builder.WithWaitForTeardown(false)
builder.WithCreateSubnet(createSubnet)
builder.WithLabels(map[string]string{"test-cluster": "true"})
Expand Down Expand Up @@ -118,8 +123,8 @@ func testGKECluster(t *testing.T, createSubnet bool) {
t.Log("validating kubernetes cluster version")
kubernetesVersion, err := env.Cluster().Version()
require.NoError(t, err)
require.Equal(t, uint64(1), kubernetesVersion.Major)
require.Equal(t, uint64(24), kubernetesVersion.Minor)
require.Equal(t, uint64(gkeVersionMajor), kubernetesVersion.Major)
require.Equal(t, uint64(gkeVersionMinor), kubernetesVersion.Minor)

t.Log("verifying that the kong addon deployed both proxy and controller")
kongAddon, err := env.Cluster().GetAddon("kong")
Expand Down
Loading