Steps:
-
Clone the project using git clone into your local repository
-
To build an image , use docker build -t node:v1 . command to create an image .
-
To push image to AWS ECR i. Install AWS CLI on your instance ii. Configure AWS CLI using the access key and token key which is generated in AWS IAM iii. Tag the Docker image use following command --> docker tag your-image-name:latest :latest iv. Authenticate Docker to your ECR registry use following command --> aws ecr get-login-password --region | docker login --username AWS --password-stdin v. Push the Docker image to ECR use following command --> docker push :latest
-
Go to the instance where Kubernetes is installed.
-
Authenticate Docker to the ECR registry by using aws ecr get-login-password --region | docker login --username AWS --password-stdin .dkr.ecr..amazonaws.com
-
Create the Kubernetes Secret using the following command
kubectl create secret docker-registry regcred
--docker-server=.dkr.ecr.ap-south-1.amazonaws.com/devops
--docker-username=AWS
--docker-password=$(aws ecr get-login-password) \ -
Reference the Secret in the Kubernetes manifest file
-
Apply the kubernetes manifest file using kubectl apply -f <> command.
-
To login into the application use the instance public ip followed by the node port to access the application.