简体   繁体   English

kube-apiserver 位于何处

[英]Where is kube-apiserver located

Base question: When I try to use kube-apiserver on my master node, I get command not found error.基本问题:当我尝试在主节点上使用 kube-apiserver 时,出现命令未找到错误。 How I can install/configure kube-apiserver?如何安装/配置 kube-apiserver? Any link to example will help.任何示例链接都会有所帮助。

$ kube-apiserver --enable-admission-plugins DefaultStorageClass
-bash: kube-apiserver: command not found

Details: I am new to Kubernetes and Docker and was trying to create StatefulSet with volumeClaimTemplates.详细信息:我是 Kubernetes 和 Docker 的新手,正在尝试使用 volumeClaimTemplates 创建 StatefulSet。 My problem is that the automatic PVs are not created and I get this message in the PVC log: "persistentvolume-controller waiting for a volume to be created".我的问题是没有创建自动 PV,我在 PVC 日志中收到此消息:“persistentvolume-controller waiting for a volume to be created”。 I am not sure if I need to define DefaultStorageClass and so needed kube-apiserver to define it.我不确定是否需要定义 DefaultStorageClass,因此需要 kube-apiserver 来定义它。

Name:          nfs
Namespace:     default
StorageClass:  example-nfs
Status:        Pending
Volume:
Labels:        <none>
Annotations:   volume.beta.kubernetes.io/storage-provisioner=example.com/nfs
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
Events:
  Type    Reason                Age                  From                         Message
  ----    ------                ----                 ----                         -------
  Normal  ExternalProvisioning  3m (x2401 over 10h)  persistentvolume-controller  waiting for a volume to be created, either by external provisioner "example.com/nfs" or manually created by system administrator

Here is get pvc result:这是得到 pvc 结果:

$ kubectl get pvc
NAME      STATUS    VOLUME    CAPACITY   ACCESS MODES   STORAGECLASS   AGE
nfs       Pending                                       example-nfs    10h

And get storageclass:并获取存储类:

$ kubectl describe storageclass example-nfs
Name:                  example-nfs
IsDefaultClass:        No
Annotations:           <none>
Provisioner:           example.com/nfs
Parameters:            <none>
AllowVolumeExpansion:  <unset>
MountOptions:          <none>
ReclaimPolicy:         Delete
VolumeBindingMode:     Immediate
Events:                <none>

How can I troubleshoot this issue (eg logs for why the storage was not created)?如何解决此问题(例如,未创建存储的原因的日志)?

You are asking two different questions here, one about kube-apiserver configuration, one about troubleshooting your StorageClass .您在这里问了两个不同的问题,一个关于 kube-apiserver 配置,一个关于对您的StorageClass故障排除。

Here's an answer for your first question:这是您的第一个问题的答案:

kube-apiserver is running as a Docker container on your master node. kube-apiserver在您的主节点上作为 Docker 容器运行。 Therefore, the binary is within the container, not on your host system.因此,二进制文件容器内,而不是在您的主机系统上。 It is started by the master's kubelet from a file located at /etc/kubernetes/manifests .它由 master 的kubelet从位于/etc/kubernetes/manifests的文件启动。 kubelet is watching this directory and will start any Pod defined here as "static pods". kubelet正在监视此目录,并将启动此处定义为“静态 Pod”的任何 Pod。

To configure kube-apiserver command line arguments you need to modify /etc/kubernetes/manifests/kube-apiserver.yaml on your master.要配置kube-apiserver命令行参数,您需要修改/etc/kubernetes/manifests/kube-apiserver.yaml上的/etc/kubernetes/manifests/kube-apiserver.yaml

I'll refer to the question regarding the location of the api-server.我将参考有关 api-server 位置的问题。

Basic answer (specific to the question title):基本答案(特定于问题标题):

The kube apiserver is located on the master node (known as the control plane). kube apiserver 位于主节点(称为控制平面)上。

It can be executed:它可以执行:

1 ) Via the host's init system (like systemd ). 1)通过主机的初始化系统(如systemd )。

