有没有办法指定自定义 NodePort 服务YAML定义的端口? 我需要能够在我的配置文件中明确定义它。
有没有办法指定自定义 NodePort 服务YAML定义的端口? 我需要能够在我的配置文件中明确定义它。
您可以设置类型 NodePort
在你的 Service
部署。请注意,有一个 Node Port Range
使用该选项为您的API服务器配置 --service-node-port-range
(默认 30000-32767
)。您还可以通过设置来指定该范围内的端口 nodePort
属性下的 Port
对象,或系统将为您选择该范围内的端口。
那么一个 Service
指定的示例 NodePort
看起来像这样:
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
name: nginx
spec:
type: NodePort
ports:
- port: 80
nodePort: 30080
name: http
- port: 443
nodePort: 30443
name: https
selector:
name: nginx