Kubernetes Service定义了这样一种抽象:一个Pod的逻辑分组,一种可以访问它们的策略 —— 通常称为微服务。这一组Pod能够被Service访问到,通常是通过Label Selector,Kubernetes Service定义了这样一种抽象:一个Pod的逻辑分组,一种可以访问它们的策略 —— 通常称为微服务。这一组Pod能够被Service访问到,通常是通过Label Selector
NodePort的原理在于在 node 上开了一个端口,将向该端口的流量导入到 kube-proxy,然后由 kube-proxy 进一步到给对应的 pod。把内部端口暴露出来,通过主机的ip+端口的方式可以被外部访问。
apiVersion: v1kind: Servicemetadata:name: mynodenamespace: defaultspec:type: NodePortselector:app: myapp #找到上面的deployment的spec.selector.matchLabels,也就是上面pod里面定义的模版里面的template.metadata.labels信息release: stabelports:- name: httpport: 80targetPort: 80
