Deploy your first Kubernetes application through CLI
Deploy your first Kubernetes app with ease using kubectl. This step-by-step guide provides a smooth introduction to cluster configuration, resource definition, deployment, and testing.
Written by
Technical Writer at Civo
Written by
Technical Writer at Civo
You're ready to deploy your first application to Kubernetes through the command line. This post will walk you through how to do exactly that, the tools you'll need, and a bit of the theory behind what is going on.
Prerequisites
- A verified Civo account
- The Civo CLI installed and authenticated (
civo apikey save <name> <key>) - kubectl installed
- Basic familiarity with containers
Creating a Civo Kubernetes cluster from the CLI
Since this is a command line guide, we'll create the cluster from the command line too:
civo kubernetes create hello-demo \--nodes 2 \--size g4s.kube.small \--create-firewall \--save --switch --wait
The --save --switch flags merge the new cluster's kubeconfig into your local config and make it the active context, so there is nothing to download by hand.
Confirm kubectl is talking to the new cluster:
kubectl get nodes
Two nodes should report Ready within a minute or two of the cluster coming up.
One more thing to note down. Every Civo cluster gets a DNS name of the form <cluster-id>.k8s.civo.com, and we'll use it to expose the application later. You can see it with:
civo kubernetes show hello-demo
Look for the DNS entry in the output and store the hostname we'll serve the app on:
HOST=hello-world.<your-cluster-id>.k8s.civo.com
The definition files
Kubernetes is declarative. You describe the state you want in YAML definition files, and the cluster works to make reality match. We'll declare three objects: a Deployment that runs the application, a Service that gives it a stable address inside the cluster, and an Ingress that exposes it to the outside world.
First, the Deployment. It runs two replicas of Civo's hello-world image:
cat > deployment.yaml <<'EOF'apiVersion: apps/v1kind: Deploymentmetadata:name: hello-worldspec:replicas: 2selector:matchLabels:app: hello-worldtemplate:metadata:labels:app: hello-worldspec:containers:- image: civo/docker-hello-world:latestname: hello-worldEOF
Next, the Service. It selects the pods by their app: hello-world label and gives them one stable port:
cat > service.yaml <<'EOF'apiVersion: v1kind: Servicemetadata:name: hello-worldlabels:app: hello-worldspec:ports:- name: "hello-world"port: 5000selector:app: hello-worldEOF
Finally, the Ingress. Civo Kubernetes ships with the Traefik ingress controller, and we select it with ingressClassName. Older guides used the kubernetes.io/ingress.class annotation for this, but that annotation is deprecated, spec.ingressClassName is the current field.
This block uses the HOST variable from earlier, so the hostname is filled in for you:
cat > ingress.yaml <<EOFapiVersion: networking.k8s.io/v1kind: Ingressmetadata:labels:app: hello-worldname: hello-world-ingressspec:ingressClassName: traefikrules:- host: ${HOST}http:paths:- backend:service:name: hello-worldport:number: 5000path: /pathType: "Prefix"EOF
Deploying the application
Apply all three files:
kubectl apply -f deployment.yamlkubectl apply -f service.yamlkubectl apply -f ingress.yamldeployment.apps/hello-world createdservice/hello-world createdingress.networking.k8s.io/hello-world-ingress created
Watch the pods come up:
kubectl get pods
Both replicas should reach Running. You can also confirm the Service and Ingress landed:
kubectl get svc,ingress
Testing the application
Point your browser at the hostname you stored earlier, or check from the terminal:
curl "http://${HOST}/"
You should see the application respond with a greeting.

Cleaning up
A running cluster costs money, so remove it when you are done experimenting:
civo kubernetes remove hello-demo
Conclusion
By following this guide, you have successfully deployed a simple application to Kubernetes by declaring the configuration you have specified in the deployment, service, and ingress files. This application runs on a Civo Kubernetes cluster, and is accessible via the web on its own subdomain.
From here, try changing the number of replicas in the Deployment and re-applying it, or deploy an image of your own in place of the hello-world container.

Technical Writer at Civo
Jubril Oyetunji is a DevOps engineer and technical writer with a strong focus on cloud-native technologies and open-source tools. His work centers on creating practical tutorials that help developers better understand platforms such as Kubernetes, NGINX, Rust, and Go.
As a contract technical writer, Jubril authored an extensive library of technical guides covering cloud-native infrastructure and modern development workflows. Many of his tutorials achieved strong search rankings, helping developers around the world learn and adopt emerging technologies.
Share this article
Further Reading
16 September 2024
Create a Kubernetes cluster using GitLab
22 July 2026