Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Ignition driver #21

Closed
wants to merge 3 commits into from
Closed
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
3 changes: 2 additions & 1 deletion devstack/contrib/new-devstack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ sudo install -o root -g root -m 0755 clusterctl /usr/local/bin/clusterctl
# Install Cluster API resources
# using the matching tested values here:
# https://github.com/stackhpc/capi-helm-charts/blob/main/dependencies.json
export EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION=true
clusterctl init \
--core cluster-api:v1.5.1 \
--bootstrap kubeadm:v1.5.1 \
--control-plane kubeadm:v1.5.1 \
--infrastructure openstack:v0.7.3
--infrastructure openstack:v0.8.0

# Install addon manager
helm upgrade cluster-api-addon-provider cluster-api-addon-provider \
Expand Down
2 changes: 1 addition & 1 deletion magnum_capi_helm/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
),
cfg.StrOpt(
"default_helm_chart_version",
default="0.1.2-dev.0.main.55",
default="0.1.5-dev.0.main.2",
help=(
"Version of the helm chart specified "
"by the config: capi_driver.helm_chart_repo "
Expand Down
105 changes: 105 additions & 0 deletions magnum_capi_helm/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,3 +769,108 @@ def update_federation(self, context, federation):

def delete_federation(self, context, federation):
raise NotImplementedError("Will not implement 'delete_federation'")


class IgnitionDriver(Driver):
@property
def provides(self):
return [
{
"server_type": "vm",
"os": "capi-kubeadm-ignition",
"coe": "kubernetes",
},
]

def _update_helm_release(self, context, cluster, nodegroups=None):
# TODO(stefan-chivu) reorganize class structure to keep the code dry
if nodegroups is None:
nodegroups = cluster.nodegroups

image_id, kube_version = self._get_image_details(
context, cluster.cluster_template.image_id
)

network_id = self._get_fixed_network_id(context, cluster)
subnet_id = neutron.get_fixed_subnet_id(context, cluster.fixed_subnet)

values = {
"kubernetesVersion": kube_version,
"machineImageId": image_id,
"machineSSHKeyName": cluster.keypair or None,
"osDistro": "flatcar",
"cloudCredentialsSecretName": self._get_app_cred_name(cluster),
"apiServer": {
"enableLoadBalancer": True,
"loadBalancerProvider": self._label(
cluster, "octavia_provider", "amphora"
),
},
"clusterNetworking": {
"dnsNameservers": self._get_dns_nameservers(cluster),
"externalNetworkId": neutron.get_external_network_id(
context, cluster.cluster_template.external_network_id
),
"internalNetwork": {
"networkFilter": (
{"id": network_id} if network_id else None
),
"subnetFilter": ({"id": subnet_id} if subnet_id else None),
# This is only used if a fixed network is not specified
"nodeCidr": self._label(
cluster, "fixed_subnet_cidr", "10.0.0.0/24"
),
},
},
"controlPlane": {
"machineFlavor": cluster.master_flavor_id,
"machineCount": cluster.master_count,
},
"nodeGroups": [
{
"name": self._sanitized_name(ng.name),
"machineFlavor": ng.flavor_id,
"machineCount": ng.node_count,
}
for ng in nodegroups
if ng.role != NODE_GROUP_ROLE_CONTROLLER
],
"addons": {
"monitoring": {
"enabled": self._get_monitoring_enabled(cluster)
},
"kubernetesDashboard": {
"enabled": self._get_kube_dash_enabled(cluster)
},
# TODO(mkjpryor): can't enable ingress until code exists to
# remove the load balancer
"ingress": {"enabled": False},
},
}

# Sometimes you need to add an extra network
# for things like Cinder CSI CephFS Native
extra_network_name = self._label(cluster, "extra_network_name", "")
if extra_network_name:
values["nodeGroupDefaults"] = {
"machineNetworking": {
"ports": [
{},
{
"network": {
"name": extra_network_name,
},
"securityGroups": [],
},
]
}
}

self._helm_client.install_or_upgrade(
self._get_chart_release_name(cluster),
CONF.capi_helm.helm_chart_name,
values,
repo=CONF.capi_helm.helm_chart_repo,
version=self._get_chart_version(cluster),
namespace=self._namespace(cluster),
)
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ packages =
[entry_points]
magnum.drivers =
k8s_capi_helm_v1 = magnum_capi_helm.driver:Driver
k8s_capi_ignition_helm_v1 = magnum_capi_helm.driver:IgnitionDriver