This repository contains a demo project created as part of my DevOps studies in the TechWorld with Nana – DevOps Bootcamp.
https://www.techworld-with-nana.com/devops-bootcamp
Demo Project: Deploy NodeJS application in K8s cluster from private Docker registry
Technologies used: Kubernetes, Helm, AWS ECR, Docker
Project Description:
- Create Secret for credentials for the private Docker registry
- Configure the Docker registry secret in application Deployment component
- Deploy web application image from AWS ECR in K8s cluster
Complete the previous demo project first. You must have a Docker image pushed to your private AWS ECR registry. See aws-module-9.5 for setup instructions.
- AWS CLI configured with an
ecrprofile kubectlinstalled locally- A DigitalOcean account with Kubernetes access
Provision a managed Kubernetes cluster through the DigitalOcean dashboard:
Download the kubeconfig file from DigitalOcean, then configure access:
chmod 400 k8s-id-kubeconfig.yaml
export KUBECONFIG=k8s-id-kubeconfig.yamlVerify the connection:
kubectl cluster-info
kubectl get nodesYou should see the cluster endpoint and node(s) listed as Ready.
Kubernetes needs credentials to pull images from your private AWS ECR registry. Choose one of the options below.
kubectl create secret docker-registry ecr-secret \
--docker-server=<aws_account_id>.dkr.ecr.<region>.amazonaws.com \
--docker-username=AWS \
--docker-password=$(aws ecr get-login-password --profile ecr)Note
Replace <aws_account_id> and <region> with your actual AWS account ID and region (e.g., us-east-1).
- Get your ECR password:
aws ecr get-login-password --profile ecr- Create a Docker
config.jsonfile:
{
"auths": {
"<aws_account_id>.dkr.ecr.<region>.amazonaws.com": {
"username": "AWS",
"password": "<password-from-step-1>",
"auth": "<base64-encoded-credentials>"
}
}
}Generate the
authfield:echo -n "AWS:<password-from-step-1>" | base64
- Create the Kubernetes secret from the file:
kubectl create secret generic ecr-secret \
--from-file=.dockerconfigjson=config.json \
--type=kubernetes.io/dockerconfigjsonAlternative: Apply the secret declaratively using the provided manifest:
- Base64-encode your
config.jsonand place it in the.dockerconfigjsonfield of docker-secret.yaml - Apply it:
kubectl apply -f docker-secret.yamlUpdate the image reference in app-deployment.yaml with your ECR repository URL:
spec:
imagePullSecrets:
- name: ecr-secret
containers:
- name: app
image: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/app:1.0
imagePullPolicy: AlwaysThen deploy:
kubectl apply -f app-deployment.yamlVerify the deployment is running:
kubectl get podsAdd the ingress-nginx Helm repository:
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginxInstall the Nginx Ingress Controller:
helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.publishService.enabled=trueVerify the controller is running:
kubectl get pods
kubectl logs nginx-ingress-ingress-nginx-controller-<pod-id>A DigitalOcean Load Balancer is automatically provisioned:
Note the external IP address assigned to the ingress service:
kubectl get svcUpdate the host in app-ingress.yaml with your external IP (replacing dots with dashes):
- host: <your-ip-address>.nip.io
# Replace <your-ip-address> with your actual external IPApply the ingress rule:
kubectl apply -f app-ingress.yamlNavigate to http://<your-ip-address>.nip.io in your browser.





