mmumshad / kubernetes-the-hard-way

Bootstrap Kubernetes the hard way on Vagrant on Local Machine. No scripts.
Apache License 2.0
4.7k stars 4.54k forks source link

Controller services down #206

Closed radouani1984 closed 2 years ago

radouani1984 commented 3 years ago

Hello, I have installed the controller services as described in the document. However, I got an error when I attempted to check the status of the services.

vagrant@master-1:~$ kubectl get componentstatuses --kubeconfig admin.kubeconfig

Output

NAME                 STATUS      MESSAGE                                                                                     ERROR
scheduler            Unhealthy   Get http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: connect: connection refused   
controller-manager   Unhealthy   Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: connect: connection refused   
etcd-0               Healthy     {"health":"true"}                                                                           
etcd-1               Healthy     {"health":"true"} 

The same error goes for the master-2. Any idea how to resolve this issue? Thanks

willie-cadete commented 3 years ago

Try to check out the logs in /var/log/syslog and service status

$ sudo systemctl status kube-controller-manager.service

$ sudo systemctl status kube-scheduler

$ sudo tail -n50 /var/log/syslog
lenninspirit commented 3 years ago

Make sure the kubeconfig file used for both the kube-controller-manager and the kube-scheduler have a "current-context" set.

Following the guide and according to the documentation, the following command should do:

sudo kubectl config --kubeconfig=/var/lib/kubernetes/_path/to/_kube-controller-manager.kubeconfig use-context default (The same should be done for the kube-scheduler.kubeconfig and the admin.kubeconfig, though, if you were able to check the status means that the admin has a default set)

Leaving it here in case someone is facing the error "invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable.

Otherwise, if that is not the error, check the logs by using the command: systemctl -u kube-controller-manager Then pressing [Shift + G] to go to the last line.

~Was able to get the kube-controller-manager service running by adding the following flag to the service unit file:~

~--master=127.0.0.1:6443~

~(if adding to the /etc/systemd/system/kube-controller-manager.service file, and it is not the last argument, remember to add the trailing back-slash if keeping it organized by splitting it into different lines. That is: --master=127.0.0.1:6443~ \

~As for the case of the kube-scheduler service, found in the documentation that the --kubeconfig flag has been deprecated and --config is to be used instead.~

~However, the above for the kube-scheduler service didn't work. Adding the --master flag did. Though, unsure if the kubeconfig file will be ignore entirely or just the master address.~

kilyes commented 3 years ago

this link helped me https://github.com/mmumshad/kubernetes-the-hard-way/issues/66

fireflycons commented 2 years ago

Hi @radouani1984 @kilyes @willie-cadete

We have now merged a major change to bring this to v1.24. Many issues have been addressed as part of the upgrade. Please try it now and feel free to raise further issues.

Thanks.