Reputation: 209
I am new to kubernetes. I am running my kubernetes cluster inside my Docker Desktop VM. Below are the versions
Docker Desktop Community : 2.3.0.4 (Stable)
Engine: 19.03.12
kubernetes: 1.16.5
i created a simple react app. below is the Docker file.
FROM node:13.12.0-alpine
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package*.json ./
RUN npm install
# add app files
COPY . ./
# start app
CMD ["npm", "start"]
I built a docker image and ran it. it works fine. I added the image in the below deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
labels:
app: test-react-app
namespace: dev
spec:
replicas: 1
selector:
matchLabels:
app: test-react-app
template:
metadata:
labels:
app: test-react-app
spec:
containers:
- name: test-react
image: myrepo/test-react:v2
imagePullPolicy: Never
ports:
- containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
name: test-service
namespace: dev
spec:
type: NodePort
ports:
- port: 80
targetPort: 80
protocol: TCP
nodePort: 31000
selector:
app: test-react-app
The pod never starts. Below is the events from describe.
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned dev/test-deployment-7766949554-m2fbz to docker-desktop
Normal Pulled 8m38s (x5 over 10m) kubelet, docker-desktop Container image "myrepo/test-react:v2" already present on machine
Normal Created 8m38s (x5 over 10m) kubelet, docker-desktop Created container test-react
Normal Started 8m38s (x5 over 10m) kubelet, docker-desktop Started container test-react
Warning BackOff 26s (x44 over 10m) kubelet, docker-desktop Back-off restarting failed container
Below is the logs from the container. It looks as if the container is running..
> [email protected] start /app
> react-scripts start
[34mℹ[39m [90m「wds」[39m: Project is running at http://10.1.0.33/
[34mℹ[39m [90m「wds」[39m: webpack output is served from
[34mℹ[39m [90m「wds」[39m: Content not from webpack is served from /app/public
[34mℹ[39m [90m「wds」[39m: 404s will fallback to /
Starting the development server...
Upvotes: 0
Views: 1514
Reputation: 209
It worked!!!
I build the react app into a production app and then copied the docker file. I followed the technique given in this link https://dev.to/rieckpil/deploy-a-react-application-to-kubernetes-in-5-easy-steps-516j.
Upvotes: 2