我可以将kubelet作为基于kubernetes v1.6.6的docker容器运行吗?如果可以,如何创建图像或在何处获取图像,以及如何运行此图像?
以下是我的操作,但有一些问题。
Dockerfile
FROM i71:5000/ubuntu:14.04
ADD iptables /usr/local/bin/iptables
ADD bin/kubelet /usr/local/bin/kubelet
docker runing sh
#!/bin/bash
docker rm -f $(docker ps -aq --filter "name=kubelet")
docker run \
-d \
--restart="always" \
--net="host" \
-v /data/kubernetes-cluster/ssl:/data/kubernetes-cluster/ssl \
-v /data/kubernetes-cluster/kube-conf:/data/kubernetes-cluster/kube-conf \
-v /data/kubernetes-cluster/log:/data/kubernetes-cluster/log \
-v /data/kubelet:/var/lib/kubelet \
-v /etc/localtime:/etc/localtime \
-v /var/run/:/var/run/ \
-v /var/log/:/var/log/ \
--privileged=true \
--name kubelet \
i71:5000/kubelet:v1.6.6 \
/usr/local/bin/kubelet \
--logtostderr=true \
--v=0 \
--cgroup-driver=cgroupfs \
--api-servers=http://192.168.0.97:8080 \
--docker-endpoint=http://127.0.0.1:4243 \
--address=192.168.0.97 \
--hostname-override=192.168.0.97 \
--allow-privileged=true \
--pod-infra-container-image=i71:5000/pod-infrastructure:rhel7 \
--cluster-dns=10.3.0.2 \
--experimental-bootstrap-kubeconfig=/data/kubernetes-cluster/kube-conf/bootstrap.kubeconfig \
--kubeconfig=/data/kubernetes-cluster/kube-conf/kubelet.kubeconfig \
--require-kubeconfig \
--cert-dir=/data/kubernetes-cluster/ssl \
--cluster-domain=cluster.local. \
--hairpin-mode=promiscuous-bridge \
--serialize-image-pulls=false
kubelet打印出这些错误(我的docker damon pid是5140):
E0706 12:11:46.061949 1 container_manager_linux.go:394] open /proc/5140/cgroup: no such file or directory
E0706 12:11:46.137217 1 container_manager_linux.go:97] Unable to ensure the docker processes run in the desired containers
E0706 12:16:46.062290 1 container_manager_linux.go:394] open /proc/5140/cgroup: no such file or directory
E0706 12:16:46.138189 1 container_manager_linux.go:97] Unable to ensure the docker processes run in the desired containers
如果我做卷主持人dir' / proc',docker damon发生错误。
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "process_linux.go:359: container init caused \"rootfs_linux.go:54: mounting\\\"/proc\\\" to rootfs \\\"/data/docker/local-storage/docker/aufs/mnt/6ad53fff3b30e8d709b1be326f5de1314371e174e34806d4d6c6436275b6fbd3\\\" at \\\"/proc\\\" caused \\\"\\\\\\\"/data/docker/local-storage/docker/aufs/mnt/6ad53fff3b30e8d709b1be326f5de1314371e174e34806d4d6c6436275b6fbd3/proc\\\\\\\" cannot be mounted because it is located inside \\\\\\\"/proc\\\\\\\"\\\"\"".
我应该怎么做,有人能给我一个亮点吗?
答案 0 :(得分:1)
有一个名为hyperkube
的官方泊坞窗图片,其中包含所有Kubernetes二进制文件,请参阅https://kubernetes.io/docs/getting-started-guides/scratch/#selecting-images
您可以在此处找到有关如何将kubelet
用于#cloud-config
# run commands
# default: none
# runcmd contains a list of either lists or a string
# each item will be executed in order at rc.local like level with
# output to the console
# - runcmd only runs during the first boot
# - if the item is a list, the items will be properly executed as if
# passed to execve(3) (with the first arg as the command).
# - if the item is a string, it will be simply written to the file and
# will be interpreted by 'sh'
#
# Note, that the list has to be proper yaml, so you have to quote
# any characters yaml would eat (':' can be problematic)
runcmd:
- [ ls, -l, / ]
- [ sh, -xc, "echo $(date) ': hello world!'" ]
- [ sh, -c, echo "=========hello world'=========" ]
- ls -l /root
- [ wget, "http://slashdot.org", -O, /tmp/index.html ]
的示例系统服务:https://github.com/kubernetes/kubernetes-anywhere/blob/master/phase2/ignition/vanilla/kubelet.service