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

Add Ingress feature configuration #176

Merged
merged 4 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 10 additions & 0 deletions charms/worker/k8s/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ config:
default: true
description: |
Enables or disables the network feature.
ingress-enabled:
type: boolean
default: false
description: |
Determines if the ingress feature should be enabled.
ingress-enable-proxy-protocol:
type: boolean
default: false
description: |
Determines if the proxy protocol should be enabled for ingresses.
node-labels:
default: ""
type: string
Expand Down
7 changes: 7 additions & 0 deletions charms/worker/k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
CreateClusterRequest,
DNSConfig,
GatewayConfig,
IngressConfig,
InvalidResponseError,
JoinClusterRequest,
K8sdAPIManager,
Expand Down Expand Up @@ -427,6 +428,11 @@ def _assemble_cluster_config(self) -> UserFacingClusterConfig:
enabled=self.config.get("network-enabled"),
)

ingress = IngressConfig(
enabled=self.config.get("ingress-enabled"),
enable_proxy_protocol=self.config.get("ingress-enable-proxy-protocol"),
)

cloud_provider = None
if self.xcp.has_xcp:
cloud_provider = "external"
Expand All @@ -435,6 +441,7 @@ def _assemble_cluster_config(self) -> UserFacingClusterConfig:
local_storage=local_storage,
gateway=gateway,
network=network,
ingress=ingress,
annotations=self._get_valid_annotations(),
cloud_provider=cloud_provider,
)
Expand Down
22 changes: 22 additions & 0 deletions charms/worker/k8s/tests/unit/test_config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,25 @@ def test_configure_network_options(harness):
harness.update_config({"network-enabled": True})
ufcg = harness.charm._assemble_cluster_config()
assert ufcg.network.enabled, "Network should be enabled"


def test_configure_ingress_options(harness):
"""Test configuring the ingress options.

Args:
harness: the harness under test
"""
if harness.charm.is_worker:
pytest.skip("Not applicable on workers")

harness.disable_hooks()

enabled = True
proxy_protocol_enabled = True

harness.update_config({"ingress-enabled": enabled})
harness.update_config({"ingress-enable-proxy-protocol": proxy_protocol_enabled})

ufcg = harness.charm._assemble_cluster_config()
assert ufcg.ingress.enabled == enabled
assert ufcg.ingress.enable_proxy_protocol == proxy_protocol_enabled
Loading