Challenge, Easy,  on  Kubernetes

Copy a File into a Running Pod to Serve a Custom NGINX Page

Scenario

A Pod named blackhole-3d is running in the space namespace using the nginx image. The Pod is already exposed via a NodePort Service on port 30088.

On the dev-machine, there is a file located at:

/home/laborant/blackhole/index.html

This file contains a simple 3D view of a black hole and must be served by the NGINX container as the default homepage.


Task

Copy the file from the dev-machine into the running Pod so that NGINX serves it as the default page.

  • Place the file in the correct directory used by NGINX to serve default content
  • View the simple 3D black hole page in the Blackhole-3D tab. If you still do not see the 3D black hole in the tab, refresh the Playground web page.

Do not create or modify any Pods or Services. Use imperative commands only.


Hint 1

NGINX serves files from /usr/share/nginx/html/ by default. The default homepage must be named index.html and placed in that directory. Use kubectl cp to copy files into a running Pod without modifying it.

Use kubectl cp to copy a file from the local machine into a running Pod. The syntax is kubectl cp <local-path> <namespace>/<pod-name>:<container-path>.

See the official docs: kubectl cp


Test Cases