How to install kube-apiserver on centos?

7/20/2020

I have installed etcd and kubernetes on centos, now I wanna install kube-apiserver. I installed kube-apiserver by snap.

sudo yum install epel-release 
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install kube-apiserver

I start kube-apiserver with the guide by this link.
Unfortunately, I got failed with ***error etcd certificate file not found in /etc/kubernetes/apiserver/apiserver.pem. But I found that the certificate file exists, how to run the kube-apiserver successfully?

-- double sun
kubernetes

2 Answers

7/20/2020

I don't know the reason of your failure. But I suggest you to install kubernetes by kubeadm, it's a great k8s tool. If you install k8s by kubeadm, the kube-apiserver will be installed as a k8s pod. The guide to install kubeadm via this link.
I run the command kubectl get pods -A,

[karl@centos-linux ~]$ kubectl get pods -A
NAMESPACE     NAME                                          READY   STATUS    RESTARTS   AGE
kube-system   coredns-66bff467f8-64pt6                      1/1     Running   6          4d18h
kube-system   coredns-66bff467f8-xpnsr                      1/1     Running   6          4d18h
kube-system   etcd-centos-linux.shared                      1/1     Running   6          4d18h
kube-system   kube-apiserver-centos-linux.shared            1/1     Running   6          4d18h
kube-system   kube-controller-manager-centos-linux.shared   1/1     Running   6          4d18h
kube-system   kube-flannel-ds-amd64-48stf                   1/1     Running   8          4d18h
kube-system   kube-proxy-9w8gh                              1/1     Running   6          4d18h
kube-system   kube-scheduler-centos-linux.shared            1/1     Running   6          4d18h

kube-apiserver-centos-linux.shared is a kube-apiserver pod, it is installed successfully.

-- Karl Doenitz
Source: StackOverflow

7/20/2020

I suggest using standard tool such as Kubeadm to install kubernetes on centos. kubeadm init will generate necessary certificates and install all the kubernetes control plane components including Kubernetes API Server.

Following this guide you should be able to install a single control plane cluster of kubernetes.

Kubeadm supports kubernetes cluster with multiple control plane node as well as cluster with completely separate ETCD nodes.

-- Arghya Sadhu
Source: StackOverflow