无法为 kube-scheduler 设置新的 api 服务器地址

问题描述 投票:0回答:1

我将所有主节点上的API服务器IP地址更改为内部网络地址。我还在 kube-controller-manager 和 kubelet 中更改了它。重启 kubelet 后,kube-controller-manager 获得了新的 ip addr 并正常工作,但 kube-scheduler 没有刷新有关 IP addr 的新信息。

我做了什么:

  • 我在每个主节点上的/etc/kubernetes/scheduler.conf中更改了IP地址 在服务器部分中,之前的值是 https://127.0.0.1:6443 现在 https://

  • 我在控制平面上重新创建 kube-scheduler pod

  • 在每个主节点上重启 kubelet

在主节点上的调度程序日志中我看到:

大师1

E0527 17:05:30.129658       1 leaderelection.go:332] error retrieving resource lock kube-system/kube-scheduler: Get "https://127.0.0.1:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 17:05:33.388533       1 leaderelection.go:332] error retrieving resource lock kube-system/kube-scheduler: Get "https://127.0.0.1:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 17:05:35.812466       1 leaderelection.go:332] error retrieving resource lock kube-system/kube-scheduler: Get "https://127.0.0.1:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 17:05:39.611595       1 leaderelection.go:332] error retrieving resource lock kube-system/kube-scheduler: Get "https://127.0.0.1:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 17:05:43.051832       1 leaderelection.go:332] error retrieving resource lock kube-system/kube-scheduler: Get "https://127.0.0.1:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 17:05:46.371439       1 leaderelection.go:332] error retrieving resource lock kube-system/kube-scheduler: Get "https://127.0.0.1:6443/apis/coordination.k8s.io/v1/namespaces/kube-system/leases/kube-scheduler?timeout=5s": dial tcp 127.0.0.1:6443: connect: connection refused
I0527 17:06:07.483982       1 leaderelection.go:260] successfully acquired lease kube-system/kube-scheduler

大师2

E0527 20:21:40.340713       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.Namespace: failed to list *v1.Namespace: Get "https://127.0.0.1:6443/api/v1/namespaces?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:21:40.662843       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.PersistentVolumeClaim: Get "https://127.0.0.1:6443/api/v1/persistentvolumeclaims?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:21:40.662954       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.PersistentVolumeClaim: failed to list *v1.PersistentVolumeClaim: Get "https://127.0.0.1:6443/api/v1/persistentvolumeclaims?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:21:40.785335       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.CSIDriver: Get "https://127.0.0.1:6443/apis/storage.k8s.io/v1/csidrivers?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:21:40.785414       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.CSIDriver: failed to list *v1.CSIDriver: Get "https://127.0.0.1:6443/apis/storage.k8s.io/v1/csidrivers?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:21:41.866142       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.PodDisruptionBudget: Get "https://127.0.0.1:6443/apis/policy/v1/poddisruptionbudgets?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:21:41.866225       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.PodDisruptionBudget: failed to list *v1.PodDisruptionBudget: Get "https://127.0.0.1:6443/apis/policy/v1/poddisruptionbudgets?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused

大师3

