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

feat: Support Flatcar OS and custom NTP servers #44

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
befc19b
fix: use flatcar
okozachenko1203 Nov 17, 2022
fc3a172
Add preKubeadmCommands for node name replacement
okozachenko1203 Nov 17, 2022
dbc43b2
Fix mdlint
okozachenko1203 Nov 17, 2022
fafcaac
Build flatcar image
okozachenko1203 Nov 18, 2022
51b67e2
Add flatcardriver
okozachenko1203 Nov 18, 2022
9a4f259
Add flatcarDriver in poetry plugin list
okozachenko1203 Nov 18, 2022
65bdd68
Fix prekubeadmcommands format
okozachenko1203 Nov 18, 2022
62bd1f0
Enable required feature gate and update ignition
okozachenko1203 Nov 18, 2022
f38ad5d
Support os switch
okozachenko1203 Nov 22, 2022
facabee
Fix lint
okozachenko1203 Nov 22, 2022
11fe3c1
Fix lint
okozachenko1203 Nov 22, 2022
e18d24a
Fix lint
okozachenko1203 Nov 22, 2022
e2b6dea
Fix fake8 lint
okozachenko1203 Nov 22, 2022
18acf68
Fix clusterclas patches
okozachenko1203 Nov 22, 2022
2408d37
Fix lint
okozachenko1203 Nov 22, 2022
a04544e
Remove default os in image build cmd
okozachenko1203 Nov 23, 2022
1aa707d
Update ignition
okozachenko1203 Nov 24, 2022
a1dc6b9
Fix ignition ignoring error
okozachenko1203 Nov 24, 2022
ded7eb4
Fix lint
okozachenko1203 Nov 24, 2022
7c46bb5
Add comment about PATH overwrite in flatcar
okozachenko1203 Nov 24, 2022
0429d08
Update TODO comment
okozachenko1203 Nov 24, 2022
e46788a
Land clct openstack provider override
okozachenko1203 Nov 25, 2022
9e58cb0
Remove comments
okozachenko1203 Nov 25, 2022
35fbe03
Support ntp servers
okozachenko1203 Nov 25, 2022
4e18f36
Fix syntax
okozachenko1203 Nov 25, 2022
5e0e344
Fix condition for ntpserver length
okozachenko1203 Nov 25, 2022
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
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

## [0.2.0](https://github.com/vexxhost/magnum-cluster-api/compare/v0.1.2...v0.2.0) (2022-11-16)


### Bug Fixes

* added flux + node labels ([5f04d4e](https://github.com/vexxhost/magnum-cluster-api/commit/5f04d4ed8b00ba0d45cc59edd678bdf72679b00b))


### Miscellaneous Chores

* release 0.2.0 ([9c8fe82](https://github.com/vexxhost/magnum-cluster-api/commit/9c8fe8252e61b43019a0c45d31284467ec99af15))
Expand Down
1 change: 1 addition & 0 deletions hack/stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ kubectl label node kind-control-plane openstack-control-plane=enabled

# Initialize the `clusterctl` CLI
export EXP_CLUSTER_RESOURCE_SET=true
export EXP_KUBEADM_BOOTSTRAP_FORMAT_IGNITION=true #Used by the kubeadm bootstrap provider
export CLUSTER_TOPOLOGY=true
clusterctl init \
--core cluster-api:v1.3.0-rc.0 \
Expand Down
7 changes: 4 additions & 3 deletions magnum_cluster_api/cmd/image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
@click.command()
@click.option(
"--operating-system",
show_default=True,
default="ubuntu-2004",
type=click.Choice(["ubuntu-2004"]),
type=click.Choice(["ubuntu-2004", "flatcar"]),
okozachenko1203 marked this conversation as resolved.
Show resolved Hide resolved
help="Operating system to build image for",
prompt="Operating system to build image for",
)
@click.option(
"--version",
Expand Down Expand Up @@ -96,6 +95,8 @@ def main(operating_system, version, image_builder_version):
"kubernetes_deb_version": f"{version.replace('v', '')}-00",
"kubernetes_semver": f"{version}",
"kubernetes_series": f"{kubernetes_series}",
# https://github.com/flatcar/Flatcar/issues/823
"ansible_user_vars": "oem_id=openstack",
Comment on lines +98 to +99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of hacks around this because we're using an ISO image, @okozachenko1203 is going to contribute to image-builder an openstack image so that it uses OpenStack to deploy and publish directly to Glance.

Once we have that in place, we should switch the image builder to use that instead. It'll drive down the dependencies and we can remove this after.

}
with tempfile.NamedTemporaryFile(suffix=".json") as fp:
fp.write(json.dumps(customization).encode("utf-8"))
Expand Down
8 changes: 8 additions & 0 deletions magnum_cluster_api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,11 @@ def provides(self):
return [
{"server_type": "vm", "os": "ubuntu-focal", "coe": "kubernetes"},
]


class FlatcarDriver(BaseDriver):
@property
def provides(self):
return [
{"server_type": "vm", "os": "flatcar", "coe": "kubernetes"},
]
268 changes: 266 additions & 2 deletions magnum_cluster_api/resources.py

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions magnum_cluster_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from magnum_cluster_api import clients, objects

AVAILABLE_OPERATING_SYSTEMS = ["ubuntu", "flatcar"]


def get_or_generate_cluster_api_cloud_config_secret_name(
api: pykube.HTTPClient, cluster: magnum_objects.Cluster
Expand Down Expand Up @@ -225,3 +227,16 @@ def delete_loadbalancers(ctx, cluster):
octavia.wait_for_lb_deleted(octavia_client, candidates)
except Exception as e:
raise exception.PreDeletionFailed(cluster_uuid=cluster.uuid, msg=str(e))


def get_operating_system(cluster: magnum_objects.Cluster):
cluster_distro = cluster.cluster_template.cluster_distro
for ops in AVAILABLE_OPERATING_SYSTEMS:
if cluster_distro.startswith(ops):
return ops
return None


def get_ntp_servers(cluster: magnum_objects.Cluster):
ntp_servers = get_cluster_label(cluster, "ntp_servers", "")
return list(filter(None, ntp_servers.split(",")))
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ magnum-cluster-api-image-loader = "magnum_cluster_api.cmd.image_loader:main"

[tool.poetry.plugins."magnum.drivers"]
"k8s_cluster_api_ubuntu_focal" = "magnum_cluster_api.driver:UbuntuFocalDriver"
"k8s_cluster_api_flatcar" = "magnum_cluster_api.driver:FlatcarDriver"