我已经使用以下配置设置了NodePort服务:
wordpress-service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: wordpress
name: wordpress
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
app: wordpress
这足以从外部访问该服务,如果可以的话,现在如何访问该服务?我需要什么细节-以及如何确定它们-例如节点IP。
当您将服务定义为type时NodeIP
,集群中的每个节点都会将该端口代理到您的服务。如果您的节点可从Kubernetes集群外部访问,则您应该能够通过访问服务nodeIP:nodePort
。
要确定nodeIP
特定节点,可以使用kubectl get no <node> -o yaml
或kubectl describe no <node>
。该status.Addresses
领域将引起关注。一般来说,你会看到像场HostName
,ExternalIP
并InternalIP
在那里。
要确定nodePort
您的服务,可以使用kubectl get svc wordpress -o yaml
或kubectl describe svc wordpress
。这spec.ports.nodePort
是您需要的端口。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句