Kubernetes exit code 243 - node.js

I'm facing an issue with the deployement of my Node.js application on my Kubernetes container.
The container is stuck on Crashlooping with this error "Back-off restarting failed container" and as error code i have this "Reason: Error - exit code: 243"
I did a describe of the pod i found nothing except the "Back-off restarting failed container" .
If someone could help that would be great thanks

I'm not sure why this worked, but it seems to be something with using npm run... to start the node service. I experimented with changing my Docker file to launch the container using:
CMD npm run start
To just running the node command, using exactly what NPM should have been running, directly:
CMD node ...
EDIT:
In our environment it was an access problem. To get NPM working, we had to chown all the directories:
COPY --chown=${uid}:${gid} --from=builder /app .

Related

Problem launching TYPO3 via DDEV on Linux: Call to undefined function Composer\Autoload\includeFile()

I need to setup ddev with TYPO3 10.4 on public server (I know it's not a good practise, it's just to show a demo to the client). On my local machine (Windows + WSL2 + Docker + DDEV + Composer) everything works perfect, but when I start my project on the Linux suddenly there are some errors.
I have checked permissions, there is a newest version of composer, docker and ddev installed.
Errors:
[ Error ]
Call to undefined function Composer\Autoload\includeFile()
Failed to execute command vendor/bin/typo3cms extension:activate site: exit status 1
Task failed: Exec command 'cd frontend && npm ci && npm run prod' in container/service 'web': exit status 130
Task failed: Exec command 'vendor/bin/typo3cms database:updateschema' in container/service 'web': exit status 1
It looks like it can't execute commands, but I can't find any meaningful reason why. I will be glad for any ideas.
You need to install most new version of typo3-console.
Your problem is described here:
https://github.com/TYPO3-Console/TYPO3-Console/issues/1081

Fabric chaincode container (nodejs) cannot access npm

I appreciate help in this matter.
I have the latest images (2.2.0, CA 1.4.8), but I'm getting the error when I'm installing chaincode at the first peer:
failed to invoke chaincode lifecycle, error: timeout expired while executing transaction
I'm working behind a proxy, using a VPN.
I tried to increase the timeouts at the docker config, for all peers:
CORE_CHAINCODE_DEPLOYTIMEOUT=300s
CORE_CHAINCODE_STARTUPTIMEOUT=300s
The process works perfectly up to that point (channel created, peers joined the channel). The chaincode can be installed manually with npm install.
I couldn't find an answer to this anywhere. Can someone provide guidance?
UPDATE: It seems that the chaincode container gets boostrap (and even attributed a random name), but gets stuck at:
+ INPUT_DIR=/chaincode/input
+ OUTPUT_DIR=/chaincode/output
+ cp -R /chaincode/input/src/. /chaincode/output
+ cd /chaincode/output
+ '[' -f package-lock.json -o -f npm-shrinkwrap.json ]
+ npm install --production
I believe it is the proxy blocking npm.
I tried to solve this with:
npm config set proxy proxy
npm config set https-proxy proxy
npm set maxsockets 3
After days of struggling, I've found a solution:
-Had to build a custom fabric nodeenv image, that contained the env variables to setup the npm proxy vars: as in node chaincode instantiate behind proxy. After that, I've setup the following env vars in docker.yaml:
- CORE_CHAINCODE_NODE_RUNTIME=my_custom_image
- CORE_CHAINCODE_PULL=true
Useful! For Chinese users, npmjs may sometimes be disconnected and can build their own instances.
For example, if I use version 2.3.1, Download https://github.com/hyperledger/fabric-chaincode-node/tree/v.2.3.1 Edition. Then enter docker/fabric-nodeenv, modify the Dockerfile, and add a line to modify the warehouse source for npmjs:
RUN npm config set registry http://registry.npm.taobao.org
The entire file is as follows:
ARG NODE_VER=12.16.1
FROM node:${NODE_VER}-alpine
RUN npm config set registry http://registry.npm.taobao.org
RUN apk add --no-cache \
make \
python \
g++;
RUN mkdir -p /chaincode/input \
&& mkdir -p /chaincode/output \
&& mkdir -p /usr/local/src;
ADD build.sh start.sh /chaincode/
Then build a docker image, using the command
docker image build-t whatever/fabric-nodeenv:2.3.
Wait a few minutes, and he'll build the image, and then with docker images, you'll see the image he created
Finally, in peer's configuration file, add in peer-environment
- CORE_CHAINCODE_NODE_RUNTIME=whatever/fabric-nodeenv:2.3
Hope it can help others!

ERROR: Cannot write pid file to /tmp/docker-entrypoint-temp-mongod.pid: Unknown error

Stack information :
BE : NodeJS App, MongoDB
FE : AngularJS App
Use case :
I am deploying BE(NodeJS) application on AWS ECS along with MongoDB. There is a task definition (AWS) in which there should be both the containers attached so that Mongo container can be linked to the NodeJS container. Mongo container is from docker hub registry registry.hub.docker.com/library/mongo:latest
Please note I have also subscribed to the CloudWatch Logs for the containers.
I am also providing the MONGO_INITDB_ROOT_PASSWORD & MONGO_INITDB_ROOT_USERNAME as new user environment variables.
Problem :
As soon as the service bootstraps NodeJS container, it gets failed with below error.
2019-05-28T14:15:23.208+0000 I CONTROL [main] ERROR: Cannot write pid file to /tmp/docker-entrypoint-temp-mongod.pid: Unknown error
Result :
As a result, mongo is not able to get started and NodeJS app is unable to operate on the db. I want this db operations within container (ECS) as a solution.
Please guide what I am doing wrong here!! Kindly Help!
Why it differs from this answer/question :
Because in my case the application along with MongoDB is running in container environment and container (Node container) is all responsible for bootstrapping it or restarting the mongo service. Also, the error I am facing is Unknown Error.
EDIT :
Dockerfile
FROM node:8-alpine
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm#5+)
COPY package*.json ./
RUN npm install
# RUN npm audit
# Bundle app source
#COPY . /usr/src/app
COPY . .
EXPOSE 9000
CMD [ "npm", "start" ]

