Reactjs is simple default application, trying to access through istio but it is unable to access. Below is the code for deployment used. docker file dockerfile
FROM node:latest
WORKDIR /app
COPY package.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]
kubernetes deployment file v1 and v2 Deployment.yaml
kind: Deployment
apiVersion: apps/v1
metadata:
name: my-react-app-v1
spec:
replicas: 2
selector:
matchLabels:
app: my-react-app
version: v1
template:
metadata:
labels:
app: my-react-app
version: v1
spec:
containers:
- name: my-react-app
image: xxx/react_sample:v1
imagePullPolicy: Always
ports:
- containerPort: 3000
restartPolicy: Always
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: my-react-app-v2
spec:
replicas: 2
selector:
matchLabels:
app: my-react-app
version: v2
template:
metadata:
labels:
app: my-react-app
version: v2
spec:
containers:
- name: my-react-app
image: xxx/react_sample:v1
imagePullPolicy: Always
ports:
- containerPort: 3000
restartPolicy: Always
---
##########################
#Service
##############
kind: Service
apiVersion: v1
metadata:
name: my-react-app
spec:
ports:
- port: 3000
name: http
selector:
app: my-react-app
Istio gateway configuration, Virtual service configuration and destination rules. Istio Configuration
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: appinfo-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: appinfo
spec:
hosts:
- "*"
gateways:
- appinfo-gateway
http:
- route:
- destination:
host: my-react-app
subset: v1
weight: 50
- destination:
host: my-react-app
subset: v2
weight: 50
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: my-react-app
spec:
host: my-react-app
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2