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
- In the Kanvas screen, rename the design from Untitled Design to a name of choice. This helps in identifying the design later easily.
- Click Components tab.
- Search for Pod in the list of components.
- Scroll down, select and drag the Pod component from the search results to the design canvas on the right.
- 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.
- 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.
- Scroll down within the Pod configuration modal to the Containers section. Click + to add a container.
- Expand Containers-0.
- Next, fill out some of the required container specifications. Start by entering the container image, we will use nginx:latest for this exercise.
- Give the container a name.
- 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.
- Click + next to Labels.
- Set any label of choice. Preferably, give a unique label since the playground is a shared environment.
- 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.
- Click Visualize to begin.
- Give the view a name (rename).
- Click the filter icon.
- 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.
- Select the Pod (or container). If you have multiple containers in a pod, select a container.
- Select the Actions tab to the right.
- Click Open Interactive Terminal. This displays the terminal on the screen.
- 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.
- Go back to the Design view.
- From Components search for service and the drag the service component to the design canvas.
- Click the service component to load the configuration modal.
- Rename it if required.
- Change Type to NodePort for this tutorial.
- Click + to add a Port.
- Expand the Ports-0 service port to make changes.
- For this tutorial we set the Target Port value to 80.
- We also set the Port value to 80.
- 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.
- Finally label this service too, with the same key value pair. This also helps in filtering resources specific to us in the Visualize screen.
- 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:
- 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
- Deploying Apache Cassandra with a StatefulSet in Meshery Playground - Deploy Apache Cassandra with a StatefulSet using Meshery Playground in an interactive live cluster environment.
- Exploring Kubernetes CronJobs - In this tutorial, we will explore how to use Meshery Playground, an interactive live cluster environment, to perform hands-on labs for managing Kubernetes CronJobs.
- Understanding Kubernetes ConfigMaps and Secrets with Meshery - In this tutorial, we will explore how to effectively use Kubernetes ConfigMaps and Secrets for managing configuration data and sensitive information. Leveraging Meshery Playground, an interactive live cluster environment, we'll perform hands-on labs to understand the practical aspects of working with ConfigMaps and Secrets in Kubernetes.
- Publishing Meshery Designs to ArtifactHub - Step by step example for how to export Meshery Designs and publish them to an ArtifactHub repository.
- Deploying WordPress and MySQL with Persistent Volumes with Meshery - Deploy a WordPress site and a MySQL database with Persistent Volumes using Meshery Playground in an interactive live cluster environment.