Skip to main content
Welcome to this comprehensive lesson on setting up a Kubernetes test environment using PlayWithK8s.com. In this guide, you’ll quickly learn how to experiment with Kubernetes without needing your own infrastructure or a public cloud account by following a step-by-step procedure similar to our previous demos, with environment-specific adjustments.
The image is a slide titled "DEMO" outlining steps for setting up a Kubernetes test environment, creating pods, and services with ClusterIP and LoadBalancer.
When you navigate to PlayWithK8s.com, you’ll get free access to Kubernetes clusters with sessions lasting four hours. Simply click on “Add New Instance” to provision a cluster instance and begin your tests immediately.
The image shows a Kubernetes login page with a reCAPTCHA verification, featuring the Kubernetes logo and branding by Google.
Once logged in, you’ll notice a session timer counting down from four hours. This environment is ideal for quick tests and experiments.

Initializing the Kubernetes Cluster

Begin by initializing your Kubernetes cluster using the provided YAML definition files from previous demos. Execute the following commands on your provisioned instance:
After executing these commands, you should see output similar to the snippet below:
The second command sets up the networking for your cluster. In this demo, we’ll skip the optional deployment of the Kubernetes Dashboard. Once your master node is running and networking is configured, you are ready to deploy your application.

Cloning the Application Repository

Next, clone our GitHub repository containing the Kubernetes YAML files for a sample voting application. First, ensure that Git is installed on your instance:
Clone the repository using:
After cloning, verify the repository contents:
You should see files such as:
  • postgres-pod.yml
  • redis-pod.yml
  • result-app-pod.yml
  • voting-app-pod.yml
  • worker-app-pod.yml
  • postgres-service.yml
  • redis-service.yml
  • result-app-service.yml
  • voting-app-service.yml
The image shows a GitHub repository page for a Kubernetes example voting app, with options to clone or download the repository.

Deploying the Voting Application

Start by deploying the voting app pod, then expose it through a service. Create the voting app pod with:
Check the pod status:
If the pod shows as “Pending”, inspect further details with:
If you see an error about no available nodes that match the scheduling predicates, it may be because the master node is tainted by default.
Allow scheduling on the master node by removing the taint (replace <nodeName> with your actual node name, e.g., “node1”):
Once untainted, verify that the pod transitions to a Running state:
After confirming, create the service to expose the voting app:
Check that the service is running:
Click the link provided by PlayWithK8s.com to open the voting app in your browser.

Deploying the Remaining Application Components

Deploy additional components required by the voting app, including Redis, Postgres, the worker, and the result app pods, along with their corresponding services. Execute the following commands one after another:
Monitor the status of all pods:
A typical output might look like:
Once all pods are Running, check that the services are created:
Access the voting application via the external link. The interface should display the current vote counts (initially 50-50, before any votes are cast). Casting a vote (e.g., selecting “CATS” or “DOGS”) will update the results as the services communicate.
A web page titled "Cats vs Dogs!" with buttons to vote for either "CATS" or "DOGS," processed by a container ID.
The image shows a voting result with "Cats" at 0.0% and "Dogs" at 100.0%, with a total of 1 vote.

Deploying All Components Simultaneously

Instead of deploying resources individually, you can deploy all YAML files from the repository at once. Execute the following command from within the repository directory:
This command initiates all pods and services. Verify the deployment using:
A sample pods output might be:

Resetting Your Environment

After the demo, you can clean up by deleting all deployed resources simultaneously. Run the following command:
This command removes all specified resources (pods, services, etc.). Confirm deletion with:
The image features a dark background with hexagonal patterns and a central text box stating "Reset - Delete all at once" in white font.
A typical deletion output might be:

Thank you for following this demo on deploying an application using PlayWithK8s.com. We hope you found this guide helpful, and we look forward to supporting your next Kubernetes adventure.

Watch Video