spec.ports[0].name: Required value
spec.ports[0].name: Required value这里复现一下这个问题,并记录一下解决方式。我用kubernetes官网一个最简单的yaml做示例vi MyApp.yamlapiVersion: v1kind: Servicemetadata:name: my-servicespec:selector:app: MyAppports:- protocol: TCPport: 80
·
spec.ports[0].name: Required value
这里复现一下这个问题,并记录一下解决方式。
我用kubernetes官网一个最简单的yaml做示例
vi MyApp.yaml
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
如果用了create或者edit去创建或修改某个资源
~]# kubectl create -f MyApp.yaml
service/my-service created
或
kubectl edit svc my-service
再用apply就会报错
~]# kubectl apply -f MyApp.yaml
Warning: kubectl apply should be used on resource created by either kubectl create --save-config or kubectl apply
The Service "my-service" is invalid:
* spec.ports[0].name: Required value
* spec.ports[1].name: Required value
解决方法就是加–force
~]# kubectl apply -f MyApp.yaml --force
service/my-service configured
建议create、edit命令慎用。
更多推荐
已为社区贡献8条内容
所有评论(0)