Skip to content

Deploy your first app

This guide takes a container image and gets it running on Kubernetes as a Deployment, then exposes it inside the cluster with a Service. The steps work on any conformant cluster; we use a paasbox cluster as the example.

Download your cluster’s kubeconfig and confirm you can reach it:

Terminal window
export KUBECONFIG=~/Downloads/paasbox-kubeconfig.yaml
kubectl get nodes

You should see your nodes listed as Ready.

Keep your app’s objects together in their own namespace:

Terminal window
kubectl create namespace demo

A Deployment runs and supervises your container, replacing Pods that crash or get rescheduled. Save this as deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
name: web
namespace: demo
spec:
replicas: 2
selector:
matchLabels: { app: web }
template:
metadata:
labels: { app: web }
spec:
containers:
- name: web
image: nginxdemos/hello:plain-text
ports:
- containerPort: 80
resources:
requests: { cpu: 50m, memory: 64Mi }
limits: { cpu: 250m, memory: 128Mi }

Apply it and watch the Pods come up:

Terminal window
kubectl apply -f deployment.yaml
kubectl -n demo get pods -w

Always set resource requests. They tell the scheduler how much CPU and memory your Pods need, which is what lets the cluster pack workloads efficiently — and on paasbox, that efficiency is where your savings come from.

A Service gives your Pods one stable address inside the cluster, load-balanced across replicas:

apiVersion: v1
kind: Service
metadata:
name: web
namespace: demo
spec:
selector: { app: web }
ports:
- port: 80
targetPort: 80
Terminal window
kubectl apply -f service.yaml

Port-forward the Service to your machine and hit it:

Terminal window
kubectl -n demo port-forward service/web 8080:80
# in another terminal:
curl localhost:8080

You should get a response from the app. 🎉

  • Run more copies and let the cluster scale them: Scale & autoscale workloads.
  • To serve traffic from the public internet, add an Ingress (or a Gateway) in front of the Service — a future guide will cover this end to end.
Terminal window
kubectl delete namespace demo