第6节 k3s Runtime Design



❤️💕💕记录sealosopen in new window开源项目的学习过程。k8s,docker和云原生的学习open in new window。Myblog:http://nsddd.topopen in new window


[TOC]

Idea

The community has great expectations for k3s. we need a more lightweight runtime (#issueopen in new window)

  • With high availability, reduce installation cost
  • high availability etcd
  • runtime interface need spilt kubeadm and k3s and k0s,Interface layer exposure, alignment
  • new_runtime.go determines which runtime.go to call based on the parameters passed in
  • k3s rootfs
  • Add a corresponding test function
  • Minimum resource test k3s vs k0sopen in new window

module list

#runtime
|____interface.go
|____types.go
|____utils.go
|____utils_test.go
|____new_runtime.go # new_runtime determines which runtime.go to call based on the parameters passed in
|____k0s
| |____common.go
| |____delete_masters.go
| |____delete_nodes.go
| |____init.go
| |____join_masters.go
| |____join_nodes.go
| |____README.md
| |____registry.go
| |____reset.go
| |____runtime.go
| |____upgrade.go
| |____utils.go
| |____v1beta1
| | |____types.go
|____kubernetes
| |____clean.go
| |____driver.go
| |____init.go
| |____join_masters.go
| |____join_nodes.go
| |____kubeadm
| | |____common.go
| | |____kubeadm_config.go
| | |____kubeadm_config_test.go
| |____runtime.go
| |____utils.go

interface(☕in preparation…)

type Interface interface {
	// Init exec kubeadm init
	Init(cluster *v2.Cluster) error
	Upgrade() error
	Reset() error
	JoinMasters(newMastersIPList []string) error
	JoinNodes(newNodesIPList []string) error
	DeleteMasters(mastersIPList []string) error
	DeleteNodes(nodesIPList []string) error
	//UpdateCert(certs []string) error
    NewK0sRuntime(cluster *v2.Cluster)(runtime.Installer, error) 
}

demo: 🧷 Runtime interface demonstrationopen in new window

achieve interface

  1. Support k3s to init、join、upgrade、reset k3s cluster
  2. Support docker as runtime
  3. Pakage the CloudImage

CloudRootfs

kubernetes:

/var/lib/sealer/data/overlay2/ebd0f721b47d5f7f3ea287fe0882613960deef376e5556b34baab95330aa6bad

Kuberfile - k8s:

FROM scratch
COPY . .
COPY imageList manifests

Kuberfile - k0s:

COPY rootfs/* .
COPY ${ARCH} .
COPY ImageList manifests
BASE rootfs cache

Kuberfile - k3s:

My talking about packaging up a minimal Linux distribution to run K3s, similar to https://github.com/rancher/k3os? Or mean just the root filesystem, such as we provide with k3s via https://github.com/k3s-io/k3s-root ?⚠️

  1. Onlineopen in new window Installation
FROM scratch
COPY imageList manifests
RUN curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.25.3 sh -
COPY . .
  1. Offlineopen in new window installation

k3s-insatll.shk3s-airgap-images-$ARCH.tark3sbinary system

FROM scratch
COPY imageList manifests
COPY . .

k3s - rootfs

sh install.sh There are a number of link types from bin

.# k3s rootfs
├── bin
│  ├── k3s
├── etc
│  ├── k3s
│  │   └── k3s.yaml
│  └── node
│      └── password
├── images
├── k3s-install.sh
├── Kuberfile
├── Metadata
└── README.md

About the k3s difference

**The installation script is k3s-insatll.sh. **

cluster role:

  • k3s server
  • k3s agents(worker nodes)

uninstalling a node:

k3s : k3s-uninstall.sh

  • k3s server : /usr/local/bin/k3s-uninstall.sh
  • k3s agent : /usr/local/bin/k3s-agent-uninstall.sh

version

Embedded Component Versions

ComponentVersion
Kubernetesv1.25.3open in new window
Kinev0.9.3open in new window
SQLite3.36.0open in new window
Etcdv3.5.3-k3s1open in new window
Containerdv1.6.8-k3s1open in new window
Runcv1.1.4open in new window
Flannelv0.19.2open in new window
Metrics-serverv0.6.1open in new window
Traefikv2.9.1open in new window
CoreDNSv1.9.1open in new window
Helm-controllerv0.12.3open in new window
Local-path-provisionerv0.0.21open in new window

newest

Issue Description

Support k3s cluster installation. Type: feature request

Describe what feature you want

step

  1. Deploy the private mirror registry (ref: https://docs.rancher.cn/docs/k3s/installation/airgap/_index) a. Distribute the k3s configuration to connect to private registry. (ref: https://docs.rancher.cn/docs/k3s/installation/private-registry/_index)
  2. Get k3s binary and move to /usr/local/bin or /usr/bin.
  3. Get k3s-install script from https://get.k3s.io/ (this would be contained by rootfs).
  4. Install k3s offline on master0 as a server (not HA cluster).
  5. Joining k3s agent and sever use k3s-install script.
  6. Using scripts to delete node (ref: https://docs.rancher.cn/docs/k3s/installation/uninstall/_index). To force delete need to exec k3s-killall.sh. (ref: https://docs.rancher.cn/docs/k3s/upgrades/killall/_index)
  7. Upgrades need to follow basic upgrade, upgrade from sever node one by one! (ref: https://docs.rancher.cn/docs/k3s/upgrades/basic/_index)

rootfs

.
├── bin
│   ├── conntrack
│   ├── containerd-rootless-setuptool.sh
│   ├── containerd-rootless.sh
│   ├── crictl
│   ├── k3s
│   ├── kubectl
│   ├── nerdctl
│   └── seautil
├── cri
│   └── docker.tar.gz
├── custom-resources.yaml
├── etc
│   ├── registries.yaml
│   ├── daemon.json
│   ├── docker.service
│   ├── k3s.yaml
│   └── registry_config.yml
├── images
│   └── docker-amd64-registry-image.tar.gz
├── Kubefile
├── lib
│   ├── gperf-3.1.tar.gz
│   ├── install_libseccomp.sh
│   └── libseccomp-2.5.4.tar.gz
├── manifests
│   └── imageList
└── scripts
    ├── docker.sh
    ├── k3s-install.sh
    ├── init-registry.sh
    └── uninstall-docker.sh

Additional context

Add any other context or screenshots about the feature request here.

END 链接