The code is based on the following repository from the Red Hat Software Collections: https://github.com/sclorg/s2i-nodejs-container/blob/master/12/README.md
# Create namespace for the application
oc new-project istio-probes-testing --display-name="Istio app to test Probes"
# Add your namespace to the SMMR
oc apply -f ocp/ServiceMeshMember.yaml
Now, substitute the configuration of the deployment with the configuration of the file deployment.yaml
:
-
Sidecar annotation.
-
Liveness and readiness probes.
-
Injecting the variable HOST using the pod name. This is the configuration that breaks the probes.
This is the content that you have to modify:
# Create application using s2i
oc new-app nodejs:12~https://github.com/alvarolop/nodejs-tester-server --name=nodejs-tester-http
# Autoinject sidecar using the Istio annotation
oc patch deployment nodejs-tester-http --type='json' -p "[{\"op\": \"add\", \"path\": \"/spec/template/metadata/annotations\", \"value\": {\"sidecar.istio.io/inject\": \"true\"}}]"
env:
- name: HOST
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: PORT
value: '8080'
readinessProbe:
httpGet:
path: /
port: 8080
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
livenessProbe:
httpGet:
path: /
port: 8080
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
# Create application using s2i
oc new-app nodejs:12~https://github.com/alvarolop/nodejs-tester-server --name=nodejs-tester-workaround
# Autoinject sidecar using the Istio annotation
oc patch deployment nodejs-tester-workaround --type='json' -p "[{\"op\": \"add\", \"path\": \"/spec/template/metadata/annotations\", \"value\": {\"sidecar.istio.io/inject\": \"true\"}}]"
env:
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: PORT
value: '8080'
readinessProbe:
httpGet:
path: /
port: 8080
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
livenessProbe:
httpGet:
path: /
port: 8080
scheme: HTTP
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
# Create application using s2i
oc new-app nodejs:12~https://github.com/alvarolop/nodejs-tester-server --name=nodejs-tester-command
# Autoinject sidecar using the Istio annotation
oc patch deployment nodejs-tester-command --type='json' -p "[{\"op\": \"add\", \"path\": \"/spec/template/metadata/annotations\", \"value\": {\"sidecar.istio.io/inject\": \"true\"}}]"
env:
- name: HOST
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: PORT
value: '8080'
readinessProbe:
exec:
command:
- /bin/bash
- '-c'
- 'curl http://$HOSTNAME:$PORT'
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
livenessProbe:
exec:
command:
- /bin/bash
- '-c'
- 'curl http://$HOSTNAME:$PORT'
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
# Create application using s2i
oc new-app nodejs:12~https://github.com/alvarolop/nodejs-tester-server --name=nodejs-tester-ip
# Autoinject sidecar using the Istio annotation
oc patch deployment nodejs-tester-ip --type='json' -p "[{\"op\": \"add\", \"path\": \"/spec/template/metadata/annotations\", \"value\": {\"sidecar.istio.io/inject\": \"true\"}}]"
env:
- name: HOST
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
- name: POD_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
- name: PORT
value: '8080'
readinessProbe:
exec:
command:
- /bin/bash
- '-c'
- 'curl http://$POD_IP:$PORT'
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
livenessProbe:
exec:
command:
- /bin/bash
- '-c'
- 'curl http://$POD_IP:$PORT'
timeoutSeconds: 1
periodSeconds: 10
successThreshold: 1
failureThreshold: 3