VOOZH about

URL: https://thenewstack.io/kubernetes-101-deploy-your-first-application-with-microk8s/

⇱ Kubernetes 101: Deploy Your First Application with MicroK8s - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-12-24 06:00:40
Kubernetes 101: Deploy Your First Application with MicroK8s
Kubernetes / Operations

Kubernetes 101: Deploy Your First Application with MicroK8s

How to deploy your first application to a Kubernetes cluster and then make that application accessible outside of the cluster.
Dec 24th, 2022 6:00am by Jack Wallen
👁 Featued image for: Kubernetes 101: Deploy Your First Application with MicroK8s

Kubernetes is challenging. Of that, there is no debate. Not only are there a lot of moving parts that go into deploying a container to a Kubernetes cluster, but so much can go wrong along the way. To complicate matters even further, deploying the Kubernetes cluster can be a hair-pulling affair.

That’s why tools like Canonical’s MicroK8s have been developed. With such software, the process of deploying a Kubernetes cluster is significantly less challenging, so you can focus more on getting up to speed with deploying applications and services to the cluster.

One of the many things that makes deploying applications and services to a Kubernetes cluster is accessing them. Unlike, say, Docker, when you deploy an application or service to a Kubernetes cluster, it’s not automatically available to your network. If you’re on a machine that’s a part of the cluster, you can certainly access that app or service, because that machine will have access to the subnet used by the cluster. Without a bit of extra trickery, that application and service is simply not available beyond the cluster. That means you have to manually make it available.

Again… a lot of moving parts.

I’ve already gone through the steps for installing Microk8s on Rocky Linux and then joining nodes to the controller. By adding the nodes, you create a cluster that your applications and services can be deployed to.

What I’m going to do now is show you how to deploy your first application to the cluster and then make that application accessible outside of the cluster. One thing to note is that deploying an application/service to a MicroK8s cluster is similar to that of any other Kubernetes distribution. The biggest difference to users is that the deployment requires the MicroK8s command, whereas other Kubernetes distributions do no have that requirement.

What You’ll Need

The only thing you’ll need for this is a running MicroK8s cluster of at least one controller and 2 nodes. These can be deployed to your data center, your test network, or a third-party cloud host. As long as the nodes are connected to the controller, you’re good to go.

If you’re unsure if the nodes are connected, log in to your controller and issue the command:

microk8s kubectl get nodes

You should see the controller and all of your attached nodes listed. If not, make sure to go through the steps to connect your nodes again.

How to Deploy Your First Application with MicroK8s

Log in to the MicroK8s controller. For this demonstration, we’ll deploy an NGINX web server application. We’ll name this deployment nginx-webserver and use the official NGINX container image for the deployment. The command for this is:

microk8s kubectl create deployment nginx-webserver --image=nginx

The output from that command should look like this:

deployment.apps/nginx-webserver created

Verify the deployment was successful with the command:

microk8s kubectl get pods

You should see something like this in the output:

nginx-webserver-67f557b648-4mfc6         1/1     Running             0          9m59s

Congratulations, your first pod has been deployed to the cluster. What is a pod? A Kubernetes pod is a collection of one or more containers and is the smallest unit of an application. Pods are generally composed of multiple, integrated containers but can also consist of a single container. In our instance above, we deployed a pod with a single container (NGINX).

At this point, the NGINX application is running but isn’t accessible. In order to make it accessible, we also have to deploy a service. What we’ll do here is expose our nginx-webserver deployment, using the type “NodePort” on port 80. What is NodePort? Simply put, a NodePort is an open port on every node connected to your cluster. Kubernetes routes incoming traffic on the NodePort to your deployed service or application.

To deploy the service, the command will look like this:

microk8s kubectl expose deployment nginx-webserver --type="NodePort" --port 80

The output of the command should look like this:

service/webserver exposed

If you attempt to access the running container on port 80, such as http://192.168.1.45, you’ll find it inaccessible. What gives? Well, Kubernetes maps internal port 80 to a random internal port. Before we can access the running web server, we have to find out what port it has been mapped to. For that, issue the command:

microk8s kubectl get svc nginx-webserver

The output should look something like this:

nginx-webserver   NodePort   10.152.183.105   <none>        80:31508/TCP   3m11s

As you can see, Kubernetes has mapped internal port 80 (the one being used by NGINX) to external port 31508 (the one being used by the Kubernetes cluster). So, if you point your web browser to 192.168.1.45:31508, you should see the NGINX welcome screen in your browser.

Of course, you would use the IP address of any one of your nodes. If, however, you use the IP address of your controller, the NGINX site won’t appear. Why? Because the controller deploys the container to the nodes, not to itself.

And that is all there is to deploy your first application to a Kubernetes cluster using MicroK8s.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
NGINX is a sponsor of The New Stack.
TNS owner Insight Partners is an investor in: Simply, Docker.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.