2 ) As a pod (I'll explain below). 2)作为一个豆荚(我将在下面解释)。

In both cases it will be located on the control plane (left side below):在这两种情况下,它将位于控制平面上(下方左侧):

在此处输入图片说明

If its running under systemD you can run: systemctl status api-server to see the path to the configuration (drop-in) file.如果它在 systemD 下运行,您可以运行: systemctl status api-server以查看配置(插入)文件的路径。
If it is running as pod you can view it under the kube-system namespace with all other control panel components (plus kube-proxy and maybe network solution like weave below):如果它作为 pod 运行,您可以在kube-system命名空间下查看它以及所有其他控制面板组件(加上kube-proxy和可能的网络解决方案,如下面的 weave):

$ kubectl get pods -n kube-system
NAME                                      READY   STATUS    RESTARTS   AGE
coredns-f9fd979d6-lpdlc                   1/1     Running   1          2d22h
coredns-f9fd979d6-vcs7g                   1/1     Running   1          2d22h
etcd-my-master                            1/1     Running   1          2d22h
kube-apiserver-my-master                  1/1     Running   1          2d22h #<----Here
kube-controller-manager-my-master         1/1     Running   1          2d22h
kube-proxy-kh2lc                          1/1     Running   1          2d22h
kube-scheduler-my-master                  1/1     Running   1          2d22h
weave-net-59r5b                           2/2     Running   3          2d22h

You can run:你可以运行:

kubectl describe pod/kube-apiserver-my-master -n kube-system

In order to get more details regarding the pod.为了获得有关 pod 的更多详细信息。

A bit more advanced answer:更高级的答案:

(regarding the location of /etc/kubernetes/manifests) (关于 /etc/kubernetes/manifests 的位置)

Lets say we have no idea where to find the relevant path for the kube-api-server config file.假设我们不知道在哪里可以找到 kube-api-server 配置文件的相关路径。

But we need to remember two important things:但是我们需要记住两个重要的事情:

1 ) The kube-api-server is running on the master node. 1 ) kube-api-server 在主节点上运行。

2 ) The Kubelet isn't running as pod and when the control plane components (plus kube-proxy) are executed as static pods - it is done by the Kubelet on the master node. 2 ) Kubelet 不作为 pod 运行,并且当控制平面组件(加上 kube-proxy)作为静态 pod执行时 - 它由主节点上的 Kubelet 完成。

So we can start our journey for reaching the manifests path by investigating the Kubelet logs.因此,我们可以通过调查 Kubelet 日志开始我们到达清单路径的旅程。
If the Kubelet is running for a long time it will be a very large file and we'll need to dump it somewhere and go to the begging - or if Kubelet was started 5 minutes ago we can run:如果 Kubelet 运行了很长时间,它将是一个非常大的文件,我们需要将它转储到某个地方并进行请求——或者如果 Kubelet 是在 5 分钟前启动的,我们可以运行:

sudo journalctl -u kubelet --since -5m >> kubelet_5_minutes.log

And a quick search for "api-server" will bring us to the 2 lines below where the path of the manifests in mentioned:快速搜索“api-server”会将我们带到下面的 2 行,其中提到了清单的路径:

my-master kubelet[71..]: 00:03:21 kubelet.go:261] Adding pod path: /etc/kubernetes/manifests
my-master kubelet[71..]: 00:03:21 kubelet.go:273] Watching apiserver

And also we can see that the Kubelet is trying to create the kube-apiserver pod under my-master node and inside the kube-system namespace:我们还可以看到 Kubelet 正在尝试在my-master节点下和kube-system命名空间内创建 kube-apiserver pod:

my-master kubelet[71..]: 00:03:29.05  kubelet.go:1576] ..
           Creating a  mirror pod for "kube-apiserver-my-master_kube-system

To make the storage class "example-nfs" default, you need to run the below command:要使存储类“example-nfs”成为默认值,您需要运行以下命令:

kubectl patch storageclass example-nfs -p '{"metadata": 
  {"annotations": {"storageclass.kubernetes.io/is-default-class": "true"}}}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM