0
0
Kubernetesdevops~10 mins

NodePort service type in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
ANodePort
BLoadBalancer
CClusterIP
DExternalName
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.
2fill in blank
medium

Complete 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'
A80
B30000
C8080
D22
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.
3fill in blank
hard

Fix 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'
AtargetPort
BportNumber
CtargetPortNumber
DcontainerPort
Attempts:
3 left
💡 Hint
Common Mistakes
Using portNumber instead of targetPort causes the service to fail.
Confusing containerPort with targetPort in the service spec.
4fill in blank
hard

Fill 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'
ATCP
BUDP
C80
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Using UDP protocol for HTTP services is incorrect.
Setting port to 443 without TLS configuration is confusing.
5fill in blank
hard

Fill 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'
ANodePort
BTCP
C80
DClusterIP
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.