kubernet pods port

  • Port: Port is the port number which makes a service visible to other services running within the same K8s cluster. In other words, in case a service wants to invoke another service running within the same Kubernetes cluster, it will be able to do so using port specified against “port” in the service spec file.
  • Target Port: Target port is the port on the POD where the service is running.
  • Nodeport: Node port is the port on which the service can be accessed from external users using [Kube-Proxy]

1. nodePort

外部机器可访问的端口。
比如一个Web应用需要被其他用户访问,那么需要配置type=NodePort,而且配置nodePort=30001,那么其他机器就可以通过浏览器访问scheme://node:30001访问到该服务,例如http://node:30001
 例如MySQL数据库可能不需要被外界访问,只需被内部服务访问,那么不必设置NodePort

2. targetPort

容器的端口(最根本的端口入口),与制作容器时暴露的端口一致(DockerFile中EXPOSE),例如docker.io官方的nginx暴露的是80端口。

3. port

kubernetes中的服务之间访问的端口,尽管mysql容器暴露了3306端口(参考https://github.com/docker-library/mysql/的DockerFile),但是集群内其他容器需要通过33306端口访问该服务,外部机器不能访问mysql服务,因为他没有配置NodePort类型

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,260评论 19 139
  • 前言 大家好~这是一直答应大家的内分享。 首先,好久不见给大家打个招呼~ 很抱歉迟到了这么久,从刚开始放假到现在,...
    13阿延阅读 4,455评论 0 1
  • 有会员问: 您好,老秘书,想跟您探讨一下穷同事的形象和命运。 最近我通过各种途径观察家里困难的同事,发现他们专职加...
    老秘书阅读 3,051评论 0 2
  • 走进文字里的千年浩瀚 姜彦伟 初秋逐渐染上了淡淡的愁色 黄花单薄了荷的身影 曾经盛开的 那圣洁的灵魂 在几...
    姜彦伟阅读 1,850评论 0 2

友情链接更多精彩内容