Bird
0
0

Which of the following is the correct basic syntax to define an Ingress resource in YAML?

easy📝 Configuration Q12 of 15
Kubernetes - Ingress
Which of the following is the correct basic syntax to define an Ingress resource in YAML?
AapiVersion: v1\nkind: Service\nmetadata:\n name: example-ingress\nspec:\n selector:\n app: example\n ports:\n - protocol: TCP\n port: 80\n targetPort: 9376
BapiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n name: example-ingress\nspec:\n rules:\n - host: example.com\n http:\n paths:\n - path: /\n pathType: Prefix\n backend:\n service:\n name: example-service\n port:\n number: 80
CapiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: example-ingress\nspec:\n replicas: 3\n selector:\n matchLabels:\n app: example
DapiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n name: example-ingress\nspec:\n rules:\n - host: example.com\n tcp:\n ports:\n - port: 80\n backend:\n serviceName: example-service\n servicePort: 80
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct Ingress syntax

    Ingress uses apiVersion networking.k8s.io/v1, kind Ingress, and defines rules with host and http paths.
  2. Step 2: Check options for correct fields

    apiVersion: networking.k8s.io/v1\nkind: Ingress\nmetadata:\n name: example-ingress\nspec:\n rules:\n - host: example.com\n http:\n paths:\n - path: /\n pathType: Prefix\n backend:\n service:\n name: example-service\n port:\n number: 80 matches the correct structure with service name and port under backend. apiVersion: v1\nkind: Service\nmetadata:\n name: example-ingress\nspec:\n selector:\n app: example\n ports:\n - protocol: TCP\n port: 80\n targetPort: 9376 is a Service definition. The other options define a Deployment or incorrectly use a tcp field.
  3. Final Answer:

    apiVersion: networking.k8s.io/v1 kind: Ingress spec: rules: - host: example.com http: paths: - path: / pathType: Prefix backend: service: name: example-service port: number: 80 -> Option B
  4. Quick Check:

    Ingress YAML syntax = A [OK]
Quick Trick: Ingress YAML uses rules with host and http paths [OK]
Common Mistakes:
  • Confusing Service or Deployment YAML with Ingress
  • Using tcp instead of http in rules
  • Incorrect apiVersion or kind for Ingress

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes