Container Orchestration with Kubernetes
⏱
2 mins remaining
Kubernetes Networking
A brief overview of various types of services in Kubernetes:
- ClusterIP Service: Exposes the Service on a cluster-internal IP. It’s accessible only within the cluster.
apiVersion: v1
kind: Service
metadata:
name: my-clusterip-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIP
- NodePort Service: Exposes the Service on each Node’s IP at a static port. It’s accessible externally using the Node’s IP and the specified NodePort.
apiVersion: v1
kind: Service
metadata:
name: my-nodeport-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30001
type: NodePort
- LoadBalancer Service: Exposes the Service externally using a cloud provider’s load balancer. The service gets an externally-accessible IP.
apiVersion: v1
kind: Service
metadata:
name: my-loadbalancer-service
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: LoadBalancer
- ExternalName Service: Maps the service to the contents of the externalName field (e.g., a DNS name).
apiVersion: v1
kind: Service
metadata:
name: my-externalname-service
spec:
externalName: my.database.example.com
ports:
- protocol: TCP
port: 3306
targetPort: 3306
type: ExternalName