一、问题描述
版本1.18+现在使用更安全的https端口10257,并默认禁用http。不幸的是,kube-controller-manager和kube-scheduler都使用了--secure-port绑定到127.0.0.1而不是0.0.0.0
解决方法:
更新/etc/kubernetes/manifests/中的清单以将--bind-address 0.0.0.0用于调度程序和控制器管理器,将使用正确的绑定地址重新启动Pod,但是这些设置将无法生存kubeadm升级
二、新增、更改KubeControllerManager配置
新增service.yaml
vim kube-prometheus/manifests/prometheus-serviceMonitorKubeControllerManager-service.yaml
输入下面内容 :
apiVersion: v1
kind: Service
metadata:
namespace: kube-system
name: kube-controller-manager
labels:
k8s-app: kube-controller-manager
spec:
ports:
- name: https-metrics
port: 10257
selector:
component: kube-controller-manager
修改/etc/kubernetes/manifests/kube-controller-manager.yaml
vim /etc/kubernetes/manifests/kube-controller-manager.yaml
将--bind-address=127.0.0.1 改为 --bind-address=0.0.0.0
由于kube-controller-manager是以静态Pod运行在集群中的,所以只要修改静态Pod目录下对应的yaml文件即可。等待一会后,对应服务会自动重启
三、新增、更改KubeScheduler配置
新增service.yaml
vim kube-prometheus/manifests/prometheus-serviceMonitorKubeScheduler-service.yaml
输入下面内容 :
apiVersion: v1
kind: Service
metadata:
namespace: kube-system
name: kube-scheduler
labels:
k8s-app: kube-scheduler
spec:
ports:
- name: https-metrics
port: 10259
selector:
component: kube-scheduler
修改 /etc/kubernetes/manifests/kube-scheduler.yaml
vim /etc/kubernetes/manifests/kube-scheduler.yaml
将--bind-address=127.0.0.1 改为 --bind-address=0.0.0.0
由于kube-scheduler是以静态Pod运行在集群中的,所以只要修改静态Pod目录下对应的yaml文件即可。等待一会后,对应服务会自动重启
四、结果图
五、参考信息
https://github.com/prometheus-operator/kube-prometheus
https://github.com/prometheus-operator/kube-prometheus/issues/718
https://blog.csdn.net/weixin_38645718/article/details/102816557