0
0
Microservicessystem_design~10 mins

Pods and deployments for services in Microservices - Interactive Code Practice

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

Complete the code to specify the number of replicas in a Kubernetes deployment.

Microservices
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-service
spec:
  replicas: [1]
  selector:
    matchLabels:
      app: my-service
Drag options to blanks, or click blank then click option'
A0
B5
C3
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting replicas to 0 stops all pods.
Using a string instead of a number.
2fill in blank
medium

Complete the code to define the container image in the pod template.

Microservices
spec:
  template:
    metadata:
      labels:
        app: my-service
    spec:
      containers:
      - name: my-service-container
        image: [1]
Drag options to blanks, or click blank then click option'
Amy-service:1.0
Bnginx:latest
Cubuntu:20.04
Dredis:alpine
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic image like nginx instead of the service image.
Forgetting to specify the image tag.
3fill in blank
hard

Fix the error in the deployment selector to correctly match the pod labels.

Microservices
spec:
  selector:
    matchLabels:
      app: [1]
  template:
    metadata:
      labels:
        app: my-service
Drag options to blanks, or click blank then click option'
Aapp-service
Bservice-app
Cmy-service
Dmyapp
Attempts:
3 left
💡 Hint
Common Mistakes
Using different label names in selector and pod template.
Typos in label values.
4fill in blank
hard

Fill both blanks to define a service that exposes the deployment on port 80 and targets container port 8080.

Microservices
apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  selector:
    app: my-service
  ports:
  - protocol: TCP
    port: [1]
    targetPort: [2]
Drag options to blanks, or click blank then click option'
A80
B8080
C443
D3000
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping port and targetPort values.
Using a port not exposed by the container.
5fill in blank
hard

Fill all three blanks to create a deployment with 3 replicas, using the image 'my-service:2.0', and label the pods with 'app: my-service'.

Microservices
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-service
spec:
  replicas: [1]
  selector:
    matchLabels:
      app: [2]
  template:
    metadata:
      labels:
        app: [3]
    spec:
      containers:
      - name: my-service-container
        image: my-service:2.0
Drag options to blanks, or click blank then click option'
A3
Bmy-service
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching selector and pod labels.
Setting replicas to 1 instead of 3.