编译Kubemark
背景
Kubemark是k8s虚拟化节点的工具,用于测试。
目前找不到现成可用Kubamark镜像,所以自行编译。
安装
1 2 3 4 5
| yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake yum -y install wget httpd-tools vim yum -y install glibc-static.x86_64 yum -y install binutils
|
Go环境准备:
LInuxGo部署过程
源码构建:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| yum install -y git
git clone https://github.com/kubernetes/kubernetes.git
git branch -a
git checkout -f remotes/origin/release-1.24
make WHAT='cmd/kubemark'
cp _output/bin/kubemark cluster/images/kubemark/ cd cluster/images/kubemark/
vim Dockerfile
make build
|
部署节点:
按照官网会出现缺少sh、bash的错误,因为google基础镜像没有这些
先给需要work节点打上label
1
| kubectl label node kubemark=work
|
hollow-node_simplified_template.yaml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| apiVersion: v1 kind: ReplicationController metadata: name: hollow-node namespace: kubemark spec: replicas: 50 selector: name: hollow-node template: metadata: labels: name: hollow-node spec: nodeSelector: kubemark: work initContainers: - name: init-inotify-limit image: docker.io/busybox:latest imagePullPolicy: IfNotPresent command: ['sysctl', '-w', 'fs.inotify.max_user_instances=200'] securityContext: privileged: true volumes: - name: rci-volume hostPath: path: /run/containerd - name: kubeconfig-volume secret: secretName: kubeconfig - name: logs-volume hostPath: path: /var/log containers: - name: hollow-kubelet image: piwriw/kubemark:v1.21 imagePullPolicy: IfNotPresent ports: - containerPort: 4194 - containerPort: 10250 - containerPort: 10255 env: - name: NODE_NAME valueFrom: fieldRef: fieldPath: metadata.name command: - /kubemark args: - --morph=kubelet - --name=$(NODE_NAME) - --kubeconfig=/kubeconfig/kubelet.kubeconfig - --alsologtostderr - --v=2 volumeMounts: - name: rci-volume mountPath: /run/containerd - name: kubeconfig-volume mountPath: /kubeconfig readOnly: true - name: logs-volume mountPath: /var/log resources: requests:
memory: 50M securityContext: privileged: true - name: hollow-proxy image: piwriw/kubemark:v1.21 imagePullPolicy: IfNotPresent env: - name: NODE_NAME valueFrom: fieldRef: fieldPath: metadata.name command: - /kubemark args: - --morph=proxy - --name=$(NODE_NAME) - --use-real-proxier=false - --kubeconfig=/kubeconfig/kubeproxy.kubeconfig - --alsologtostderr - --v=2 volumeMounts: - name: kubeconfig-volume mountPath: /kubeconfig readOnly: true - name: logs-volume mountPath: /var/log resources: requests:
memory: 50M tolerations: - effect: NoExecute key: node.kubernetes.io/unreachable operator: Exists - effect: NoExecute key: node.kubernetes.io/not-ready operator: Exists
|
问题 rpc error: code = Unimplemented desc = unknown service runtime.v1alpha2.ImageService
1 2 3 4 5 6 7 8
| cat > /etc/containerd/config.toml <<EOF [plugins."io.containerd.grpc.v1.cri"] systemd_cgroup = true EOF
systemctl restart containerd
|