这节讲一下 k8s 网络相关的资源类型 service 和 endpoint,关于这一块,这篇博客讲的不错:https://www.cnblogs.com/moonlight-lin/p/14553119.html 在前面创建的 POD 会发现一个问题,POD的 IP 地址不是固定不变的,对外提供服务时很不方面,使用 Service 资源可以解决这个问题。 Service 先创建一个deployment ...
我们可以直接编辑 Service 对象,添加 endpoints 字段引用 Endpoint 对象,也可以使用以下命令关联它们: ```shell kubectl expose service my-service --type=NodePort --target-port=80 ``` 这条命令会自动将 Service 和 Endpoint 对象关联起来。 至此,我们完成了创建 Endpoint 的全部流程。现在,新的 Service 对象就...
| 1 | 创建 Service | | 2 | 创建 Pod | | 3 | 确保 Pod 正常运行 | | 4 | 查看 Endpoint | ### 如何实现 ### 步骤 1:创建 Service 首先,我们需要创建一个 Service,指定 Service 的类型和端口以及选择器以匹配 Pod。以下是创建 Service 的 YAML 文件示例: ```yaml apiVersion: v1 kind: Serv...
kind: InitConfiguration localAPIEndpoint: advertiseAddress: 1.2.3.4 bindPort: 6443
Service创建:创建一个Service对象时,K8s会为该服务分配一个Cluster IP,并为其创建一个DNS记录。 Endpoint更新:K8s通过Label Selector将Service与匹配的Pod关联起来,并更新相应的Endpoints对象。 DNS解析:其他Pod可以通过Service名称或Endpoint的DNS记录来解析服务的IP地址。
功能一:与service做负载均衡 [root@k8s ~]# kubectl describe svc Name: kubernetes Namespace: default Labels: component=apiserver provider=kubernetes Annotations: <none> Selector: <none> Type: ClusterIP IP Family Policy: SingleStack IP Families: IPv4 ...
首先我们在本机(localhost)创建一个String Boot项目,确保localhost:8091/app可以访问: image.png 接着我们在minikube中创建EndPoints: apiVersion:v1kind:Endpointsmetadata:name:custom-endpointsubsets:-addresses:-ip:192.168.3.175ports:-port:8091 再为这个EndPoints创建一个Service,以便可以通过内部Pod找到这个Service,...
并不是service暴露一个外部ip,而是service转发外部ip+port,做法如下: 首先,创建endpoint: 其中10.2.1.1:8080是外部服务。 其次,创...
接下来创建 Service,其配置文件如下: 代码语言:javascript 复制 [root@k8s-master k8s]# cat httpd-service.ymlapiVersion:v1kind:Servicemetadata:name:httpd-servicespec:selector:run:httpdports:-protocal:TCPport:8080targetPort:80 ①v1是 Service 的apiVersion。