rancher / k3os

Purpose-built OS for Kubernetes, fully managed by Kubernetes.
https://k3os.io
Apache License 2.0
3.5k stars 402 forks source link

Missing Git dependency for Kustomize. How to install Git on K3OS? #539

Open tschuchortdev opened 4 years ago

tschuchortdev commented 4 years ago

K3OS is supposed to be a minimal OS with only the packages needed to run Kubernetes. Apparently, this is not true because Kustomize as part of kubectl is also part of Kubernetes which relies on Git to fetch base config files through go-getter, but Git is not included in the K3OS image. This means that kubectl will crash when trying to deploy Kustomize manifests with certain URI formats (for example github.com/fluxcd/flux//deploy?ref=v1.19.0).

What is the best way to install git without building K3OS from scratch? I'm using Packer to create my own images from the K3OS base image, but I can't use it to install Git because K3OS doesn't come with a package manager.

liyimeng commented 4 years ago

You are supposed to do things in this way. If you do need to run it inside the cluster, do it from inside a pod.

tschuchortdev commented 4 years ago

You mean I should run kubectl from inside a pod? That doesn't sound like a good idea. I need git as a dependency to kubectl itself and not to some third party application that you would usually run in a pod.

liyimeng commented 4 years ago

yes, if you do not have an additional machine, e.g a laptop, to run kubectl outside of the cluster. Please note that k3os is kind of immutable OS, it dose this by purpose to ensure system stability. If u wanna continue the traditional way of operations, install k3s into traditional os instead, e.g. alpine, ubuntu ... , but not taking k3os.

Kampe commented 4 years ago

So you've got a few options here,

One is to include the kustomize and git binaries as part of your generation of your ISO and do some kustomize dance as part of runtime init and stick the resulting manifests in /var/lib/rancher/k3s/server/manifests

Or two is do the kustomization of your git-required remote base manifests before you write out the ISO and include it in a directory in which is copied to the k3os host from /k3os/system and either copy them over at runtime, or run further kustomizations on them to stick the resulting output into /var/lib/rancher/k3s/server/manifests

Hope this helps