Skip to content

Commit

Permalink
feat(kong): allow customizing chart version and proxy readiness probe
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Aug 10, 2023
1 parent d6d384b commit 5d718b1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.36.0

- Allow customizing Helm chart version and proxy readiness probe used
in Kong addon.
[#774](https://github.com/Kong/kubernetes-testing-framework/pull/774)

## v0.35.0

- Support specifying namespace of Kong addon to deploy Kong in certain
Expand Down
17 changes: 14 additions & 3 deletions pkg/clusters/addons/kong/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ type Addon struct {
logger *logrus.Logger

// kubernetes and helm chart related configuration options
namespace string
name string
deployArgs []string
namespace string
name string
deployArgs []string
chartVersion string

// ingress controller configuration options
ingressControllerDisabled bool
Expand All @@ -92,6 +93,7 @@ type Addon struct {
proxyLogLevel string
proxyServiceType corev1.ServiceType
proxyEnvVars map[string]string
proxyReadinessProbePath string

// proxy server enterprise mode configuration options
proxyEnterpriseEnabled bool
Expand Down Expand Up @@ -215,6 +217,10 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
return err
}

if a.chartVersion != "" {
a.deployArgs = append(a.deployArgs, "--version", a.chartVersion)
}

if a.proxyPullSecret != (pullSecret{}) {
// create the pull Secret
opts := create.CreateSecretDockerRegistryOptions{
Expand Down Expand Up @@ -300,6 +306,11 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
a.deployArgs = append(a.deployArgs, "--set", fmt.Sprintf("env.log_level=%s", a.proxyLogLevel))
}

// Set the proxy readiness probe path.
if len(a.proxyReadinessProbePath) > 0 {
a.deployArgs = append(a.deployArgs, "--set", fmt.Sprintf("readinessProbe.httpGet.path=%s", a.proxyReadinessProbePath))
}

// Deploy licenses and other configurations for enterprise mode.
if a.proxyEnterpriseEnabled {
// Set the enterprise defaults helm installation values.
Expand Down
28 changes: 22 additions & 6 deletions pkg/clusters/addons/kong/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ type Builder struct {
logger *logrus.Logger

// kubernetes and helm chart related configuration options
namespace string
name string
deployArgs []string
namespace string
name string
deployArgs []string
chartVersion string

// ingress controller configuration options
ingressControllerDisabled bool
Expand All @@ -34,6 +35,7 @@ type Builder struct {
proxyLogLevel string
proxyServiceType corev1.ServiceType
proxyEnvVars map[string]string
proxyReadinessProbePath string

// proxy server enterprise mode configuration options
proxyEnterpriseEnabled bool
Expand Down Expand Up @@ -76,9 +78,10 @@ func (b *Builder) Build() *Addon {
return &Addon{
logger: b.logger,

namespace: b.namespace,
name: b.name,
deployArgs: b.deployArgs,
namespace: b.namespace,
name: b.name,
deployArgs: b.deployArgs,
chartVersion: b.chartVersion,

ingressControllerDisabled: b.ingressControllerDisabled,
ingressControllerImage: b.ingressControllerImage,
Expand All @@ -92,6 +95,7 @@ func (b *Builder) Build() *Addon {
proxyLogLevel: b.proxyLogLevel,
proxyServiceType: b.proxyServiceType,
proxyEnvVars: b.proxyEnvVars,
proxyReadinessProbePath: b.proxyReadinessProbePath,

proxyEnterpriseEnabled: b.proxyEnterpriseEnabled,
proxyEnterpriseLicenseJSON: b.proxyEnterpriseLicenseJSON,
Expand Down Expand Up @@ -206,3 +210,15 @@ func (b *Builder) WithProxyEnterpriseSuperAdminPassword(password string) *Builde
b.proxyEnterpriseSuperAdminPassword = password
return b
}

// WithHelmChartVersion sets the helm chart version to use for the Kong proxy.
func (b *Builder) WithHelmChartVersion(version string) *Builder {
b.deployArgs = append(b.deployArgs, "--version", version)
return b
}

// WithProxyReadinessProbePath sets the path to use for the proxy readiness probe.
func (b *Builder) WithProxyReadinessProbePath(path string) *Builder {
b.proxyReadinessProbePath = path
return b
}

0 comments on commit 5d718b1

Please sign in to comment.