Some understanding of k8s service

  • Service is an abstract concept that defines the logical collection of multiple pods of a service and the strategy for accessing pods. Generally, services are called microservices.

For example, a service a runs 3 pods, how does the b service access the pods of the a service, the ip of the pod is not persistent and will change after restarting.
At this time, service b can access the service bound to service a. The service information is fixed and told to b in advance. The service is bound to the pod of service a through the Label Selector. No matter how the pod of a changes, it is transparent to b. of

kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9376
The targetPort port is the port exposed by the service. Anyone accessing port 9376 will be mapped to port 80 of the backend pod by the service.
  • Each node in the k8s cluster runs a component of kube-proxy, which is actually a proxy layer responsible for implementing services

There are two proxy modes

  1. userspace 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325306492&siteId=291194637