Hi, have a question on creating custom scheduler. Getting the below error when c . . .

Subba:
Hi, have a question on creating custom scheduler. Getting the below error when creating custom scheduler. I have changed the port to 10251 instead of 10259. Not sure why am getting the below error

root@controlplane:~# kubectl logs -f my-scheduler -n kube-system
I0611 00:37:18.364066 1 serving.go:331] Generated self-signed cert in-memory
failed to create listener: failed to listen on 127.0.0.1:10259: listen tcp 127.0.0.1:10259: bind: address already in use

Below is the yaml file for customer scheduler

apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
component: kube-scheduler
tier: control-plane
name: my-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=false
- --scheduler-name=my-scheduler
image: <http://k8s.gcr.io/kube-scheduler:v1.20.0|k8s.gcr.io/kube-scheduler:v1.20.0>
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 8
httpGet:
host: 127.0.0.1
path: /healthz
port: 10251
scheme: HTTPS
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 15
name: my-scheduler
resources:
requests:
cpu: 100m
startupProbe:
failureThreshold: 24
httpGet:
host: 127.0.0.1
path: /healthz
port: 10251
scheme: HTTPS
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 15
volumeMounts:
- mountPath: /etc/kubernetes/scheduler.conf
name: kubeconfig
readOnly: true
hostNetwork: true
priorityClassName: system-node-critical
volumes:
- hostPath:
path: /etc/kubernetes/scheduler.conf
type: FileOrCreate
name: kubeconfig
status: {}

SaidBen:
try adding this flag then redeploy --secure-port=10251

Subba:
Thanks @SaidBen for the response. I have tried that as well…but getting the same issue with port 10251.

root@controlplane:~# kubectl logs -f my-scheduler -n kube-system
I0611 01:08:09.027109 1 serving.go:331] Generated self-signed cert in-memory
failed to create listener: failed to listen on 127.0.0.1:10251: listen tcp 127.0.0.1:10251: bind: address already in use

Subba:
Below is the code for spec

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=false
- --scheduler-name=my-scheduler
- --secure-port=10251

SaidBen:
change the port to 10280; it looks like that port 10251 is being used

Subba:
Will check that as well…but I dont see the port 10251 being used

root@controlplane:~# netstat -tulp | grep 10251
root@controlplane:~#
root@controlplane:~#

Subba:
Interestingly, 10280 worked…not sure what was the issue with 10251…thanks for the help @SaidBen

Karim Meslem:
I had that exact same issue, changed the port a few times until I found one that wasn’t being used.

Mayur Sharma:
@Subba I think, we always need to change following to make the custom scheduler work,

  1. make --port as 10280 (or any other available port)
  2. make secure port as 0, --secure-port=0 (as we do not want any https conenction)
  3. change the port (to 10280) and scheme (to HTTP) in readinessProbe and livenessProbe as well
  4. –scheduler-name=my-custom-scheduler
  5. –leader-elect=false