W0527 20:22:08.468571       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.PodDisruptionBudget: Get "https://127.0.0.1:6443/apis/policy/v1/poddisruptionbudgets?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:22:08.468677       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.PodDisruptionBudget: failed to list *v1.PodDisruptionBudget: Get "https://127.0.0.1:6443/apis/policy/v1/poddisruptionbudgets?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:22:10.338980       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.StorageClass: Get "https://127.0.0.1:6443/apis/storage.k8s.io/v1/storageclasses?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:22:10.339106       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.StorageClass: failed to list *v1.StorageClass: Get "https://127.0.0.1:6443/apis/storage.k8s.io/v1/storageclasses?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:22:15.962091       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.Node: Get "https://127.0.0.1:6443/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:22:15.962156       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.Node: failed to list *v1.Node: Get "https://127.0.0.1:6443/api/v1/nodes?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:22:17.945875       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.PersistentVolumeClaim: Get "https://127.0.0.1:6443/api/v1/persistentvolumeclaims?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
E0527 20:22:17.945964       1 reflector.go:147] vendor/k8s.io/client-go/informers/factory.go:159: Failed to watch *v1.PersistentVolumeClaim: failed to list *v1.PersistentVolumeClaim: Get "https://127.0.0.1:6443/api/v1/persistentvolumeclaims?limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused
W0527 20:22:21.984112       1 reflector.go:539] vendor/k8s.io/client-go/informers/factory.go:159: failed to list *v1.Pod: Get "https://127.0.0.1:6443/api/v1/pods?fieldSelector=status.phase%21%3DSucceeded%2Cstatus.phase%21%3DFailed&limit=500&resourceVersion=0": dial tcp 127.0.0.1:6443: connect: connection refused

我的 kube-scheduler pod 清单位于 /etc/kubernetes/manifests/kube-scheduler.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-scheduler
    tier: control-plane
  name: kube-scheduler
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-scheduler
    - --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
    - --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
    - --bind-address=0.0.0.0
    - --config=/etc/kubernetes/kubescheduler-config.yaml
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=true
    - --profiling=False
    image: registry.k8s.io/kube-scheduler:v1.29.3
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        path: /healthz
        port: 10259
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15
    name: kube-scheduler
    resources:
      requests:
        cpu: 100m
    startupProbe:
      failureThreshold: 30
      httpGet:
        path: /healthz
        port: 10259
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15
    volumeMounts:
    - mountPath: /etc/kubernetes/scheduler.conf
      name: kubeconfig
      readOnly: true
    - mountPath: /etc/kubernetes/kubescheduler-config.yaml
      name: kubescheduler-config
      readOnly: true
  hostNetwork: true
  priority: 2000001000
  priorityClassName: system-node-critical
  securityContext:
    seccompProfile:
      type: RuntimeDefault
  volumes:
  - hostPath:
      path: /etc/kubernetes/scheduler.conf
      type: FileOrCreate
    name: kubeconfig
  - hostPath:
      path: /etc/kubernetes/kubescheduler-config.yaml
      type: ""
    name: kubescheduler-config
status: {}

文件 /etc/kubernetes/scheduler.conf 中的 IP 地址已更改

集群信息:

NAME                 STATUS   ROLES           AGE    VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION       CONTAINER-RUNTIME
m1   Ready    control-plane   5d5h   v1.29.3   <IP>      <none>        Ubuntu 22.04.4 LTS   5.15.0-25-generic    containerd://1.7.15
m2   Ready    control-plane   5d5h   v1.29.3   <IP>      <none>        Ubuntu 22.04.4 LTS   5.15.0-25-generic    containerd://1.7.15
m3   Ready    control-plane   5d5h   v1.29.3   <IP>      <none>        Ubuntu 22.04.4 LTS   5.15.0-25-generic    containerd://1.7.15
w1   Ready    worker          5d5h   v1.29.3   <IP>      <none>        Ubuntu 22.04.4 LTS   5.15.0-107-generic   containerd://1.7.15
w2   Ready    worker          5d5h   v1.29.3   <IP>      <none>        Ubuntu 22.04.4 LTS   5.15.0-107-generic   containerd://1.7.15
kubernetes kube-scheduler
1个回答
0
投票

kube-scheduler不支持动态配置更改。要为kube-scheduler设置新的服务器地址,您需要手动更新主节点上的配置文件并重新启动调度程序。 您可以尝试更新 KubeSchedulerConfiguration:

apiVersion: kubescheduler.config.k8s.io/v1
kind: KubeSchedulerConfiguration
clientConnection:
  kubeconfig: /path/to/new/kubeconfig

然后重新启动调度程序:

systemctl restart kube-scheduler
© www.soinside.com 2019 - 2024. All rights reserved.