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: support arbitrary Kuma Helm values #958

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

## Unreleased

- Added support for arbitrary Helm chart values to the Kuma plugin.
[#958](https://github.com/Kong/kubernetes-testing-framework/pull/958)

## v0.45.0

- `Kuma` addon now properly uses the Helm chart version passed in its builder's
Expand Down
8 changes: 7 additions & 1 deletion pkg/clusters/addons/kuma/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ type Addon struct {

version *semver.Version

mtlsEnabled bool
mtlsEnabled bool
additionalValues map[string]string
}

// New produces a new clusters.Addon for Kuma with MTLS enabled
Expand Down Expand Up @@ -155,6 +156,11 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {

// compile the helm installation values
args = append(args, "--create-namespace", "--namespace", Namespace)

for name, value := range a.additionalValues {
args = append(args, "--set", fmt.Sprintf("%s=%s", name, value))
}

a.logger.Debugf("helm install arguments: %+v", args)

// Sometimes running helm install fails. Just in case this happens, retry.
Expand Down
15 changes: 12 additions & 3 deletions pkg/clusters/addons/kuma/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ type Builder struct {
version *semver.Version
logger *logrus.Logger

mtlsEnabled bool
mtlsEnabled bool
additionalValues map[string]string
}

// NewBuilder provides a new Builder object for configuring Kuma cluster addons.
func NewBuilder() *Builder {
return &Builder{
name: string(AddonName),
name: string(AddonName),
additionalValues: make(map[string]string),
}
}

Expand All @@ -48,6 +50,12 @@ func (b *Builder) WithMTLS() *Builder {
return b
}

// WithAdditionalValue sets a key and value to pass to Helm using --set.
func (b *Builder) WithAdditionalValue(name, value string) *Builder {
b.additionalValues[name] = value
return b
}

// Build generates a new kong cluster.Addon which can be loaded and deployed
// into a test Environment's cluster.Cluster.
func (b *Builder) Build() *Addon {
Expand All @@ -59,6 +67,7 @@ func (b *Builder) Build() *Addon {
version: b.version,
logger: b.logger,

mtlsEnabled: b.mtlsEnabled,
mtlsEnabled: b.mtlsEnabled,
additionalValues: b.additionalValues,
}
}
Loading