Bird
0
0

Which of the following is the correct minimal YAML snippet to define a ReplicaSet with 3 replicas?

easy📝 Configuration Q12 of 15
Kubernetes - ReplicaSets and Deployments
Which of the following is the correct minimal YAML snippet to define a ReplicaSet with 3 replicas?
AapiVersion: apps/v1\nkind: ReplicaSet\nmetadata:\n name: my-rs\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: myapp\n template:\n metadata:\n labels:\n app: myapp\n spec:\n containers:\n - name: nginx\n image: nginx
BapiVersion: v1\nkind: ReplicaSet\nmetadata:\n name: my-rs\nspec:\n replicas: 3\n selector:\n app: myapp\n template:\n metadata:\n labels:\n app: myapp\n spec:\n containers:\n - name: nginx\n image: nginx
CapiVersion: apps/v1\nkind: ReplicaSet\nmetadata:\n name: my-rs\nspec:\n replicas: three\n selector:\n matchLabels:\n app: myapp\n template:\n metadata:\n labels:\n app: myapp\n spec:\n containers:\n - name: nginx\n image: nginx
DapiVersion: apps/v1\nkind: ReplicaSet\nmetadata:\n name: my-rs\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: myapp\n template:\n metadata:\n labels:\n app: otherapp\n spec:\n containers:\n - name: nginx\n image: nginx
Step-by-Step Solution
Solution:
  1. Step 1: Check apiVersion and kind

    ReplicaSet requires apiVersion: apps/v1 and kind: ReplicaSet. The option with apiVersion: v1 is invalid.
  2. Step 2: Validate replicas and selector-template match

    Replicas must be an integer like 3, not string 'three'. Selector labels must match template labels exactly (one option has template app: otherapp mismatch). Only one option has all correct: apps/v1, replicas: 3, matching labels with proper structure.
  3. Final Answer:

    Correct YAML with apiVersion apps/v1, replicas: 3, matching selector and template labels -> Option A
  4. Quick Check:

    YAML syntax + matching labels = D [OK]
Quick Trick: Match selector labels exactly with template labels [OK]
Common Mistakes:
  • Using wrong apiVersion
  • Setting replicas as string instead of number
  • Mismatching selector and template labels

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes