Complete the code to create a LoadBalancer service in Kubernetes.
apiVersion: v1 kind: Service metadata: name: my-service spec: type: [1] selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
The LoadBalancer type exposes the service externally using a cloud provider's load balancer.
Complete the code to specify the port that the LoadBalancer service listens on.
spec:
type: LoadBalancer
ports:
- protocol: TCP
port: [1]
targetPort: 8080Port 80 is the standard HTTP port commonly used for web services.
Fix the error in the service type to correctly expose the service externally.
spec: type: [1] ports: - port: 80 targetPort: 8080
Only LoadBalancer type creates an external load balancer for the service.
Fill both blanks to complete the LoadBalancer service YAML with correct port and protocol.
spec:
type: LoadBalancer
ports:
- protocol: [1]
port: [2]
targetPort: 8080The protocol is usually TCP and the port is commonly 80 for HTTP services.
Fill all three blanks to create a LoadBalancer service with selector, port, and protocol.
apiVersion: v1
kind: Service
metadata:
name: my-loadbalancer
spec:
type: LoadBalancer
selector:
app: [1]
ports:
- protocol: [2]
port: [3]
targetPort: 8080The selector matches pods labeled 'MyApp'. The protocol is TCP and the service listens on port 80.