k8s Services
- kind: Service ,
Service-NodePort k8s-Obj-bind external node port to internal. NodePort is external port 30000-32767
apiVersion: v1 kind: Service metadata: name: myapp-service spec: type: NodePort ports: - targetPort: 80 ->POD port: 80 ->This service local ip port (Optional) nodePort: 30008 ->Node external port listening on host, same port on all Nodes! selector: app: myapp type: front-end
Service-!ClusterIP internal network, default type
apiVersion: v1 kind: Service metadata: name: back-end-service spec: type: ClusterIP << Default if not specified ports: - targetPort: 80 port: 80 selector: name: my-app type: back-end
Service-LoadBalancer - Configure external LB
apiVersion: v1 kind: Service metadata: name: myapp-service spec: type: Loadbalancer ports: - targetPort: 80 port: 80 nodePort: 30008 selector: name: my-app type: back-end