Kubenete study notes (Service)
2021-04-09 15:26
标签:oss types fqdn ubi mes confirm benet config orm Ways to create service: kubectl exec [pod name] -- [command name] to execute command within pod Discover service: Service endpoint: Exposing service to external client: Need to open firewall to access node Use spec: externalTrafficPolicy: local to instruct kubenete use to use pod on node receives the request, preventing extra hop but may not load balance evenly. 2.Create a loadBalancer service External-IP = fixed. Node port can be assigned automatically No need to open firewall 3.Create an ingress service A single ingress service can be used for multiple pods. Host path of the request determines which service the request is forwarded to. The Ingress controller didn’t forward the request to the service. It only used it to select a pod. Readiness probe: Headless service: Troubleshot service: Kubenete study notes (Service) 标签:oss types fqdn ubi mes confirm benet config orm 原文地址:https://blog.51cto.com/shadowisper/2476302
Kubectl expose created a Service resource with the same pod selector as the one
used by the ReplicationController
Kubectl create with service specs apiVersion: v1
kind: Service
metadata:
name: kubia
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: kubia
Kubenete service only supports 2 types of session affinity (none/client ip), since it deals with TCP/UDP packet, it does not know cookie
apiVersion: v1
kind: Endpoints
metadata:
name: external-service
subsets:
- addresses:
- ip: 11.11.11.11
- ip: 22.22.22.22
ports:
- port: 80
apiVersion: v1
kind: Service
metadata:
name: external-service
spec:
type: ExternalName
externalName: someapi.somecompany.com
ports:
- port: 80
1.Create a nodePort service External-IP = nodes indicates that service is accessible through the IP address of any cluster node [node ip]:[node port] or [cluster ip]:[port] spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
nodePort: 30123
Client’s IP is not visible to the pod
Find out node’s external ip: kubectl get nodes -o jsonpath=‘{.items[].status.addresses[?(@.type=="ExternalIP")].address}‘spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kubia
spec:
rules:
- host: kubia.example.com
http:
paths:
- path: /
backend:
serviceName: kubia-nodeport
servicePort: 80
Performing DNS lookup in kubenetes: kubectl run dnsutils --image=tutum/dnsutils --generator=run-pod/v1 --command -- sleep infinity
kubectl exec dnsutils nslookup service name
文章标题:Kubenete study notes (Service)
文章链接:http://soscw.com/essay/73372.html