Code Monkey home page Code Monkey logo

pacman's Introduction

pacman

Pac-Man

Install dependencies

npm install

Getting started

npm run start

Development

npm run dev

Create Application Container Image

Docker Container Image

The Dockerfile performs the following steps:

  1. It is based on Node.js LTS Version 6 (Boron).
  2. It then clones the Pac-Man game into the configured application directory.
  3. Exposes port 8080 for the web server.
  4. Starts the Node.js application using npm start.

To build the image run:

cd docker
docker build -t <registry>/<user>/pacman-nodejs-app .

You can test the image by running:

docker run -p 8000:8080 <registry>/<user>/pacman-nodejs-app

And going to http://localhost:8000/ to see if you get the Pac-Man game.

Once you're satisfied you can push the image to the container registry.

docker push <registry>/<user>/pacman-nodejs-app

Building using an s2i image

s2i build . centos/nodejs-6-centos7 pacman

pacman's People

Contributors

codificat avatar dav1x avatar detiber avatar font avatar mvazquezc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pacman's Issues

App is not able to write to the database , nor it is able to query from it

I have installed the app on a bare metal EC2 as docker was not working correctly, My ultimate aim is to send data to an external observability tool through open telemetry , i have also installed the tracing libraries and running the app like this ๐Ÿ‘
npm start -- @splunk/otel/instrument

Error [MongoError]: Unsupported OP_QUERY command: find. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal
at MongoError.create (/usr/src/app/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/usr/src/app/node_modules/mongodb-core/lib/cursor.js:212:36)
at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:469:18
at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
ok: 0,
errmsg: 'Unsupported OP_QUERY command: find. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal',
code: 352,
codeName: 'UnsupportedOpQueryCommand'
}
/usr/src/app/node_modules/mongodb/lib/utils.js:123
process.nextTick(function() { throw err; });
^

TypeError: Cannot read properties of undefined (reading 'forEach')
at /usr/src/app/routes/highscores.js:30:18
at handleCallback (/usr/src/app/node_modules/mongodb/lib/utils.js:120:56)
at /usr/src/app/node_modules/mongodb/lib/cursor.js:858:22
at handleCallback (/usr/src/app/node_modules/mongodb-core/lib/cursor.js:171:5)
at /usr/src/app/node_modules/mongodb-core/lib/cursor.js:594:22
at queryCallback (/usr/src/app/node_modules/mongodb-core/lib/cursor.js:212:16)
at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:469:18
at process.processTicksAndRejections (node:internal/process/task_queues:77:11)

Node.js v18.12.0

Cloud Provider information is no longer available

We recently patched our OCP cluster and discovered the ability to query the cloud provider metadata is not longer allowed. It appears this access is blocked. This was confirmed with the network team that containers no longer have access to this information.

We are doing a work around of this by using the kubeapi. We create a service account for pacman, cluster role, cluster role binding and pass in the environment variable of the node name to be used when querying information through the kubeapi.

SA

apiVersion: v1
kind: ServiceAccount
metadata:
  name: pacman 

ClusterRole and ClusterRoleBinding

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: pacman
rules:
- apiGroups: [""]
  resources: ["pods", "nodes"]
  verbs: ["get", "watch", "list"]

---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: pacman
  namespace: pacmanv3
subjects:
- kind: ServiceAccount
  name: pacman 
  namespace: pacmanv3
roleRef:
  kind: ClusterRole
  name: pacman
  apiGroup: rbac.authorization.k8s.io

Deployment

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace: pacmanv3
  name: pacman
  labels:
    name: pacman
spec:
  replicas: 1
  selector:
    matchLabels:  
      name: pacman
  template:
    metadata:
      namespace: pacman
      labels:
        name: pacman
    spec:
      serviceAccount: pacman
      containers:
      - name: pacman
        image: quay.io/rcook/pacman-nodejs-app:latest
        imagePullPolicy: Always
        env:
        - name: MONGO_SERVICE_HOST
        # Single member MongoDB
          value: internal-a4dfda3218e1e11e9967c0edf0f025f2-791543394.us-east-1.elb.amazonaws.com
        # Replicaset (federated) MongoDB
        #  value: mongo-east1.apps.east-1.sysdeseng.com,mongo-east2.apps.east-2.sysdeseng.com,mongo-west2.apps.west-2.sysdeseng.com
        # Comment out MONGO_REPLICA_SET for the single-member Mongo
        # - name: MONGO_REPLICA_SET
        #  value: rs0
        - name: MONGO_AUTH_USER
          valueFrom:
            secretKeyRef:
              key: database-user
              name: mongodb-users-secret
        - name: MONGO_AUTH_PWD
          valueFrom:
            secretKeyRef:
              key: database-password
              name: mongodb-users-secret
        - name: MONGO_DATABASE
          value: pacman
        - name: MONGO_PORT
          value: "27017"
        - name: MONGO_USE_SSL
          value: "false"
        - name: MONGO_VALIDATE_SSL
          value: "false"
        - name: MY_NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        ports:
        - containerPort: 8080 

This is the location.js we are working with now to try to redo the cloud provider check https://github.com/dav1x/pacman/blob/master/routes/location.js

This is the rough curl command which will allow for us to get the data that we need.

curl -v --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" https://kubernetes.default.svc/api/v1/nodes/$MY_NODE_NAME 

Cloud is Null in High score

For some reason cloud appears as null at the high score page. It looks like the items are being directed properly

[POST /highscores] body = { name: 'rocok2',
  'cloud[]': 'aws',
  zone: 'us-east-2a',
  host: 'pacman-f787877d4-btv7m',
  score: '100',
  level: '1' }  host = rcook-pacman.sysdeseng.com  user-agent = Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36  referer = http://rcook-pacman.sysdeseng.com/
Successfully inserted highscore
Time:  Fri Jul 19 2019 18:01:35 GMT+0000 (UTC)
[GET /highscores/list]

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.