第6节 k3s Runtime Design
❤️💕💕记录sealos开源项目的学习过程。k8s,docker和云原生的学习。Myblog:http://nsddd.top
[TOC]
Idea
The community has great expectations for k3s. we need a more lightweight runtime (#issue)
- 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 whichruntime.go
to call based on the parameters passed in- k3s rootfs
- Add a corresponding test function
- Minimum resource test k3s vs k0s
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 demonstration
achieve interface
- Support k3s to init、join、upgrade、reset k3s cluster
- Support docker as runtime
- 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 ?⚠️
- Online Installation
FROM scratch
COPY imageList manifests
RUN curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.25.3 sh -
COPY . .
- Offline installation
k3s-insatll.sh
、k3s-airgap-images-$ARCH.tar
、k3s
binary 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
- Comparison of k3s vs k0s
- Comparison of containerd vs docker
**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
Component | Version |
---|---|
Kubernetes | v1.25.3 |
Kine | v0.9.3 |
SQLite | 3.36.0 |
Etcd | v3.5.3-k3s1 |
Containerd | v1.6.8-k3s1 |
Runc | v1.1.4 |
Flannel | v0.19.2 |
Metrics-server | v0.6.1 |
Traefik | v2.9.1 |
CoreDNS | v1.9.1 |
Helm-controller | v0.12.3 |
Local-path-provisioner | v0.0.21 |
newest
Issue Description
Support k3s cluster installation. Type: feature request
Describe what feature you want
step
- 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)
- Get k3s binary and move to /usr/local/bin or /usr/bin.
- Get k3s-install script from https://get.k3s.io/ (this would be contained by rootfs).
- Install k3s offline on master0 as a server (not HA cluster).
- Joining k3s agent and sever use k3s-install script.
- 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)
- 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 链接
✴️版权声明 © :本书所有内容遵循CC-BY-SA 3.0协议(署名-相同方式共享)©