我正在尝试为我部署的一个豆荚创建一个服务: NodePort,
下面的是我的服务定义
apiVersion: v1
kind: Service
metadata:
name: voting-service
labels:
name: voting-service
app: demo-voting-app
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
nodePort: 30004
selector:
name: voting-app-pod
app: demo-voting-app我正在使用下面的命令部署此服务
kubectl create -f voting-app-service.yaml 这里是错误
The Service "voting-service" is invalid: spec.ports[0].nodePort: Invalid value: 30004: provided port is already allocated因此,我试图通过netstat和lsof命令找到使用端口30004的服务,但却找不到使用该端口的任何服务。
➜ Voting-app kubectl create -f voting-app-service.yaml
The Service "voting-service" is invalid: spec.ports[0].nodePort: Invalid value: 30004: provided port is already allocated
➜ Voting-app sudo netstat -lntp | grep 30004
➜ Voting-app lsof -i :30004
➜ Voting-app 迷你版: v1.22.0 kubectl : 1.21版本
发布于 2021-08-02 09:07:09
正如@HarshManvar所提到的,您可以将服务文件中的端口更改为未分配的端口。
稍后,您会发现端口30004已经被分配,因为有一个使用该端口的荚:
kubectl得到svc \ grep 30004
https://stackoverflow.com/questions/68612689
复制相似问题