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
…#774)

Adds WithHelmChartVersion and WithProxyReadinessProbePath Kong addon builder methods. 
Modifies the WithControllerDisabled method to also alter the proxyReadinessProbePath to 
/status so that the installation succeeds if the controller is disabled (otherwise /status/ready 
default would be used which expects Gateway to have a non-empty config loaded/configured).
  • Loading branch information
czeslavo committed Aug 10, 2023
1 parent d6d384b commit 1b08206
Show file tree
Hide file tree
Showing 3 changed files with 48 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
18 changes: 15 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,11 @@ func (a *Addon) Deploy(ctx context.Context, cluster clusters.Cluster) error {
return err
}

// Pin the chart version if specified.
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 +307,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
33 changes: 27 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 @@ -121,6 +125,11 @@ func (b *Builder) WithProxyImagePullSecret(server, username, password, email str
// WithControllerDisabled configures the Addon in proxy only mode (bring your own control plane).
func (b *Builder) WithControllerDisabled() *Builder {
b.ingressControllerDisabled = true

// The default readiness probe path for the proxy is /status/ready which would make the proxy
// with no configuration never get ready if the controller is disabled.
b.proxyReadinessProbePath = "/status"

return b
}

Expand Down Expand Up @@ -206,3 +215,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.chartVersion = 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 1b08206

Please sign in to comment.