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

Add Support for FlatcarContainerLinux #221

Merged
merged 5 commits into from
Oct 18, 2021
Merged

Add Support for FlatcarContainerLinux #221

merged 5 commits into from
Oct 18, 2021

Conversation

bephinix
Copy link
Contributor

Fixes #189.

@bephinix
Copy link
Contributor Author

@kke I am currently working on providing support for FCL using #183 as a reference. Although everything is built correctly, setting os: flatcarcontainerlinux still results in unsupported os.

@kke
Copy link
Contributor

kke commented Sep 27, 2021

@kke I am currently working on providing support for FCL using #183 as a reference. Although everything is built correctly, setting os: flatcarcontainerlinux still results in unsupported os.

You need to at least implement InstallPackage, I think that is the bare minimum for distro support.

func (l FlatcarContainerLinux) InstallPackage(h os.Host, pkg ...string) error {
	return h.Execf("SOME_COMMAND_TO_INSTALL_PACKAGES_HERE %s", strings.Join(pkg, " "), exec.Sudo(h))
}

@bephinix
Copy link
Contributor Author

@kke Ok, OS detection works and Flatcar is now a valid OS for k0sctl but the new path is still not used although the correct method is reimplemented.

@kke
Copy link
Contributor

kke commented Sep 28, 2021

Hmm. I'm not entirely sure why the BaseLinux type exists. This composing / type embedding stuff in Go is tricky stuff.

I think it should cause a compilation error if there are ambiguous functions 🤔 It may be required that the K0sBinaryPath() is removed from configurer/linux.go, maybe creating something like:

package linux

type writableUSR struct {}

func (w writableUSR) K0sBinaryPath() string {
  return "/usr/local/bin/k0s"
}

and then embedding that to all the other linuxes:

type Debian struct {
	linux.Ubuntu
	configurer.Linux
       writableUSR
}

Using a dedicated interface enables distro-specific structs to 'override'
functions returning string constants such as config folders or paths.
@bephinix
Copy link
Contributor Author

@kke I solved the problem by using a dedicated interface for functions returning a static string such as the K0S Binary Path. The MR now consists of three logical commits:

  1. Introduction of dedicated interface to support overridding static string functions.
  2. Fix for download method to create destination directory if it does not exists.
  3. Add support for Flatcar Container Linux.

It works now as intended. 🎉
Pleases let me know if I am missing something. 😉

@kke
Copy link
Contributor

kke commented Sep 28, 2021

Shaping up nicely, some wizardry going on, need to tinker it with a bit myself before yanking the lever :)

@kke kke added the enhancement New feature or request label Sep 28, 2021
@bephinix
Copy link
Contributor Author

I have just changed the default path for flatcar to /opt/bin/k0s as /opt/bin seems to be the default workarround for flatcar systems. Nevertheless, the path creation seems to be a good idea.

@bephinix
Copy link
Contributor Author

@kke Did you already found time to check the changes? It would be great to use the official k0sctl binaries for my deployments.
So if you need further information or assistance, please let me know. 👍🏻

@kke
Copy link
Contributor

kke commented Oct 12, 2021

Sorry, not yet, trying to look into it asap.

configurer/linux.go Outdated Show resolved Hide resolved
@kke
Copy link
Contributor

kke commented Oct 18, 2021

It's a pretty clever way to override the functions 🤔

configurer/linux.go Outdated Show resolved Hide resolved
@bephinix
Copy link
Contributor Author

@kke Okay, let me update the PR to include bespoked ideas. :)

@bephinix
Copy link
Contributor Author

@kke Updated. 🚀

@kke kke merged commit 0106928 into k0sproject:main Oct 18, 2021
@bephinix bephinix mentioned this pull request May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Flatcar Container Linux
2 participants