Git Product home page Git Product logo

nodejs-tester-server's Introduction

nodejs-tester-server

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

1. How to deploy app on OCP

# 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:

Option 1: Invalid configuration

# 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

Option 2: Valid configuration

# 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

Option 3: Invalid configuration using curl command

# 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

Option 4: Invalid configuration using curl command and injecting IP using an env variable

# 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

Annex. How to create image in local

podman build -t node-app .
podman run localhost/node-app
podman run --env PORT=8080 localhost/node-app

nodejs-tester-server's People

Contributors

alvarolop avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.