Skip to content

Commit

Permalink
Add Ingress feature configuration (#176)
Browse files Browse the repository at this point in the history
* Add Ingress feature config options
* Remove defaultTLS option
  • Loading branch information
HomayoonAlimohammadi authored Nov 22, 2024
1 parent 9909a91 commit 25370eb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions charms/worker/k8s/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,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 @@ -439,6 +440,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"),
)

metrics_server = MetricsServerConfig(enabled=self.config.get("metrics-server-enabled"))

load_balancer = LoadBalancerConfig(
Expand All @@ -462,6 +468,7 @@ def _assemble_cluster_config(self) -> UserFacingClusterConfig:
cloud_provider=cloud_provider,
dns_config=dns_config,
gateway=gateway,
ingress=ingress,
local_storage=local_storage,
load_balancer=load_balancer,
metrics_server=metrics_server,
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

0 comments on commit 25370eb

Please sign in to comment.