在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:k3os开源软件地址:https://gitee.com/rancher/k3os开源软件介绍:k3OSk3OS is a Linux distribution designed to remove as much OS maintenanceas possible in a Kubernetes cluster. It is specifically designed to onlyhave what is needed to run k3s. Additionallythe OS is designed to be managed by Quick StartDownload the ISO from the latest release and run itin 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 willlook as follows /etc - ephemeral/usr - read-only (except /usr/local is writable and persistent)/k3os - system files/home - persistent/var - persistent/opt - persistent/usr/local - persistent /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 thefile system. It contains squashfs images and binaries for k3OS, k3s, and the Linux kernel. Onboot 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 thekernel source is coming from Ubuntu 20.04 LTS. Some code and a lot of inspiration came fromLinuxKit 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 systemit 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 creativesolutions 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 releaseartifacts, 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. Usage: ./install.sh [--force-efi] [--debug] [--tty TTY] [--poweroff] [--takeover] [--no-format] [--config https://.../config.yaml] DEVICE ISO_URLExample: ./install.sh /dev/vda https://github.com/rancher/k3os/releases/download/v0.10.0/k3os.isoDEVICE must be the disk that will be partitioned (/dev/vda). If you are using --no-format it should be the device of the K3OS_STATE partition (/dev/vda2)The parameters names refer to the same names used in the cmdline, refer to README.md formore info. 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 xorrisomount -o loop k3os.iso /mntmkdir -p iso/boot/grubcp -rf /mnt/k3os iso/cp /mnt/boot/grub/grub.cfg iso/boot/grub/# Edit iso/boot/grub/grub.cfggrub-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.shand 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.yamlsyncreboot -f This method places k3OS on disk and also overwrites ConfigurationAll configuration is done through a single cloud-init style config file that iseither packaged in the image, downloaded though cloud-init or managed byKubernetes. The configuration file is found at /k3os/system/config.yaml/var/lib/rancher/k3os/config.yaml/var/lib/rancher/k3os/config.d/* 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 areavailable: k3os.dns_nameserver
, k3os.ntp_servers
, k3os.wifi
. Refer to thereference for a full explanation of those keys. If you wishto 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 thewrite_files
key to create connman servicefiles.
Upgrading and reconfiguring k3OS is all handled through the Kubernetes operator. The operatoris still in development. More details to follow. The basic design is that one can set thedesired k3s and k3OS versions, plus their configuration and the operator will roll that out tothe 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 labelk3os.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 jobthat will drain most pods, upgrade the k3OS content under /k3os/system
, and then reboot. The system should come back up running the latestkernel 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 setupthe 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 exitthe 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 youjust 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 primarilyhas one user, rancher
. The root
account is always disabled, has no password, and is neverassigned a ssh key. SSH keys can be obtained from GitHub user accounts by using the formatgithub:${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 forthe 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 todisk 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:
awscdromdigitaloceangcphetzneropenstackpacketscalewayvultr
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 wifi configuration. All that is accepted is name
and passphrase
. If you require morecomplex configuration then you should use write_files
to write a connman service config.
Example:
k3os: wifi: - name: home passphrase: mypassword - name: nothome passphrase: somethingelse
k3os.password
The password for the rancher
user. By default there is no password for the rancher
user.If you set a password at runtime it will be reset on next boot because /etc
is ephemeral. Thevalue of the password can be clear text or an encrypted form. The easiest way to get this encryptedform is to just change your password on a Linux system and copy the value of the second field from/etc/shadow
. You can also encrypt a password using openssl passwd -1
.
Example
k3os: password: "$1$tYtghCfK$QHa51MS6MVAcfUKuOzNKt0"
Or clear text
k3os: password: supersecure
k3os.server_url
The URL of the k3s server to join as an agent.
Example
k3os: server_url: https://myserver:6443
k3os.token
The cluster secret or node token. If the value matches the format of a node token it willautomatically be assumed to be a node token. Otherwise it is treated as a cluster secret.
Example
k3os: token: myclustersecret
Or a node token
k3os: token: "K1074ec55daebdf54ef48294b0ddf0ce1c3cb64ee7e3d0b9ec79fbc7baf1f7ddac6::node:77689533d0140c7019416603a05275d4"
k3os.labels
Labels to be assigned to this node in Kubernetes on registration. After the node is first registeredin Kubernetes the value of this setting will be ignored.
Example
k3os: labels: region: us-west-1 somekey: somevalue
k3os.k3s_args
Arguments to be passed to the k3s process. The arguments should start with server
or agent
to be valid.k3s_args
is an exec-style (aka uninterpreted) argument array which means that when specifying a flag with a value onemust either join the flag to the value with an =
in the same array entry or specify the flag in an entry by itselfimmediately followed the value in another entry, e.g.:
# K3s flags with values joined with `=` in single entryk3os: k3s_args: - server - "--cluster-cidr=10.107.0.0/23" - "--service-cidr=10.107.1.0/23"# Effectively invokes k3s as:# exec "k3s" "server" "--cluster-cidr=10.107.0.0/23" "--service-cidr=10.107.1.0/23"
# K3s flags with values in following entryk3os: k3s_args: - server - "--cluster-cidr" - "10.107.0.0/23" - "--service-cidr" - "10.107.1.0/23"# Effectively invokes k3s as:# exec "k3s" "server" "--cluster-cidr" "10.107.0.0/23" "--service-cidr" "10.107.1.0/23"
k3os.environment
Environment variables to be set on k3s and other processes like the boot process.Primary use of this field is to set the http proxy.
Example
k3os: environment: http_proxy: http://myserver https_proxy: http://myserver
k3os.taints
Taints to set on the current node when it is first registered. After thenode is first registered the value of this field is ignored.
k3os: taints: - "key1=value1:NoSchedule" - "key1=value1:NoExecute"
Copyright (c) 2014-2020 Rancher Labs, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not usethis file except in compliance with the License. You may obtain a copy of theLicense at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributedunder the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES ORCONDITIONS OF ANY KIND, either express or implied. See the License for thespecific language governing permissions and limitations under the License.
请发表评论