Tutorial: Deploy a Web App
This tutorial walks through deploying your own web application to the cluster.
What you need
- A containerized application (a Docker image, either public or pushed to a registry)
- SSH access to nst-n1, or access to NST Init
Option A: Using NST Init (easiest)
- Go to init.nstsdc.org
- Log in with your GitHub account
- Provide your app name and container image
- NST Init creates the Deployment, Service, and Ingress for you
- Your app is live at
<appname>.nstsdc.org
Option B: Using kubectl (manual)
This gives you full control over the configuration.
Step 1: Choose a namespace
You can use the shared apps namespace or create your own:
kubectl create namespace mynameStep 2: Create a Deployment
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
namespace: myname
spec:
replicas: 1
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: your-dockerhub-username/your-app:latest
ports:
- containerPort: 3000 # whatever port your app listens onApply it:
kubectl apply -f deployment.yamlStep 3: Create a Service
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-app
namespace: myname
spec:
selector:
app: my-app
ports:
- port: 80
targetPort: 3000 # must match containerPortkubectl apply -f service.yamlStep 4: Create an Ingress
# ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ing
namespace: myname
spec:
ingressClassName: traefik
rules:
- host: my-app.nstsdc.org
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app
port:
number: 80kubectl apply -f ingress.yamlStep 5: Verify
# Check pod is running
kubectl -n myname get pods
# Check service exists
kubectl -n myname get svc
# Check ingress is created
kubectl -n myname get ingress
# Test locally on the node
curl -i -H "Host: my-app.nstsdc.org" http://127.0.0.1
# Test from browser
# Visit: http://my-app.nstsdc.orgUsing a private container image
If your image is in a private registry (like GitHub Container Registry), you need to create an image pull secret:
kubectl -n myname create secret docker-registry ghcr-secret \
--docker-server=ghcr.io \
--docker-username=YOUR_GITHUB_USERNAME \
--docker-password=YOUR_GITHUB_TOKENThen reference it in your Deployment:
spec:
template:
spec:
imagePullSecrets:
- name: ghcr-secret
containers:
- name: my-app
image: ghcr.io/your-org/your-app:latestUsing the cluster's container registry
The cluster has a local container registry running at nst-n1:30500. You can push images directly:
# Tag your image
docker tag my-app:latest nst-n1.nstsdc.org:30500/my-app:latest
# Push
docker push nst-n1.nstsdc.org:30500/my-app:latestThen use nst-n1.nstsdc.org:30500/my-app:latest as your image in the Deployment.
Common mistakes
Wrong targetPort: The targetPort in the Service must match the port your app actually listens on inside the container. If your app runs on port 3000, set targetPort: 3000.
Image pull errors: If the pod shows ImagePullBackOff, the image name is wrong, the registry is unreachable, or authentication is missing for a private image.
Pod CrashLoopBackOff: Your application is crashing. Check the logs:
kubectl -n myname logs <pod-name>Ingress returns 404: Either the Ingress hostname does not match what you are requesting, or the Ingress is in a different namespace than the Service.