Deploying a Node app in a subdirectory on AWS Elastic Beanstalk

I am currently in the process of setting up my first Elastic Beanstalk Node application and I have hit a snag.
I followed this tutorial to get a working Express application running with no view-engine (going to be using React):
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs_express.html
However, I want to move it to the /app directory so that eventually I can install a Wordpress instance in the root directory to use as a quick public facing intro to our application with a blog.
The project looks like this:
my-app
// Wordpress Files Here
/.ebextensions
/app
/bin
/client
// React Files Here
/node_modules
/public
/routes
/app.js
/package-lock.json
/package.json
With all of the Node files in the root directory, everything works as expected. When I move everything to the app directory and add this to the .ebextensions/01_nodeconfig.config file:
commands:
01_npm_install:
command: npm install
cwd: app/
I get this error on eb deploy:
2018-11-09 17:39:35 INFO Environment update is starting.
2018-11-09 17:40:15 INFO Deploying new version to instance(s).
2018-11-09 17:40:22 ERROR [Instance: i-0eedebf7a339e69ca] Command failed on instance. Return code: 1 Output: [Errno 2] No such file or directory: 'app/'.
EBExtension failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2018-11-09 17:40:23 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2018-11-09 17:40:23 ERROR Unsuccessful command execution on instance id(s) 'i-0eedebf7a339e69ca'. Aborting the operation.
2018-11-09 17:40:23 ERROR Failed to deploy application.
When I look in the log, here is what is returned:
[2018-11-09T17:40:20.819Z] INFO [26711] - [Application update app-4f25-181109_123930#15/AppDeployStage0/EbExtensionPreBuild/Infra-EmbeddedPreBuild] : Activity execution failed, because: [Errno 2] No such file or directory: 'app/' (ElasticBeanstalk::ExternalInvocationError)
Does anyone have an idea on why it cannot find the app directory even though it is right there?
Thanks.

Kubernetes fails to deploy valid container image

I have a docker image containing an NodeJS app. The Dockerfile is:
FROM node:8
WORKDIR /app
ADD . /app
RUN npm install
EXPOSE 80
ENTRYPOINT [ "/bin/sh", "./start.sh" ]
The start.sh script is:
#!/bin/bash
...
echo "Starting application"
npm start
I'm able to launch and test the image manually:
$ gcloud docker -- run -it --rm my-container
...
Starting application
...
> node index.js
...
The same container is used by a kubernetes deployment:
apiVersion: extensions/v1beta1
kind: Deployment
...
spec:
...
template:
...
spec:
containers:
- image: my-container
...
The container starts, the start.sh script is correctly executed but it terminates and the container goes into a CrashLoopBackOff loop.
After inspecting the pod manually:
kubectl exec -ti my-pod -- bash
I have no name!#my-pod:/app# cat /etc/passwd
... empty response
-> It appears that somehow there are no system users on the container, which makes most commands (like npm) fail silently and terminate the container
I have also tried, without success:
deleting the pod
deleting and re-creating the deployment
running the node image with the node user -> unable to find user node: no matching entries in passwd file
Last note: I actually have many deployments (using the same template with just a different name) which are running fine with an image that was built a few days ago with the same source code.
For some deployments, it actually worked after manually deleting the pod and letting kubernetes recreate it.
Any ideas?
Edit 18/01/2018 I have tried rebuilding an image with the same source code that old working images use, without success. I have also tried a simpler Dockerfile:
FROM node:8
USER node
But I still get an error related to the fact that no users seem to be there:
Error response from daemon: {"message":"linux spec user: unable to find user node: no matching entries in passwd file"}
I have checked with the docker-node guys, the image hasn't changed recently. Could it be related to kubernetes changes? Keep it mind that my images do run when I run them manually with the docker command.
I tried to reproduce your issue, but didn't get it to fail in anything like the same fashion. I made a dummy express app and stuck it on github that matches your example above, and then invoked it into a local minikube instance I had. The base image size is reasonably large, but it started up just fine.
I had to interpret what was happening within npm start for your example since you didn't specify, but you can see my package.json, which I suspect is pretty close to what you're doing based on the description.
When I fire this up:
git clone https://github.com/heckj/dummyexpress
cd dummyexpress
kubectl apply -f deploy/
The I got a running instance right off the bat:
NAME READY STATUS RESTARTS AGE
dummynodeapp-7788b95497-tkw2s 1/1 Running 0 1d
And the logs show pretty much what you'd expect:
**kubectl log dummynodeapp-7788b95497-tkw2s**
W0117 19:41:00.986498 20648 cmd.go:353] log is DEPRECATED and will be removed in a future version. Use logs instead.
Starting application
> blah#1.0.0 start /app
> node index.js
Example app listening on port 3000!
My guess is that you've got something going awry within your npm start execution, so I'd recommend fiddling with that aspect of your deployment and see if you can't resolve it that way.
Well as #heckj pointed out, it was a Docker issue on my kubernetes cluster. I updated the cluster from 1.6.13-gke.1 to v1.7.12-gke.0 and the pods worked fine again. I'm not sure what Docker version was used since there's another kubernetes bug that is preventing me from seeing it.

Resources