1

我使用hyperkube不安全的 API 设置了不安全的 k8s 主节点:

docker run -d --name=k8s-apiserver --net=container:etcd gcr.io/google_containers/hyperkube:v1.8.5 /apiserver --etcd-servers=http://127.0.0.1:2378 --service-cluster-ip-range=10.0.0.1/24 --insecure-bind-address=0.0.0.0 --insecure-port=8080 --admission-control=AlwaysAdmit

继续配置节点,docker run -d --name=kubelet gcr.io/google_containers/hyperkube:v1.8.5 /kubelet命令的哪个选项指向kubelet主节点apiserver?我似乎无法使用--help.

4

1 回答 1

2

从 kubernetes 1.8 版开始,您应该使用--kubeconfigkey 指定文件的路径,该kubeconfig文件描述了如何连接到 API 服务器:

--kubeconfig string      Path to a kubeconfig file, specifying how to connect to the API server. (default "/var/lib/kubelet/kubeconfig")

/var/lib/kubelet/kubeconfig像这样的地方:

apiVersion: v1
clusters:
- cluster:
    certificate-authority: ~/.kube/ca.crt
    server: https://<API_IP>:<API_PORT>
  name: dev
contexts:
- context:
    cluster: dev
    user: dev
  name: dev
current-context: dev
kind: Config
preferences: {}
users:
- name: dev
  user:
    as-user-extra: {}
    client-certificate: ~/.kube/client.crt
    client-key: ~/.kube/client.key

所以,最后你应该把配置文件挂载到kubeletdocker 容器中:

docker run -d -v /var/lib/kubelet/kubeconfig:/var/lib/kubelet/kubeconfig --name=kubelet gcr.io/google_containers/hyperkube:v1.8.5 /kubelet
于 2017-12-11T18:56:07.340 回答