content/guides/angular/deploy.md
Before you begin, make sure you’ve completed the following:
New to Kubernetes?
Visit the Kubernetes basics tutorial to get familiar with how clusters, pods, deployments, and services work.
This section guides you through deploying your containerized Angular application locally using Docker Desktop’s built-in Kubernetes. Running your app in a local Kubernetes cluster closely simulates a real production environment, enabling you to test, validate, and debug your workloads with confidence before promoting them to staging or production.
Follow these steps to define your deployment configuration:
In the root of your project, create a new file named: angular-sample-kubernetes.yaml
Open the file in your IDE or preferred text editor.
Add the following configuration, and be sure to replace {DOCKER_USERNAME} and {DOCKERHUB_PROJECT_NAME} with your actual Docker Hub username and repository name from the previous Automate your builds with GitHub Actions.
apiVersion: apps/v1
kind: Deployment
metadata:
name: angular-sample
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: angular-sample
template:
metadata:
labels:
app: angular-sample
spec:
containers:
- name: angular-container
image: {DOCKER_USERNAME}/{DOCKERHUB_PROJECT_NAME}:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
resources:
limits:
cpu: "500m"
memory: "256Mi"
requests:
cpu: "250m"
memory: "128Mi"
---
apiVersion: v1
kind: Service
metadata:
name: angular-sample-service
namespace: default
spec:
type: NodePort
selector:
app: angular-sample
ports:
- port: 8080
targetPort: 8080
nodePort: 30001
This manifest defines two key Kubernetes resources, separated by ---:
Deployment
Deploys a single replica of your Angular application inside a pod. The pod uses the Docker image built and pushed by your GitHub Actions CI/CD workflow
(refer to Automate your builds with GitHub Actions).
The container listens on port 8080, which is typically used by Nginx to serve your production Angular app.
Service (NodePort)
Exposes the deployed pod to your local machine.
It forwards traffic from port 30001 on your host to port 8080 inside the container.
This lets you access the application in your browser at http://localhost:30001.
[!NOTE] To learn more about Kubernetes objects, see the Kubernetes documentation.
Follow these steps to deploy your containerized Angular app into a local Kubernetes cluster and verify that it’s running correctly.
In your terminal, navigate to the directory where your angular-sample-kubernetes.yaml file is located, then deploy the resources using:
$ kubectl apply -f angular-sample-kubernetes.yaml
If everything is configured properly, you’ll see confirmation that both the Deployment and the Service were created:
deployment.apps/angular-sample created
service/angular-sample-service created
This confirms that both the Deployment and the Service were successfully created and are now running inside your local cluster.
Run the following command to check the status of your deployment:
$ kubectl get deployments
You should see output similar to the following:
NAME READY UP-TO-DATE AVAILABLE AGE
angular-sample 1/1 1 1 14s
This confirms that your pod is up and running with one replica available.
Check if the NodePort service is exposing your app to your local machine:
$ kubectl get services
You should see something like:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
angular-sample-service NodePort 10.100.185.105 <none> 8080:30001/TCP 1m
This output confirms that your app is available via NodePort on port 30001.
Open your browser and navigate to http://localhost:30001.
You should see your production-ready Angular Sample application running — served by your local Kubernetes cluster.
Once you're done testing, you can delete the deployment and service using:
$ kubectl delete -f angular-sample-kubernetes.yaml
Expected output:
deployment.apps "angular-sample" deleted
service "angular-sample-service" deleted
This ensures your cluster stays clean and ready for the next deployment.
In this section, you learned how to deploy your Angular application to a local Kubernetes cluster using Docker Desktop. This setup allows you to test and debug your containerized app in a production-like environment before deploying it to the cloud.
What you accomplished:
kubectl apply to deploy the application locallyhttp://localhost:30001Explore official references and best practices to sharpen your Kubernetes deployment workflow:
kubectl CLI reference – Manage Kubernetes clusters from the command line.