Exploring Kubernetes Pods with Meshery

Introduction

In this tutorial, we’ll learn the fundamentals of Pods, the smallest deployable units in the Kubernetes ecosystem. Using Meshery Playground, an interactive live cluster environment, we’ll perform hands-on labs to gain practical experience in deploying, managing, and understanding some of the concepts related to Pods.

NOTE: This tutorial demonstrates stand alone pods, i.e. pods not managed through deployments.

Prerequisites

  • Basic understanding of containerization and Kubernetes concepts.
  • Access to the Meshery Playground. If you don’t have an account, sign up at Meshery Playground.

Lab Scenario

Deploy and explore an NGINX pod in a Kubernetes cluster. Additionally, expose the pod through a service.

Objective

Learn how to create, manage, and explore Kubernetes Pods and Services within the context of a microservices architecture.

Steps

Access Meshery Playground

  • Log in to the Meshery Playground using your credentials. On successful login, you should be at the dashboard. Press the X on the Where do you want to start? popup to close it (if required).
  • Click Explore in the Cloud Native Playground tile to navigate to Kanvas.

NOTE: Kanvas is still in beta.

Create a simple stand-alone Pod

  1. In the Kanvas screen, rename the design from Untitled Design to a name of choice. This helps in identifying the design later easily.
  2. Click Components tab.
  3. Search for Pod in the list of components.
  4. Scroll down, select and drag the Pod component from the search results to the design canvas on the right.
  5. You should now have a pod in the design canvas for further configuration. It has a default name assigned to it. Click the pod component to load the configuration modal.
  6. Rename the pod, if necessary.

Add a container to the Pod

The pod at this stage does not have a container, so we will add one. This is similar to defining the containers in the spec: section of a YAML file. For this hands-on we will make some basic and necessary configurations only.

  1. Scroll down within the Pod configuration modal to the Containers section. Click + to add a container.
  2. Expand Containers-0.
  3. Next, fill out some of the required container specifications. Start by entering the container image, we will use nginx:latest for this exercise.
  4. Give the container a name.
  5. Additionally, we will also give it a label. This will server many advantages later in this exercise. To do so, click the label icon on the modal.
  6. Click + next to Labels.
  7. Set any label of choice. Preferably, give a unique label since the playground is a shared environment.
  8. Click outside to close the modal.

Validating and Deploying the Pod

The next step in this process is to validate the design, after which we can deploy it.

To do this, click Validate on the top.

This should show a pop-up with details such as the number of components, annotations and errors (if any).

Ensure there are no errors before deploying. To deploy, click the Deploy (1) tab in the pop-up modal and then click Deploy (2) again.

You should see a few alerts on the bottom right about the deployment.

Visualizing the Pod

To view the resources deployed we will use the Visualize section of the Kanvas. A view is created with necessary filters to show the relevant resources.

  1. Click Visualize to begin.
  2. Give the view a name (rename).
  3. Click the filter icon.
  4. Choose appropriate filters, for this hands-on choose the label that was set earlier during the pod creation. This helps in showing limited resources in the view.

Click the filter icon again to close. This should show a filtered view with only your resources something similar to the screenshot below:

Pod state and information

Select the Details tab and select the pod from the view to view details about the pod. The details tab shows the following:

  • Pod state, a green check means running.
  • The namespace where the pod is running.
  • Image details of the container in the pod like image tag and name.
  • It also shows the number of restarts and uptime.

Connecting to the Pods / containers

Meshery Playground provides terminal capabilities to connect to the container(s) and stream logs. The following steps demonstrate this.

  1. Select the Pod (or container). If you have multiple containers in a pod, select a container.
  2. Select the Actions tab to the right.
  3. Click Open Interactive Terminal. This displays the terminal on the screen.
  4. To view streaming logs, click Stream Container Logs to the right and an additional logs view is added to the terminal window.

Exposing a Pod with a Service

NOTE: As of this writing, Meshery Playground supports only NodePort at the moment.

  1. Go back to the Design view.
  2. From Components search for service and the drag the service component to the design canvas.
  3. Click the service component to load the configuration modal.
  4. Rename it if required.
  5. Change Type to NodePort for this tutorial.
  6. Click + to add a Port.
  7. Expand the Ports-0 service port to make changes.
  8. For this tutorial we set the Target Port value to 80.
  9. We also set the Port value to 80.
  10. Click + next to Selector and add the key value pair app:9870. This is the same pair that is used as label in the Pod.
  11. Finally label this service too, with the same key value pair. This also helps in filtering resources specific to us in the Visualize screen.
  12. Move your mouse over the service component until you see the green dots on all four sides. Move your mouse over one of the green dots to reveal an arrow, then click the arrow. Select Network option, and then move your mouse to the pod to create the relationship. It should look similar to the screenshot below:
  13. Validate the design. Click Validate from the top menu to do so.

Updating the deployment

In order to apply the updated design (which contains a service now), we must undeploy and deploy the design.

  • Select Undeploy and click Undeploy again.
  • To deploy the updated components, select Deploy and click Deploy.

Deleting and Recreating Pods

To delete the resources such as Pods, use the Undeploy option from the Design view.

To recreate, use the Deploy option.

Conclusion

Congratulations! You’ve successfully completed the lab on exploring Kubernetes Pods using Meshery Playground. This hands-on experience should have provided valuable insights into the deployment, management, and interaction with Pods in a Kubernetes environment. Continue exploring more scenarios in the Meshery Playground to enhance your skills.

Suggested Reading