APP | 01- APP后端设计—基础:HTTP协议

本文介绍了Web的概念及其三个核心特点,并详细解释了统一资源定位器(URL)的组成及HTTP协议的工作原理。

一、Web的概念:

Web的概念:Web是一种分布式应用架构。Web采用客户/服务器通信模式,客户与服务器之间用HTTP协议通信。


  • Web的3个特点
    • 用超文本技术HTML来表达信息,以及建立信息与信息的连接。
    • 用统一资源定位技术URL来实现网络上信息的精确定位。
    • 用网络应用层协议HTTP来规范浏览器与Web服务之间的通信过程。
  • URL简介

URL的格式为:应用层协议://主机IP地址或域名/资源所在路径/文件名

URL是(Uniform Resource Locator)的缩写,表示同意资源定位器,它是专为标识网络上的资源位置而设的一种编址方式。
URL一般由3个部分组成:
(1)应用层协议。
(2)主机IP地址或域名。
(3)资源所在路径/文件名。

二、HTTP协议

HTTP协议(Hypertext Transfer Protocol,超文本传输协议)。HTTP协议采用客户/服务器通信模式,服务器端为HTTP服务器(也称作Web服务器),客户端为HTTP客户程序。

最常见的HTTP客户程序:浏览器

这段配置文件描述了什么? # service for uat.use1 apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/name: tapocare-app name: tapocare-app-aps1 namespace: app-ipc spec: ports: - name: http-actuator port: 9090 protocol: TCP targetPort: http-actuator - name: grpc port: 8850 protocol: TCP targetPort: grpc - name: http # if the service has its custom port, please add it there. Reference the definition of the field 'service': {service.name}/helm/{service.name}/values.yaml in local environment port: 8080 protocol: TCP targetPort: http - name: istio-metric port: 15020 protocol: TCP targetPort: istio-metric selector: app.kubernetes.io/name: tapocare-app region: ap-southeast-1 type: ClusterIP --- apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/name: tapocare-app name: tapocare-app-use1 namespace: app-ipc spec: ports: - name: http-actuator port: 9090 protocol: TCP targetPort: http-actuator - name: grpc port: 8850 protocol: TCP targetPort: grpc - name: http # if the service has its custom port, please add it there. Reference the definition of the field 'service': {service.name}/helm/{service.name}/values.yaml in local environment port: 8080 protocol: TCP targetPort: http - name: istio-metric port: 15020 protocol: TCP targetPort: istio-metric selector: app.kubernetes.io/name: tapocare-app region: us-east-1 type: ClusterIP --- apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/name: tapocare-app name: tapocare-app-euw1 namespace: app-ipc spec: ports: - name: http-actuator port: 9090 protocol: TCP targetPort: http-actuator - name: grpc port: 8850 protocol: TCP targetPort: grpc - name: http # if the service has its custom port, please add it there. Reference the definition of the field 'service': {service.name}/helm/{service.name}/values.yaml in local environment port: 8080 protocol: TCP targetPort: http - name: istio-metric port: 15020 protocol: TCP targetPort: istio-metric selector: app.kubernetes.io/name: tapocare-app region: eu-west-1 type: ClusterIP
最新发布
11-06
这段配置文件定义了 **Kubernetes Service 资源**,用于为名为 `tapocare-app` 的应用在三个不同区域(`ap-southeast-1`、`us-east-1`、`eu-west-1`)创建服务端点。以下是详细解析: --- ### **1. 核心配置解析** #### (1)**基础信息** - **资源类型**:`Service`(Kubernetes 服务)。 - **命名空间**:`app-ipc`。 - **服务名称**: - `tapocare-app-aps1`(亚太区域,ap-southeast-1) - `tapocare-app-use1`(美国东部,us-east-1) - `tapocare-app-euw1`(欧洲西部,eu-west-1) - **服务类型**:`ClusterIP`(仅集群内可访问)。 #### (2)**端口配置** 每个服务暴露以下端口: | 端口名称 | 端口号 | 协议 | 目标端口(Pod) | 用途推测 | |------------------|--------|------|----------------------|-------------------------| | `http-actuator` | 9090 | TCP | `http-actuator` | Spring Boot Actuator(健康检查/监控) | | `grpc` | 8850 | TCP | `grpc` | gRPC 通信(微服务间调用) | | `http` | 8080 | TCP | `http` | 主应用 HTTP 端口 | | `istio-metric` | 15020 | TCP | `istio-metric` | Istio 监控指标采集 | #### (3)**Selector 选择器** - 通过标签选择器关联到后端 Pod: ```yaml selector: app.kubernetes.io/name: tapocare-app region: <region> # 动态匹配对应区域(如 ap-southeast-1) ``` - 只有同时满足 `app.kubernetes.io/name` 和 `region` 标签的 Pod 会被纳入服务流量。 --- ### **2. 关键设计意图** - **多区域部署**: 通过 `region` 标签区分不同地理区域的 Pod,实现**区域亲和性**(如美国用户的请求优先路由到 `use1` 的服务)。 - **端口标准化**: 所有区域的服务端口定义一致,便于统一管理(如监控配置复用)。 - **Istio 集成**: `istio-metric` 端口(15020)表明该服务已接入 Istio 服务网格,用于采集 Envoy 代理的监控数据。 --- ### **3. 典型使用场景** 1. **服务发现**: 集群内其他服务可通过 `tapocare-app-<region>.app-ipc.svc.cluster.local:8080` 访问对应区域的应用。 2. **流量路由**: 配合 Istio 的 `DestinationRule` 可实现区域感知的路由(如故障转移时跨区域调用)。 3. **监控对接**: - Actuator 端口(9090)提供健康检查接口。 - Istio 端口(15020)暴露 Prometheus 格式的指标。 --- ### **4. 注意事项** - **ClusterIP 限制**: 默认仅限集群内访问,若需外部访问需配合 Ingress 或 LoadBalancer。 - **端口冲突风险**: 确保 Pod 的容器端口定义与 Service 的 `targetPort` 严格匹配。 - **区域标签一致性**: Pod 必须正确打标 `region`,否则服务无法关联到后端---
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值