部署 statefulset 时提示: 0/3 nodes are available: 3 node(s) didn't have free ports for the requested pod ports. preemption: 0/3 nodes are available: 3 No preemption victims found for incoming pod
背景:一共 3 个节点,master+node1+node2
现象:前三个副本都正常(分别在三个节点上),启动第四个节点时就报错“0/3 nodes are available: 3 node(s) didn't have free ports for the requested pod ports. preemption: 0/3 nodes are available: 3 No preemption victims found for incoming pod”。
分析:看了下 Service 的 yaml ,我并没有配置 nodePort,所以理论上一个节点上可以部署多个相同 pod 。但是现在直接提示闲置端口数量不足~~~百思不得其解,本来就是新部署的 k8s 集群,没几个 pod ,不至于端口数量不对。google 也无解。
求大佬们解惑,不胜感激~~~
1
dier 2023-03-14 15:20:28 +08:00
敏感信息替换一下,把完整的 yaml 发出来看看吧
|
2
dong706 OP ```
--- apiVersion: v1 kind: Namespace metadata: name: cssp-cloud-component --- apiVersion: v1 kind: ConfigMap metadata: name: redis-config namespace: cssp-cloud-component data: update-node.sh: | #!/bin/sh REDIS_NODES="/data/nodes.conf" sed -i -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${MY_POD_IP}/" ${REDIS_NODES} exec "$@" redis.conf: |+ port 7001 protected-mode no cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 15000 #cluster-announce-ip ${MY_POD_IP} #cluster-announce-port 7001 #cluster-announce-bus-port 17001 logfile "/data/redis.log" --- ``` ``` --- apiVersion: apps/v1 kind: StatefulSet metadata: labels: app: redis-cluster name: redis-cluster namespace: default-component spec: replicas: 2 selector: matchLabels: app: redis-cluster serviceName: redis-cluster template: metadata: labels: app: redis-cluster spec: containers: - command: ["/bin/bash", "/usr/local/etc/redis/update-node.sh", "redis-server", "/usr/local/etc/redis/redis.conf"] #args: # - /usr/local/etc/redis/redis.conf # - --cluster-announce-ip # - "$(MY_POD_IP)" env: - name: MY_POD_IP valueFrom: fieldRef: fieldPath: status.podIP - name: TZ value: Asia/Shanghai image: 'redis:6.0.10' imagePullPolicy: IfNotPresent name: redis ports: - containerPort: 7001 hostPort: 7001 name: redis-port protocol: TCP volumeMounts: - mountPath: /data name: redis-cluster-data subPath: data readOnly: false - mountPath: /usr/local/etc/redis name: redis-config readOnly: false dnsPolicy: ClusterFirst volumes: - name: redis-config configMap: name: redis-config volumeClaimTemplates: - metadata: name: redis-cluster-data namespace: default-component spec: storageClassName: "default-storage-class" accessModes: ["ReadWriteMany"] resources: requests: storage: 1Gi --- apiVersion: v1 kind: Service metadata: labels: app: redis-cluster name: redis-cluster namespace: default-component spec: ports: - name: redis-port port: 7001 protocol: TCP targetPort: 7001 selector: app: redis-cluster type: ClusterIP clusterIP: None ``` @dier 其实没有敏感信息,就是部署 redis 集群时碰到的莫名其妙的错误...上面就是全部的脚本 |
3
dier 2023-03-14 15:59:59 +08:00
你用了一个 hostPort 的配置,这个配置会跟宿主机的端口绑定
|