Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a NodePort service in Kubernetes.
Kubernetes
apiVersion: v1 kind: Service metadata: name: my-service spec: type: [1] selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ClusterIP instead of NodePort will not expose the service outside the cluster.
LoadBalancer is used for cloud providers, not basic NodePort exposure.
✗ Incorrect
The type field set to NodePort exposes the service on each Node's IP at a static port.
2fill in blank
mediumComplete the code to specify the port number for the NodePort service.
Kubernetes
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
nodePort: [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting nodePort to 80 or 22 will cause errors because those ports are reserved.
Choosing a port outside the 30000-32767 range is invalid.
✗ Incorrect
The nodePort must be a port number between 30000 and 32767 for NodePort services.
3fill in blank
hardFix the error in the service definition by completing the missing field.
Kubernetes
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
[1]: 9376
nodePort: 30001 Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
portNumber instead of targetPort causes the service to fail.Confusing
containerPort with targetPort in the service spec.✗ Incorrect
The correct field to specify the port on the pod is targetPort.
4fill in blank
hardFill both blanks to complete the NodePort service ports configuration.
Kubernetes
ports: - protocol: [1] port: [2] targetPort: 8080 nodePort: 30010
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using UDP protocol for HTTP services is incorrect.
Setting port to 443 without TLS configuration is confusing.
✗ Incorrect
The protocol is usually TCP and the service port is commonly 80 for HTTP.
5fill in blank
hardFill all three blanks to complete the NodePort service YAML snippet.
Kubernetes
apiVersion: v1 kind: Service metadata: name: example-service spec: type: [1] selector: app: example ports: - protocol: [2] port: [3] targetPort: 5000 nodePort: 31000
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ClusterIP instead of NodePort will not expose the service externally.
Using UDP protocol for HTTP services is incorrect.
Setting port to 5000 instead of 80 changes the exposed port.
✗ Incorrect
The service type must be NodePort, protocol TCP, and port 80 to expose the app on port 80 via NodePort.