Challenge, Easy,  on  KubernetesSecurity

Expose the Snake Game via TLS Ingress

Scenario

A Snake game is already deployed in the snake namespace. The Deployment (snake-game, 3 replicas) and ClusterIP Service (snake-game, port 80 → 8080) are running and ready.

The platform team has already provisioned TLS for this workload using cert-manager. You do not need to create or modify any cert-manager resources. Your job is to create the Ingress that wires the HTTPS frontend to the running Service — referencing the existing snake-tls Secret in the tls block.

The cluster runs Traefik as the Ingress controller.


Task

Create an Ingress named snake-ingress in the snake namespace using ingressClassName: traefik. It must:

  • Route host snake.game.io, path / (Prefix) to the snake-game Service on port 80
  • Include a tls block referencing the existing snake-tls Secret for host snake.game.io
Snake game Ingress flow: Client → Traefik → snake-ingress → snake-game Service → Deployment

HTTPS traffic enters via Traefik, routed by snake-ingress to the snake-game Service using TLS from snake-tls Secret.

# Verify the game loads over HTTPS
curl -sk https://snake.game.io/ | head -5
Important

The environment is being set up. Please wait 1 minute before starting the tasks.

Important

Do not create or modify the selfsigned-issuer ClusterIssuer, the snake-tls Certificate, or the snake-tls Secret — these are pre-provisioned. All changes must be applied on cplane-01.


Hint 1 — Inspect what's already running

Before writing the Ingress, confirm that the Deployment, Service, and TLS Secret are all in place in the snake namespace:

kubectl get deployment,service,secret -n snake

Inspect the TLS Secret to understand what data it holds and how you will reference it in the Ingress tls block:

kubectl describe secret snake-tls -n snake

Documentation

Hint 2 — Ingress manifest structure

An Ingress with TLS requires both a rules block and a tls block. The rules block defines how traffic is routed to the Service. The tls block tells the Ingress controller which Secret to use for terminating HTTPS for a given hostname.

Use this skeleton as a starting point and fill in the correct values:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: <ingress-name>
  namespace: <namespace>
spec:
  ingressClassName: <controller>
  tls:
  - hosts:
    - <hostname>
    secretName: <tls-secret-name>
  rules:
  - host: <hostname>
    http:
      paths:
      - path: <path>
        pathType: <Prefix|Exact>
        backend:
          service:
            name: <service-name>
            port:
              number: <port>

Make sure the pathType is set to Prefix for the / path.

Documentation


⚒ Test Cases