I managed to create and deploy a k8s cluster with minikube, running 4 replicas of a simple hello-world node.js app, using the following configuration.
Dockerfile for the app:
FROM ubuntu:latest
RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y nodejs npm
# TODO could uninstall some build dependencies
# debian installs `node` as `nodejs`
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
COPY package.json package.json
RUN npm install
COPY . .
CMD ["node", "app.js"]
k8s Deployment yml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-deployment
labels:
app: node-app
spec:
replicas: 4
selector:
matchLabels:
app: node-app
template:
metadata:
labels:
app: node-app
spec:
containers:
- name: node-app
image: my-repo/ubuntu-node:sectry
ports:
- containerPort: 3000
---
apiVersion: v1
kind: Service
metadata:
name: node-service
labels:
app: node-app
spec:
type: NodePort
ports:
- port: 3000
protocol: TCP
selector:
app: node-app
My question is how can add an nginx container for it? I know k8s cluster already load-balancing, but I really wish to use NGINX features.