- Pod의 containerPort에 name 을 붙이면, service 에서 targetPort로 해당 name을 사용할 수 있다.
EndpointSlice
- EndpointSlice contains references to a set of network endpoints. The control plane automatically creates EndpointSlices for any Kubernetes Service that has a selector specified.
- By default, the control plane creates and manages EndpointSlices to have no more than 100 endpoints each. You can configure this with the --max-endpoints-per-slice kube-controller-manager flag, up to a maximum of 1000.
- EndpointSlices can act as the source of truth for kube-proxy when it comes to how to route internal traffic.
Selector 없는 Service
- 외부의 DB에 접근할 때
- 다른 namespace나 다른 cluster에 접근할 때
- kubernetes migration할 때
- Selector 가 없는 service는 EndpointSlice를 control plane에서 직접 생성해주지 않아 수동으로 생성해줘야 함
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: my-service-1 # by convention, use the name of the Service
# as a prefix for the name of the EndpointSlice
labels:
# You should set the "kubernetes.io/service-name" label.
# Set its value to match the name of the Service
kubernetes.io/service-name: my-service
addressType: IPv4
ports:
- name: '' # empty because port 9376 is not assigned as a well-known
# port (by IANA)
appProtocol: http
protocol: TCP
port: 9376
endpoints:
- addresses:
- "10.4.5.6"
- addresses:
- "10.1.2.3"