在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):rancher/k3os开源软件地址(OpenSource Url):https://github.com/rancher/k3os开源编程语言(OpenSource Language):Go 59.7%开源软件介绍(OpenSource Introduction):k3OSk3OS is a Linux distribution designed to remove as much OS maintenance
as possible in a Kubernetes cluster. It is specifically designed to only
have what is needed to run k3s. Additionally
the OS is designed to be managed by Quick StartDownload the ISO from the latest release and run it
in VMware, VirtualBox, KVM, or bhyve. The server will automatically start a single node Kubernetes cluster.
Log in with the user To copy k3OS to local disk, after logging in as Live install (boot from ISO) requires at least 2GB of RAM. Local install requires 1GB RAM. DesignCore design goals of k3OS are
File System StructureCritical to the design of k3OS is how that file system is structured. A booted system will look as follows
/etcAll configuration in the system is intended to be ephemeral. If you change anything in /usrThe entire user space is stored in /k3osThe k3OS directory contains the core operating system files references on boot to construct the file system. It contains squashfs images and binaries for k3OS, k3s, and the Linux kernel. On boot the appropriate version for all three will be chosen and configured. /var, /usr/local, /home, /optPersistent changes should be kept in Upstream DistrosMost of the user-space binaries comes from Alpine and are repackaged for k3OS. Currently the kernel source is coming from Ubuntu 20.04 LTS. Some code and a lot of inspiration came from LinuxKit InstallationInteractive InstallationInteractive installation is done from booting from the ISO. The installation is done by running
The installation will format an entire disk. If you have a single hard disk attached to the system it will not ask which disk but just pick the first and only one. Automated InstallationInstallation can be automated by using kernel cmdline parameters. There are a lot of creative solutions to booting a machine with cmdline args. You can remaster the k3OS ISO, PXE boot, use qemu/kvm, or automate input with packer. The kernel and initrd are available in the k3OS release artifacts, along with the ISO. The cmdline value
Custom partition layoutBy default k3OS expects one partition to exist labeled Bootstrapped InstallationYou can install k3OS to a block device from any modern Linux distribution. Just download and run install.sh. This script will run the same installation as the ISO but is a bit more raw and will not prompt for configuration.
Remastering ISOTo remaster the ISO all you need to do is copy # Ubuntu: apt install grub-efi grub-pc-bin mtools xorriso
# CentOS: dnf install grub2-efi grub2-pc mtools xorriso
# Alpine: apk add grub-bios grub-efi mtools xorriso
mount -o loop k3os.iso /mnt
mkdir -p iso/boot/grub
cp -rf /mnt/k3os iso/
cp /mnt/boot/grub/grub.cfg iso/boot/grub/
# Edit iso/boot/grub/grub.cfg
grub-mkrescue -o k3os-new.iso iso/ -- -volid K3OS GRUB2 CAVEAT: Some non-Alpine installations of grub2 will create Takeover InstallationA special mode of installation is designed to install to a current running Linux system. This only works on ARM64 and x86_64. Download install.sh
and run with the In order for this to work a couple of assumptions are made. First the root (/) is assumed to be an ext4 partition. Also it is assumed that grub2 is installed and looking for the configuration at ./install.sh --takeover --debug --tty ttyS0 --config /tmp/config.yaml --no-format /dev/vda1 https://github.com/rancher/k3os/releases/download/v0.10.0/k3os.iso ARM Overlay InstallationIf you have a custom ARMv7 or ARM64 device you can easily use an existing bootable ARM image to create a k3OS setup.
All you must do is boot the ARM system and then extract curl -sfL https://github.com/rancher/k3os/releases/download/v0.10.0/k3os-rootfs-arm.tar.gz | tar zxvf - --strip-components=1 -C /
cp myconfig.yaml /k3os/system/config.yaml
sync
reboot -f This method places k3OS on disk and also overwrites ConfigurationAll configuration is done through a single cloud-init style config file that is either packaged in the image, downloaded though cloud-init or managed by Kubernetes. The configuration file is found at
The The
Sample |
Key | initrd | boot | runtime |
---|---|---|---|
ssh_authorized_keys | x | x | |
write_files | x | x | x |
hostname | x | x | x |
run_cmd | x | ||
boot_cmd | x | ||
init_cmd | x | ||
k3os.data_sources | x | ||
k3os.modules | x | x | x |
k3os.sysctls | x | x | x |
k3os.ntp_servers | x | x | |
k3os.dns_nameservers | x | x | |
k3os.wifi | x | x | |
k3os.password | x | x | x |
k3os.server_url | x | x | |
k3os.token | x | x | |
k3os.labels | x | x | |
k3os.k3s_args | x | x | |
k3os.environment | x | x | x |
k3os.taints | x | x |
Networking is powered by connman
. To configure networking a couple of helper keys are
available: k3os.dns_nameserver
, k3os.ntp_servers
, k3os.wifi
. Refer to the
reference for a full explanation of those keys. If you wish
to configure a HTTP proxy set the http_proxy
, and https_proxy
fields in k3os.environment
.
All other networking configuration should be done by configuring connman directly by using the
write_files
key to create connman service
files.
Upgrading and reconfiguring k3OS is all handled through the Kubernetes operator. The operator is still in development. More details to follow. The basic design is that one can set the desired k3s and k3OS versions, plus their configuration and the operator will roll that out to the cluster.
Integration with rancher/system-upgrade-controller has been implemented as of v0.9.0.
To enable a k3OS node to automatically upgrade from the latest GitHub release you will need to make sure it has the label
k3os.io/upgrade
with value latest
(for k3OS versions prior to v0.11.x please use label plan.upgrade.cattle.io/k3os-latest
). The upgrade controller will then spawn an upgrade job
that will drain most pods, upgrade the k3OS content under /k3os/system
, and then reboot. The system should come back up running the latest
kernel and k3s version bundled with k3OS and ready to schedule pods.
If your k3OS installation is running a version prior to the v0.9.0 release or one of its release candidates you can setup the system upgrade controller to upgrade your k3OS by following these steps:
# apply the system-upgrade-controller manifest (once per cluster)
kubectl apply -f https://raw.githubusercontent.com/rancher/k3os/v0.10.0/overlay/share/rancher/k3s/server/manifests/system-upgrade-controller.yaml
# after the system-upgrade-controller pod is Ready, apply the plan manifest (once per cluster)
kubectl apply -f https://raw.githubusercontent.com/rancher/k3os/v0.10.0/overlay/share/rancher/k3s/server/manifests/system-upgrade-plans/k3os-latest.yaml
# apply the `plan.upgrade.cattle.io/k3os-latest` label as described above (for every k3OS node), e.g.
kubectl label nodes -l k3os.io/mode plan.upgrade.cattle.io/k3os-latest=enabled # this should work on any cluster with k3OS installations at v0.7.0 or greater
For single-node or development use cases, where the operator is not being used, you can upgrade the rootfs and kernel with the following commands. If you do not specify K3OS_VERSION, it will default to the latest release.
When using an overlay install such as on Raspberry Pi (see ARM Overlay Installation) the original distro kernel (such as Raspbian) will continue to be used. On these systems the k3os-upgrade-kernel script will exit with a warning and perform no action.
export K3OS_VERSION=v0.10.0
/usr/share/rancher/k3os/scripts/k3os-upgrade-rootfs
/usr/share/rancher/k3os/scripts/k3os-upgrade-kernel
You should always remember to backup your data first, and reboot after upgrading.
These scripts have been deprecated as of v0.9.0 are still on the system at /usr/share/rancher/k3os/scripts
.
To build k3OS you just need Docker and then run make
. All artifacts will be put in ./dist/artifacts
.
If you are running on Linux you can run ./scripts/run
to run a VM of k3OS in the terminal. To exit
the instance type CTRL+a c
to get the qemu console and then q
for quit.
The source for the kernel is in https://github.com/rancher/k3os-kernel
and similarly you
just need to have Docker and run make
to compile the kernel.
Below is a reference of all keys available in the config.yaml
ssh_authorized_keys
A list of SSH authorized keys that should be added to the rancher
user. k3OS primarily
has one user, rancher
. The root
account is always disabled, has no password, and is never
assigned a ssh key. SSH keys can be obtained from GitHub user accounts by using the format
github:${USERNAME}
. This is done by downloading the keys from https://github.com/${USERNAME}.keys
.
Example
ssh_authorized_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2TBZGjE+J8ag11dzkFT58J3XPONrDVmalCNrKxsfADfyy0eqdZrG8hcAxAR/5zuj90Gin2uBR4Sw6Cn4VHsPZcFpXyQCjK1QDADj+WcuhpXOIOY3AB0LZBly9NI0ll+8lo3QtEaoyRLtrMBhQ6Mooy2M3MTG4JNwU9o3yInuqZWf9PvtW6KxMl+ygg1xZkljhemGZ9k0wSrjqif+8usNbzVlCOVQmZwZA+BZxbdcLNwkg7zWJSXzDIXyqM6iWPGXQDEbWLq3+HR1qKucTCSxjbqoe0FD5xcW7NHIME5XKX84yH92n6yn+rxSsyUfhJWYqJd+i0fKf5UbN6qLrtd/D"
- "github:ibuildthecloud"
write_files
A list of files to write to disk on boot. These files can be either plain text, gziped, base64 encoded, or base64+gzip encoded.
Example
write_files:
- encoding: b64
content: CiMgVGhpcyBmaWxlIGNvbnRyb2xzIHRoZSBzdGF0ZSBvZiBTRUxpbnV4...
owner: root:root
path: /etc/connman/main.conf
permissions: '0644'
- content: |
# My new /etc/sysconfig/samba file
SMDBOPTIONS="-D"
path: /etc/sysconfig/samba
- content: !!binary |
f0VMRgIBAQAAAAAAAAAAAAIAPgABAAAAwARAAAAAAABAAAAAAAAAAJAVAAAAAA
AEAAHgAdAAYAAAAFAAAAQAAAAAAAAABAAEAAAAAAAEAAQAAAAAAAwAEAAAAAAA
AAAAAAAAAwAAAAQAAAAAAgAAAAAAAAACQAAAAAAAAAJAAAAAAAAcAAAAAAAAAB
...
path: /bin/arch
permissions: '0555'
- content: |
15 * * * * root ship_logs
path: /etc/crontab
hostname
Set the system hostname. This value will be overwritten by DHCP if DHCP supplies a hostname for the system.
Example
hostname: myhostname
init_cmd
, boot_cmd
, run_cmd
All three keys are used to run arbitrary commands on startup in the respective phases of initrd
,
boot
and runtime
. Commands are ran after write_files
so it is possible to write a script to
disk and run it from these commands. That often makes it easier to do longer form setup.
k3os.data_sources
These are the data sources used for download config from cloud provider. The valid options are:
aws
cdrom
digitalocean
gcp
hetzner
openstack
packet
scaleway
vultr
More than one can be supported at a time, for example:
k3os:
data_sources:
- openstack
- cdrom
When multiple data sources are specified they are probed in order and the first to provide /run/config/userdata
will halt further processing.
k3os.modules
A list of kernel modules to be loaded on start.
Example
k3os:
modules:
- kvm
- nvme
k3os.sysctls
Kernel sysctl to setup on start. These are the same configuration you'd typically find in /etc/sysctl.conf
.
Must be specified as string values.
k3os:
sysctl:
kernel.printk: 4 4 1 7 # the YAML parser will read as a string
kernel.kptr_restrict: "1" # force the YAML parser to read as a string
k3os.ntp_servers
Fallback ntp servers to use if NTP is not configured elsewhere in connman.
Example
k3os:
ntp_servers:
- 0.us.pool.ntp.org
- 1.us.pool.ntp.org
k3os.dns_nameservers
Fallback DNS name servers to use if DNS is not configured by DHCP or in a connman service config.
Example
k3os:
dns_nameservers:
- 8.8.8.8
- 1.1.1.1
k3os.wifi
Simple
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论