Skip to content

Commit

Permalink
Bootstrap with bootstrapConfig -- including registerWithTaints and se…
Browse files Browse the repository at this point in the history
…rvice-cidr
  • Loading branch information
addyess committed Apr 15, 2024
1 parent 4654ed2 commit 4ed0c68
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
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 @@ -295,6 +295,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 @@ -309,6 +310,7 @@ class BootstrapConfig(BaseModel):
"""

cluster_config: UserFacingClusterConfig = Field(None, alias="cluster-config")
control_plane_taints: List[str] = Field(None, alias="control-plane-taints")
pod_cidr: str = Field(None, alias="pod-cidr")
service_cidr: str = Field(None, alias="service-cidr")
disable_rbac: 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 @@ -221,6 +221,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()

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

0 comments on commit 4ed0c68

Please sign in to comment.