我有一个健康的 k8s 集群。kube-apiserver 正在使用端口8443。然后我做类似下面的事情。我也创建/编辑一个服务并分配一个固定的 nodePort 8443。
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
nodePort: 8443
集群变得无法访问。如果我运行命令kubectl get pods
。它返回Unable to connect to the server: EOF
因为我需要运行 kubectl 命令来更改 nodePort。但我不能使用 kubectl。它变成了一个死循环。我有 2 个问题。
- 我该怎么做才能恢复我的 k8s 集群?
- 为什么 kube-apiserver 或其他组件不会阻止我将 nodePort 更改为8443?指示端口8443已在使用中。