K8资源之endpoint资源&EP资源

1 endpoint资源概述

  • endpoint资源在K8S中用来表s示vc与后端 Pod 之间的连接关系的对象。当创建svc时,svc根据标签是否相同或svc名字是否和ep名字相同,把svc和ip关联上。

  • 删除svc时,会自动的删除同名的ep资源。

2 ep资源和svc的关联测试

yaml 复制代码
[root@master23107-ep]# cat 01-pod-svc.yaml 
apiVersion: v1
kind: Endpoints
metadata:
  name: wzy-web
subsets:
- addresses:
  - ip: 47.120.55.69
  # 如果一个ip地址下有多个port,需要指定名称
  ports:
  - port: 80
    name: http
  - port: 443
    name: https
---

apiVersion: v1
kind: Service
metadata:
  name: wzy-web
spec:
  type: ClusterIP
  ports:
  - port: 80
    # 由于ep使用了名称,所以这里必须指定一样的名称,否则无法关联
    name: http
  - port: 443
    name: https
bash 复制代码
[root@master23107-ep]# kubectl get ep,svc
NAME                   ENDPOINTS                          AGE
endpoints/kubernetes   10.0.0.231:6443                    7d7h
endpoints/wzy-web      47.120.55.69:80,47.120.55.69:443   8m13s

NAME                 TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
service/kubernetes   ClusterIP   10.200.0.1       <none>        443/TCP          7d7h
service/wzy-web      ClusterIP   10.200.254.222   <none>        80/TCP,443/TCP   5m34s

2.访问测试。我的公网服务器设置了80会临时跳转到443

bash 复制代码
[root@master23107-ep]# curl 10.200.254.222:80
<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.24.0</center>
</body>
</html>

[root@master23107-ep]# curl -k https://10.200.254.222:443
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta http-equiv="Cache-Control" content="no-transform" />

3.删除svc wzy-web测试,发现ep wzy-web真的不见了

bash 复制代码
[root@master23107-ep]# kubectl get ep,svc
NAME                   ENDPOINTS                          AGE
endpoints/kubernetes   10.0.0.231:6443                    7d7h
endpoints/wzy-web      47.120.55.69:80,47.120.55.69:443   23s

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/kubernetes   ClusterIP   10.200.0.1      <none>        443/TCP          7d7h
service/wzy-web      ClusterIP   10.200.92.170   <none>        80/TCP,443/TCP   23s
[root@master23107-ep]# kubectl delete svc wzy-web
service "wzy-web" deleted
[root@master23107-ep]# kubectl get ep
error: resource(s) were provided, but no name was specified
相关推荐
treesforest31 分钟前
数据包是如何找到回家路的?
网络·智能路由器·nat·ip归属地查询
Soneswy1 小时前
Linux系统篇--重定向与文件操作命令
linux
有毒的教程1 小时前
Linux底层存储路由配
linux·运维·网络
是真的小外套2 小时前
第9章:网络层安全协议 IPSec 学习笔记
网络·网络协议·tcp/ip
Linux系统运维工程师_郭主任3 小时前
运维人还在被拒offer?现在能考的,只有 RHCE 10.0。
linux
自养Agent3 小时前
MCP Server Boundary Audit Report
linux·服务器·人工智能·windows·大模型·llm
中屹指纹浏览器svip3 小时前
静态 IP和动态 IP,搭配指纹浏览器该怎么选?
网络·网络协议·tcp/ip·中屹指纹浏览器
深蓝电商API3 小时前
Docker+K8s部署爬虫:从单机到集群的完整路线
爬虫·docker·k8s
ITxiaobing20234 小时前
选型不踩坑:IPinfo 之外,IP 地址定位服务还有哪些可选项
网络·网络协议·tcp/ip
Coisinier4 小时前
docker命令管理镜像及容器
linux·运维·nginx·docker·容器·操作系统