Kubernetes NodePort自定义端口
有没有办法在服务YAML定义中指定自定义的NodePort端口? 我需要能够明确地在我的configuration文件中定义它。
您可以在Service
Deployment中设置typesNodePort
。 请注意,为您的API服务器configuration了一个Node Port Range
,并带有选项--service-node-port-range
(默认为30000-32767
)。 您还可以通过在Port
对象下设置nodePort
属性来指定该范围内的Port
,否则系统将为您select该范围内的端口。
因此具有指定NodePort
的Service
示例如下所示:
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
有关NodePort的更多信息,请参阅本文档 。 有关configurationAPI服务器节点端口范围,请参阅此 。