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

Configuration for service-cidr and control-plane-taints #43

Merged
merged 5 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 21 additions & 1 deletion charms/worker/k8s/charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,27 @@ config:
type: string
description: |
Labels can be used to organize and to select subsets of nodes in the
cluster. Declare node labels in key=value format, separated by spaces.
cluster. Declare node labels in key=value format, separated by spaces.
register-with-taints:
type: string
default: ""
description: |
Space-separated list of taints to apply to this node at registration time.

This config is only used at deploy time when Kubelet first registers the
node with Kubernetes. To change node taints after deploy time, use kubectl
instead.

For more information, see the upstream Kubernetes documentation about
taints:
https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
service-cidr:
type: string
default: 10.152.183.0/24
description: |
CIDR to use for Kubernetes services. After deployment it is
only possible to increase the size of the IP range. It is not possible to
change or shrink the address range after deployment.

actions:
get-kubeconfig:
Expand Down
2 changes: 2 additions & 0 deletions charms/worker/k8s/lib/charms/k8s/v0/k8sd_api_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ class BootstrapConfig(BaseModel):

Attributes:
cluster_config (UserFacingClusterConfig): The cluster configuration settings.
control_plane_taints (List[str]): Register with the following control-plane taints
pod_cidr (str): The IP address range for the cluster's pods.
service_cidr (str): The IP address range for the cluster services.
disable_rbac (bool): Flag to disable role-based access control
Expand All @@ -312,6 +313,7 @@ class BootstrapConfig(BaseModel):
"""

cluster_config: Optional[UserFacingClusterConfig] = Field(None, alias="cluster-config")
control_plane_taints: Optional[List[str]] = Field(None, alias="control-plane-taints")
pod_cidr: Optional[str] = Field(None, alias="pod-cidr")
service_cidr: Optional[str] = Field(None, alias="service-cidr")
disable_rbac: Optional[bool] = Field(None, alias="disable-rbac")
Expand Down
2 changes: 2 additions & 0 deletions charms/worker/k8s/src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ def _bootstrap_k8s_snap(self):

bootstrap_config = BootstrapConfig()
self._configure_datastore(bootstrap_config)
bootstrap_config.service_cidr = self.config["service-cidr"]
bootstrap_config.control_plane_taints = self.config["register-with-taints"].split()
bootstrap_config.extra_sans = [_get_public_address()]

status.add(ops.MaintenanceStatus("Bootstrapping Cluster"))
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/data/test-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: integration-test
description: |-
Used to deploy or refresh within an integration test model
series: jammy
series: focal
applications:
k8s:
charm: k8s
Expand Down
Loading