I'm new to Kubernetes, I have a docker image built and run with npm token how to convert this to deployment in Kubernetes. Below is my image and command to build and run.
#First Build
FROM node:16.17-bullseye
ARG NPM_TOKEN
WORKDIR /usr/src/app
#COPY package*.json .npmrc ./
COPY package*.json /usr/src/app/
COPY .npmrc /usr/src/app/
RUN npm update
RUN npm install
COPY . .
CMD ["npm","run","main"]
Buld command:
docker build . -t image --build-arg NPM_TOKEN=<token>
Run command:
docker run -p 3001:3001 -it -e NPM_TOKEN="Token" imageid
I'm using azure pipelines where image is build, pushed to azure container registry, then pulled and deployed to aks (azure kubernetes service). Below is my deployment file :
apiVersion : apps/v1
kind: Deployment
metadata:
name: microa
namespace: ingress-basic
spec:
replicas: 1
selector:
matchLabels:
app: microa
template:
metadata:
labels:
app: microa
spec:
containers:
- name: microa
image: acrURL/microa
args: ["NPM_TOKEN=<token>"]
resources:
requests:
memory: "256Mi"
cpu: "1000m"
limits:
memory: "512Mi"
cpu: "1500m"
ports:
- containerPort: 3001