Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

代替原始调度器失败 #42

Open
zhimushan opened this issue Feb 28, 2023 · 3 comments
Open

代替原始调度器失败 #42

zhimushan opened this issue Feb 28, 2023 · 3 comments

Comments

@zhimushan
Copy link

zhimushan commented Feb 28, 2023

k8s版本1.21.10
kube-scheduler-master报错信息:

[root@master ~]# kubectl describe pod kube-scheduler-master -n kube-system
Name:                 kube-scheduler-master
Namespace:            kube-system
Priority:             2000001000
Priority Class Name:  system-node-critical
Node:                 master/192.168.189.100
Start Time:           Sun, 12 Feb 2023 19:10:12 +0800
Labels:               component=kube-scheduler
                      tier=control-plane
Annotations:          kubernetes.io/config.hash: 456d6f68d333532ade0a5a2a7823efaf
                      kubernetes.io/config.mirror: 456d6f68d333532ade0a5a2a7823efaf
                      kubernetes.io/config.seen: 2023-03-02T16:52:39.104787713+08:00
                      kubernetes.io/config.source: file
Status:               Running
IP:                   192.168.189.100
IPs:
  IP:           192.168.189.100
Controlled By:  Node/master
Containers:
  kube-scheduler:
    Container ID:  docker://80e22d215ac0eccdce39322f85307f46c558d84d70346a12c89ad45150b440c7
    Image:         gocrane/crane-scheduler:0.0.23
    Image ID:      docker-pullable://gocrane/crane-scheduler@sha256:9ba6d11b20794b29d35661998e806b5711b36f49f5b57e8bd32af2ca8426c928
    Port:          <none>
    Host Port:     <none>
    Command:
      kube-scheduler
      --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
      --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
      --bind-address=127.0.0.1
      --kubeconfig=/etc/kubernetes/scheduler.conf
      --leader-elect=true
      --port=0
      --config=/etc/kubernetes/scheduler-config.yaml
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       ContainerCannotRun
      Message:      failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "kube-scheduler": executable file not found in $PATH: unknown
      Exit Code:    127
      Started:      Thu, 02 Mar 2023 16:53:13 +0800
      Finished:     Thu, 02 Mar 2023 16:53:13 +0800
    Ready:          False
    Restart Count:  2
    Requests:
      cpu:        100m
    Liveness:     http-get https://127.0.0.1:10259/healthz delay=10s timeout=15s period=10s #success=1 #failure=8
    Startup:      http-get https://127.0.0.1:10259/healthz delay=10s timeout=15s period=10s #success=1 #failure=24
    Environment:  <none>
    Mounts:
      /etc/kubernetes/scheduler-config.yaml from schedulerconfig (ro)
      /etc/kubernetes/scheduler.conf from kubeconfig (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  kubeconfig:
    Type:          HostPath (bare host directory volume)
    Path:          /etc/kubernetes/scheduler.conf
    HostPathType:  FileOrCreate
  schedulerconfig:
    Type:          HostPath (bare host directory volume)
    Path:          /etc/kubernetes/scheduler-config.yaml
    HostPathType:  FileOrCreate
QoS Class:         Burstable
Node-Selectors:    <none>
Tolerations:       :NoExecute op=Exists
Events:
  Type     Reason   Age                From     Message
  ----     ------   ----               ----     -------
  Normal   Pulled   17s (x3 over 39s)  kubelet  Container image "gocrane/crane-scheduler:0.0.23" already present on machine
  Normal   Created  17s (x3 over 39s)  kubelet  Created container kube-scheduler
  Warning  Failed   17s (x3 over 39s)  kubelet  Error: failed to start container "kube-scheduler": Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "kube-scheduler": executable file not found in $PATH: unknown
  Warning  BackOff  1s (x6 over 38s)   kubelet  Back-off restarting failed container

无法修改版本,显示找不到scheduler-config,应该是因为kube-scheduler-master无法创建的原因

[root@master ~]# KUBE_EDITOR="sed -i 's/v1beta2/v1beta1/g'" kubectl edit cm scheduler-config -n crane-system && KUBE_EDITOR="sed -i 's/0.0.23/0.0.20/g'" kubectl edit deploy crane-scheduler -n crane-system
Error from server (NotFound): configmaps "scheduler-config" not found

修改的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=127.0.0.1
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=true
    - --port=0
    - --config=/etc/kubernetes/scheduler-config.yaml
    # image: registry.cn-hangzhou.aliyuncs.com/google_containers/kube-scheduler:v1.21.10
    image: gocrane/crane-scheduler:0.0.23
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 127.0.0.1
        path: /healthz
        port: 10259
        scheme: HTTPS
      initialDelaySeconds: 10
      periodSeconds: 10
      timeoutSeconds: 15
    name: kube-scheduler
    resources:
      requests:
        cpu: 100m
    startupProbe:
      failureThreshold: 24
      httpGet:
        host: 127.0.0.1
        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/scheduler-config.yaml
      name: schedulerconfig
      readOnly: true
  hostNetwork: true
  priorityClassName: system-node-critical
  volumes:
  - hostPath:
      path: /etc/kubernetes/scheduler.conf
      type: FileOrCreate
    name: kubeconfig
  - hostPath:
      path: /etc/kubernetes/scheduler-config.yaml
      type: FileOrCreate
    name: schedulerconfig
status: {}

修改的scheduler-config.yaml的内容

apiVersion: kubescheduler.config.k8s.io/v1beta2
kind: KubeSchedulerConfiguration
leaderElection:
  leaderElect: true
clientConnection:
  kubeconfig: /etc/kubernetes/scheduler.conf
profiles:
  - schedulerName: default-scheduler
    plugins:
      filter:
        enabled:
          - name: Dynamic
      score:
        enabled:
          - name: Dynamic
            weight: 3
    pluginConfig:
      - name: Dynamic
        args:
          policyConfigPath: /etc/kubernetes/policy.yaml
@xieydd
Copy link
Member

xieydd commented Mar 6, 2023

you can update KubeSchedulerCofiguration manually, this command have some error
KUBE_EDITOR="sed -i 's/v1beta2/v1beta1/g'" kubectl edit cm scheduler-config -n crane-system
i wil fixed it.

@zhimushan
Copy link
Author

我可以问下我的kube-scheduler.yaml这个文件修改正确吗?主要修改了四个部分

spec:
  containers:
  - command:
    - kube-scheduler
    - --authentication-kubeconfig=/etc/kubernetes/scheduler.conf
    - --authorization-kubeconfig=/etc/kubernetes/scheduler.conf
    - --bind-address=127.0.0.1
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=true
    - --port=0
    - --config=/etc/kubernetes/scheduler-config.yaml
    image: gocrane/crane-scheduler:0.0.23
    volumeMounts:
    - mountPath: /etc/kubernetes/scheduler.conf
      name: kubeconfig
      readOnly: true
    - mountPath: /etc/kubernetes/scheduler-config.yaml
      name: schedulerconfig
      readOnly: true
  volumes:
  - hostPath:
      path: /etc/kubernetes/scheduler.conf
      type: FileOrCreate
    name: kubeconfig
  - hostPath:
      path: /etc/kubernetes/scheduler-config.yaml
      type: FileOrCreate
    name: schedulerconfig

主要就是安装里的第二步我不太会操作,麻烦了

@xieydd
Copy link
Member

xieydd commented Mar 8, 2023

/etc/kubernetes/scheduler-config.yaml is mounted to container via hostpath, so you need edit the local file to change the apiversion. @zhimushan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants