EDITORIAL words
When K8S first section we briefly mentioned that there are three operating modes Service: userspace / iptables / ipvs. And already know the current default in the new version it is ipvs, provided that in accordance with K8S when configured ipvs module.
Service Inventory
It has been known for short service in front of svc, so we can explain to view the list of direct parameters of resources in the following table:
svc | |||
---|---|---|---|
apiVersion | v1 | ||
kind | Service | ||
metadata | And like any other, name / labels / namespace, etc. | ||
spec | |||
clusterIP | IP defines Service, usually only when the configuration type is ClusterIP, and most of the time randomly assigned | ||
ports | |||
name | name | ||
nodePort | NodePort is used when the type, is larger than the native mapping port 30000 | ||
port | Service port | ||
targetPort | Pod port | ||
selector | Tag selector, direct key-value pairs | ||
sessionAffinity | Configuring allocation rules, support ClientIP / None | ||
type | ExternalName, ClusterIP, NodePort, LoadBalancer (typically a cloud) |
Simple list of resources Example:
apiVersion: v1 kind: Service metadata: name: redis-svc namespace: default spec: type: ClusterIP selector: app: redis role: logstore ports: - name: redis-port port: 6373 targetPort: 6379
Run View:
kubectl apply -f svc- demo.yaml
kubectl get svc
The results are shown:
Resource record parsing name format: SVC_NAME.NS_NAME.DOMAIN.LTD.
Such as the above named redis: redis.default.svc.cluster.local.
When we type using NodePort time, you can at ports configured inside nodePort parameters (more than 30,000 ports, do not specify the random).
Be sure that the port is useless to another service.
When we only CluterIP to None, the resource record resolves directly to the Pod. At this time, when re-use dig added resolved locally, the resource record needs to resolve the IP address of kube-dns.