Skip to content

Commit

Permalink
Merge branch 'main' into KU-2111/add-ingress-feature-configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
addyess committed Nov 22, 2024
2 parents 7233a6d + 109adea commit 7e443ad
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
48 changes: 48 additions & 0 deletions charms/worker/k8s/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,54 @@ config:
default: false
description: |
Enable/Disable the gateway feature on the cluster.
load-balancer-enabled:
type: boolean
default: false
description: |
Enable/Disable the load balancer feature on the cluster.
load-balancer-cidrs:
type: string
default: ""
description: |
Space-separated list of CIDRs to use for the load balancer. This is
only used if load-balancer-enabled is set to true.
load-balancer-l2-mode:
type: boolean
default: false
description: |
Enable/Disable L2 mode for the load balancer. This is only used if
load-balancer-enabled is set to true.
load-balancer-l2-interfaces:
type: string
default: ""
description: |
Space-separated list of interfaces to use for the load balancer. This
is only used if load-balancer-l2-mode is set to true. if unset, all
interfaces will be used.
load-balancer-bgp-mode:
type: boolean
default: false
description: |
Enable/Disable BGP mode for the load balancer. This is only used if
load-balancer-enabled is set to true.
load-balancer-bgp-local-asn:
type: int
default: 64512
description: |
Local ASN for the load balancer. This is only used if load-balancer-bgp-mode
is set to true.
load-balancer-bgp-peer-address:
type: string
default: ""
description: |
Address of the BGP peer for the load balancer. This is only used if
load-balancer-bgp-mode is set to true.
load-balancer-bgp-peer-port:
type: int
default: 179
description: |
Port of the BGP peer for the load balancer. This is only used if
load-balancer-bgp-mode is set to true.
local-storage-enabled:
type: boolean
default: true
Expand Down
8 changes: 4 additions & 4 deletions charms/worker/k8s/lib/charms/k8s/v0/k8sd_api_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ class LoadBalancerConfig(BaseModel, allow_population_by_field_name=True):
Attributes:
enabled: Optional flag which represents the status of LoadBalancer.
cidrs: List of CIDR blocks for the load balancer.
l2_enabled: Optional flag to enable or disable layer 2 functionality.
l2_mode: Optional flag to enable or disable layer 2 mode.
l2_interfaces: List of layer 2 interfaces for the load balancer.
bgp_enabled: Optional flag to enable or disable BGP.
bgp_mode: Optional flag to enable or disable BGP.
bgp_local_asn: The local ASN for BGP configuration.
bgp_peer_address: The peer address for BGP configuration.
bgp_peer_asn: The peer ASN for BGP configuration.
Expand All @@ -241,9 +241,9 @@ class LoadBalancerConfig(BaseModel, allow_population_by_field_name=True):

enabled: Optional[bool] = Field(default=None)
cidrs: Optional[List[str]] = Field(default=None)
l2_enabled: Optional[bool] = Field(default=None, alias="l2-enabled")
l2_mode: Optional[bool] = Field(default=None, alias="l2-mode")
l2_interfaces: Optional[List[str]] = Field(default=None, alias="l2-interfaces")
bgp_enabled: Optional[bool] = Field(default=None, alias="bgp-enabled")
bgp_mode: Optional[bool] = Field(default=None, alias="bgp-mode")
bgp_local_asn: Optional[int] = Field(default=None, alias="bgp-local-asn")
bgp_peer_address: Optional[str] = Field(default=None, alias="bgp-peer-address")
bgp_peer_asn: Optional[int] = Field(default=None, alias="bgp-peer-asn")
Expand Down
14 changes: 14 additions & 0 deletions charms/worker/k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
JoinClusterRequest,
K8sdAPIManager,
K8sdConnectionError,
LoadBalancerConfig,
LocalStorageConfig,
NetworkConfig,
UnixSocketConnectionFactory,
Expand Down Expand Up @@ -433,6 +434,18 @@ def _assemble_cluster_config(self) -> UserFacingClusterConfig:
enable_proxy_protocol=self.config.get("ingress-enable-proxy-protocol"),
)

load_balancer = LoadBalancerConfig(
enabled=self.config.get("load-balancer-enabled"),
cidrs=str(self.config.get("load-balancer-cidrs")).split(),
l2_mode=self.config.get("load-balancer-l2-mode"),
l2_interfaces=str(self.config.get("load-balancer-l2-interfaces")).split(),
bgp_mode=self.config.get("load-balancer-bgp-mode"),
bgp_local_asn=self.config.get("load-balancer-bgp-local-asn"),
bgp_peer_address=self.config.get("load-balancer-bgp-peer-address"),
bgp_peer_asn=self.config.get("load-balancer-bgp-peer-asn"),
bgp_peer_port=self.config.get("load-balancer-bgp-peer-port"),
)

cloud_provider = None
if self.xcp.has_xcp:
cloud_provider = "external"
Expand All @@ -444,6 +457,7 @@ def _assemble_cluster_config(self) -> UserFacingClusterConfig:
ingress=ingress,
annotations=self._get_valid_annotations(),
cloud_provider=cloud_provider,
load_balancer=load_balancer,
)

def _configure_datastore(self, config: Union[BootstrapConfig, UpdateClusterConfigRequest]):
Expand Down

0 comments on commit 7e443ad

Please sign in to comment.