Site Overlay

minikube + Kathara

安装Docker

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

ref: https://docs.docker.com/engine/install/ubuntu/

修改containerd配置

修改/etc/containerd/config.toml,将disabled_plugins = ["cri"]改为disabled_plugins = []

ref: https://github.com/containerd/containerd/issues/8139

安装minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
minikube start

ref: https://minikube.sigs.k8s.io/docs/start/

安装kubectl

sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

ref: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

安装Multus CNI

git clone https://github.com/k8snetworkplumbingwg/multus-cni.git && cd multus-cni
cat ./deployments/multus-daemonset-thick.yml | kubectl apply -f -

ref: https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/docs/quickstart.md

安装Megalos CNI

kubectl apply -f https://raw.githubusercontent.com/KatharaFramework/Megalos-CNI/master/kathara-daemonset.yml

ref: https://github.com/KatharaFramework/Megalos-CNI

安装Kathara

sudo apt install -y xterm
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 21805A48E6CBBA6B991ABE76646193862B759810
sudo add-apt-repository ppa:katharaframework/kathara
sudo apt update
sudo apt install -y kathara

ref: https://github.com/KatharaFramework/Kathara/wiki/Linux#debian-based

配置k8s的token

创建两个配置文件1.yaml2.yaml

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system

将两个文件apply:

kubectl apply -f 1.yaml
kubectl apply -f 2.yaml

获取token:

kubectl -n kube-system create token admin-user

获取到的token后面会用到。

ref: https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

配置Kathara

输入命令kathara settings,启动设置。

  1. 选择Choose default manager,将其改为Kubernetes (Megalos)
  2. 选择Insert a Kubernetes API Server URL,将其配置为https://127.0.0.1:8001
  3. 选择Insert a Kubernetes API Token,将其配置为上一步获取的token。

启动kubectl proxy

kubectl proxy --accept-hosts="^.*"

开始测试

wget https://github.com/KatharaFramework/Kathara-Labs/raw/master/Labs%20Integrating%20Several%20Technologies/Small%20Internet%20with%20DNS%20and%20Webserver/small-internet-w-dns-webserver.zip
unzip small-internet-w-dns-webserver.zip
cd small-internet-w-dns-webserver
kathara lstart

可以使用kathara connect <节点名称>命令进入节点的终端,进行测试,比如:

kathara connect as100r1

# 上一句会进入kathara-as100r1节点,然后执行:
ping 11.0.0.2

ref: https://github.com/KatharaFramework/Kathara#quick-example
https://github.com/KatharaFramework/Kathara-Labs/blob/master/Labs%20Integrating%20Several%20Technologies/Small%20Internet%20with%20DNS%20and%20Webserver/Small%20Internet%20with%20DNS%20and%20Webserver.pdf

1 thought on “minikube + Kathara

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据