当前位置:网站首页>How to integrate Kata in kubernetes cluster
How to integrate Kata in kubernetes cluster
2022-07-24 19:51:00 【Xie Xiaoyu】
Kubernetes Cluster integration Kata
install Kubernetes colony
Use Kubeadm It is very convenient to install the cluster , You can refer to stay ubuntu Install in k8s colony .
You can also refer to official documents directly :https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/ .
- View installed Kubernetes edition
$ kubectl version
Client Version: version.Info{
Major:"1", Minor:"17", GitVersion:"v1.17.9", GitCommit:"4fb7ed12476d57b8437ada90b4f93b17ffaeed99", GitTreeState:"clean", BuildDate:"2020-07-15T16:18:16Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{
Major:"1", Minor:"17", GitVersion:"v1.17.9", GitCommit:"4fb7ed12476d57b8437ada90b4f93b17ffaeed99", GitTreeState:"clean", BuildDate:"2020-07-15T16:10:45Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
install Kata Command line tools
With CentOS Operating system as an example :
$ source /etc/os-release
$ yum -y install yum-utils
$ ARCH=$(arch)
$ BRANCH="${BRANCH:-master}"
$ yum-config-manager --add-repo "http://download.opensuse.org/repositories/home:/katacontainers:/releases:/${ARCH}:/${BRANCH}/CentOS_${VERSION_ID}/home:katacontainers:releases:${ARCH}:${BRANCH}.repo"
$ yum -y install kata-runtime kata-proxy kata-shim
stay Ubuntu in ( Refer to official documentation ):
$ ARCH=$(arch)
$ BRANCH="${BRANCH:-master}"
$ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/katacontainers:/releases:/${ARCH}:/${BRANCH}/xUbuntu_$(lsb_release -rs)/ /' > /etc/apt/sources.list.d/kata-containers.list"
$ curl -sL http://download.opensuse.org/repositories/home:/katacontainers:/releases:/${
ARCH}:/${
BRANCH}/xUbuntu_$(lsb_release -rs)/Release.key | sudo apt-key add -
$ sudo -E apt-get update
$ sudo -E apt-get -y install kata-runtime kata-proxy kata-shim
Check if the hardware supports Kata
Kata The requirements for hardware need to meet any of the following conditions :
- Intel VT-x technology.
- ARM Hyp mode (virtualization extension).
- IBM Power Systems.
- IBM Z mainframes.
installed kata-runtime after , Execute test command :
$ kata-runtime kata-check
System is capable of running Kata Containers
System can currently create Kata Containers
The output here represents , The running environment supports Kata Containers
Configure and test Docker( Official documents )
- To configure kata-runtime Parameters
$ vim /etc/docker/daemon.json
Add the following , Default still used runc, But by specifying runtime Parameters can be used Kata .
{
"runtimes": {
"kata-runtime": {
"path": "/usr/bin/kata-runtime"}
}}
restart Docker service
$ systemctl daemon-reload
$ systemctl restart docker
test Kata Is the installation successful
$ docker run --runtime=kata-runtime busybox uname -a
Linux 249a23f53475 5.4.60-65.1.container #1 SMP Thu Jan 1 00:00:00 UTC 1970 x86_64 GNU/Linux
$ docker run busybox uname -a
Linux b4812ed8990c 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 GNU/Linux
kata-runtime The container uses a different kernel version than the host , This means that kata-runtime Configuration worked .
To configure Kubelet
- New configuration file
$ mkdir -p /etc/systemd/system/kubelet.service.d/
$ cat << EOF | sudo tee /etc/systemd/system/kubelet.service.d/0-containerd.conf
[Service]
Environment="KUBELET_EXTRA_ARGS=--container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock"EOF
- Restart and take effect
$ systemctl daemon-reload
$ systemctl restart kubelet
What we use here is containerd . If you use CRI-O , The configuration will be different .
to Kubernetes Provide kata-runtime
By directly creating Container have access to kata-runtime . But in a cluster , How can we tell Kubernetes Which loads need to be used kata-runtime Well ? According to different versions ,Kata Provides different ways .
First of all, you need to generate containerd The configuration file
$ containerd config default > /etc/containerd/config.toml
- RuntimeClass The way
This method requires relevant component versions :
Kata Containers v1.5.0 or above (including 1.5.0-rc)
Containerd v1.2.0 or above
Kubernetes v1.12.0 or above
stay config.toml In profile , Add the following :
[plugins.cri.containerd]
no_pivot = false[plugins.cri.containerd.runtimes]
[plugins.cri.containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v1"
[plugins.cri.containerd.runtimes.runc.options]
NoPivotRoot = false
NoNewKeyring = false
ShimCgroup = ""
IoUid = 0
IoGid = 0
BinaryName = "runc"
Root = ""
CriuPath = ""
SystemdCgroup = false
[plugins.cri.containerd.runtimes.kata]
runtime_type = "io.containerd.kata.v2"
[plugins.cri.containerd.runtimes.katacli]
runtime_type = "io.containerd.runc.v1"
[plugins.cri.containerd.runtimes.katacli.options]
NoPivotRoot = false
NoNewKeyring = false
ShimCgroup = ""
IoUid = 0
IoGid = 0
BinaryName = "/usr/bin/kata-runtime"
Root = ""
CriuPath = ""
SystemdCgroup = false
here [plugins.cri.containerd.runtimes.kata] Medium kata Will be used as RuntimeClass handler keyword .
- Use untrusted_workload_runtime The way
For the environment that does not meet the requirements of the above version , You can use the previous method .
Add the following to the configuration file :
[plugins.cri.containerd.untrusted_workload_runtime]
runtime_type = "io.containerd.runtime.v1.linux"
runtime_engine = "/usr/bin/kata-runtime"
Last , Both need to be rebooted containerd.
$ containerd systemctl daemon-reload
$ systemctl restart containerd
And then I'll talk about kubelet Copy the configuration file to the user directory
sudo mkdir -p /home/xrw/.kube && sudo cp /etc/kubernetes/admin.conf /home/xrw/.kube/config
Use kata-runtime
RuntimeClass The way
- establish RuntimeClass
kata-runtime.yaml
kind: RuntimeClass
apiVersion: node.k8s.io/v1beta1
metadata:
name: kata-containers
handler: kata
It can also be for runc establish RuntimeClass
$ kubectl get runtimeclass
NAME CREATED AT
kata-containers 2020-08-30
Create a payload kata-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: kata-nginx
spec:
runtimeClassName: kata-containers
containers:
- name: nginx
image: nginx
ports:- containerPort: 80
$ kubectl apply -f kata-pod.yaml
Check whether the load is kata Running
# obtain pod Medium Container ID
$ sudo kubectl decribe pod kata-nginx
# Check whether the container runtime of the container kata
$ sudo crictl inspect [Container ID]
untrusted_workload_runtime Use annotations tell Kubernetes Which loads of the cluster need to be used kata-runtime.
annotations:
io.kubernetes.cri.untrusted-workload: "true"
Here's an example kata-pod-untrusted.yaml
apiVersion: v1
kind: Pod
metadata:
name: kata-nginx-untrusted
annotations:
io.kubernetes.cri.untrusted-workload: "true"
spec:
containers:
- name: nginx
image: nginx
ports:- containerPort: 80
$ kubectl apply -f kata-pod-untrusted.yaml
边栏推荐
- 870. Approximate number
- 拿捏C指针
- Flink Window&Time 原理
- Please ask a question. Follow the quick start method. After creating the table, the Flink SQL queries and displays the table structure, but there is an error when it exceeds the limit. What should we
- day 1
- Pay close attention! List of the latest agenda of 2022 open atom open source Summit
- Codeforces round 580 (Div. 2) c- almost equal [Law]
- PostgreSQL weekly news - July 13, 2022
- [untitled]
- 聊下自己转型测试开发的历程
猜你喜欢

【德味】安全:如何为行人提供更多保护

Talk about your transformation test development process

Flink Window&Time 原理

Setting up a dual machine debugging environment for drive development (vs2017)

Day 9 (this keyword and experiment)

This visual analysis library makes it easy for you to play with data science!

Thymeleaf application notes

Getting started with COM programming 1- creating projects and writing interfaces

【JVM学习03】类加载与字节码技术

01 | opening words: teach you to build a blog website hand in hand
随机推荐
Decorator of function
[JVM learning 04] JMM memory model
从码农转型大音乐家,你只差这些音乐处理工具
Detailed explanation of ELF format (I)
Leetcode652 finding duplicate subtrees
How to convert the world coordinates of unity's camera into view matrix
Richview table table alignment
Modelarts, Pangu big model, ModelBox... Detailed explanation of Huawei cloud AI development production line
Xiaomi 12s ultra products are so powerful, but foreigners can't buy Lei Jun: first concentrate on the Chinese market
Talk about your transformation test development process
01 | opening words: teach you to build a blog website hand in hand
Biopharmaceutical safety, power supply and production guarantee
How to encrypt your own program with dongle
MySQL8.0学习记录20 - Trigger
871. Sum of divisors
Introduction to WDK development 1- basic environment construction and the first driver (VS2010)
Excuse me: is Flink 1.14.5 compatible with MySQL CDC 2.1.0
Unity2d~ game practice of decrypting Zhou mu (completed in three days)
How to select software dongle
Hold the C pointer