kubernetes nginx upstream server as service not found - nginx

These are my yaml files referenced by here (kubernetes.io/docs)
deployment gists
And I use command kubectl apply -f backend-deployment.yaml -f frontend-configmap.yaml -f frontend-deployment.yaml
Backend were launched successfully, but Frontend occured error.
[emerg] 1#1: host not found in upstream "backend-service" in /etc/nginx/conf.d/nginx.conf:2
#nginx: [emerg] host not found in upstream "backend-service" in /etc/nginx/conf.d/nginx.conf:2
Even if 'backend-service' is declared, nginx couldn't recognize it.
Command nslookup backend-service result is:
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find backend-service: SERVFAIL
What am I missing?

I have gotten closer to the issue/solution.
First of all, you if the images in your supplied answer are correct, you are running nginx in your backend deployment and node-js server on your frontend deployment. This is a mistake.
after changing the images frontend is running (as expected) but backend pod is crashing.
However, the backend pod is successfully resolving the mysql-service to its internal clusterIp and I appear to have wrong authentication setup.
`> server#1.0.0 start /usr/src/app
> node backend.js
(node:18) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:18) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:18) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:18) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
listening on 3000
events.js:292
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED 10.100.77.32:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1142:16)
--------------------
at Protocol._enqueue (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/usr/src/app/node_modules/mysql/lib/Connection.js:116:18)
at Object.<anonymous> (/usr/src/app/backend.js:58:12)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Connection instance at:
at Connection._handleProtocolError (/usr/src/app/node_modules/mysql/lib/Connection.js:423:8)
at Protocol.emit (events.js:315:20)
at Protocol._delegateError (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:398:10)
at Handshake.<anonymous> (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:153:12)
at Handshake.emit (events.js:315:20)
at Handshake.Sequence.end (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:78:12)
at Protocol.handleNetworkError (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:369:14)
at Connection._handleNetworkError (/usr/src/app/node_modules/mysql/lib/Connection.js:418:18)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:96:8)
at emitErrorCloseNT (internal/streams/destroy.js:68:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: -111,
code: 'ECONNREFUSED',
syscall: 'connect',
address: '10.100.77.32',
port: 3306,
> node backend.js
fatal: true
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 start: `node backend.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-07-21T08_46_32_833Z-debug.log`
if you look at the log. it says it tries to connect to 10.100.77.32:3306 and the output of kubectl get svc is the following mysql-service ClusterIP 10.100.77.32 <none> 3306/TCP 17m
with the matching ip of my service.
kubectl get endpoints shows that the mysql-service has indeed found an endpoint:
mysql-service ClusterIP 10.100.77.32 <none> 3306/TCP 17m
and here is additional log information showing that the authentication mechanism of your nodejs application appearently is not working for the mysql pod.
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
at Handshake.Sequence._packetToError (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/usr/src/app/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/usr/src/app/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/usr/src/app/node_modules/mysql/lib/Connection.js:88:28)
at Socket.<anonymous> (/usr/src/app/node_modules/mysql/lib/Connection.js:526:10)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:296:12)
at readableAddChunk (_stream_readable.js:272:9)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
--------------------
at Protocol._enqueue (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/usr/src/app/node_modules/mysql/lib/Connection.js:116:18)
at Object.<anonymous> (/usr/src/app/backend.js:58:12)
at Module._compile (internal/modules/cjs/loader.js:1185:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1205:10)
at Module.load (internal/modules/cjs/loader.js:1034:32)
at Function.Module._load (internal/modules/cjs/loader.js:923:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
Emitted 'error' event on Connection instance at:
at Connection._handleProtocolError (/usr/src/app/node_modules/mysql/lib/Connection.js:423:8)
at Protocol.emit (events.js:315:20)
at Protocol._delegateError (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:398:10)
at Handshake.<anonymous> (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:153:12)
at Handshake.emit (events.js:315:20)
at Handshake.Sequence.end (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Sequence.js:78:12)
at Handshake.ErrorPacket (/usr/src/app/node_modules/mysql/lib/protocol/sequences/Handshake.js:125:8)
at Protocol._parsePacket (/usr/src/app/node_modules/mysql/lib/protocol/Protocol.js:291:23)
[... lines matching original stack trace ...]
at readableAddChunk (_stream_readable.js:272:9) {
code: 'ER_NOT_SUPPORTED_AUTH_MODE',
errno: 1251,
sqlMessage: 'Client does not support authentication protocol requested by server; consider upgrading MySQL client',
sqlState: '08004',
fatal: true
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! server#1.0.0 start: `node backend.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the server#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-07-21T08_55_22_133Z-debug.log
However, with the changes suggest at the beginning of the answer the issues around resolving the service name and communicating inside of kubernetes should be resolved.

backend-deployment image : bateaux/test-nginx
frontend-deployment image : bateaux/test-node-server
When deploy backend-deployment, remove [livenessProbe, readinessProbe].
Because node.js express server use #cloudnative/health-connect To readinessProbe, so call PingCheck(worker node ip).

Wow....I found solution for getaddrinfo EAI_AGAIN mysql-service.
I think if network can't find service, there is error in dns.
kubectl logs --namespace=kube-system -l k8s-app=kube-dns
Result of command is gist.
So...I finally found this link about kubernetes coredns.
By belphegor's answer, it works restart coredns.
Although, there is new error Client does not support authentication protocol requested by server; consider upgrading MySQL client, but i think to solve it is easier than dns error. hhhhhhhhhhhhhhhh

Related

Next.js create-next-app won't work anymore

I have been able to get around and make Next.js apps a lot as of late. However, something changed and I cannot seem to find a solution to my issue. I run npx create-next-app <app name> and it hits me with an error and only creates the package.json. It then shows me this error. Any insight would be appreciated.
>npx create-next-app imageuploads3
Creating a new Next.js app in /Users/Jeremy!##$%^%$#/Desktop/Code For Learning/imageuploads3.
Using yarn.
Installing dependencies:
- react
- react-dom
- next
node:events:505
throw er; // Unhandled 'error' event
^
Error: spawn yarn ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
at onErrorNT (node:internal/child_process:476:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn yarn',
path: 'yarn',
spawnargs: [
'add',
'--exact',
'--cwd',
'/Users/jeremy!##$^%$#/Desktop/Code For Learning/imageuploads3',
'react',
'react-dom',
'next'
]
}
Node.js v17.8.0
IIOS 12.3
npx create-react-app works just fine BTW.
It's because Yarn isn't enabled. You have two options:
If you want to use NPM instead of Yarn, pass the --use-npm flag in:
$ npx create-next-app --use-npm myapp
For Yarn, enable Corepack first:
$ corepack enable
$ npx create-next-app myapp

How to configure two processes in a heroku dyno to communicate with each other

I'm trying to establish communication between 2 processes running in a single heroku dyno, which according to this documentation should be possible:
https://devcenter.heroku.com/articles/dynos#networking
Individual processes within a dyno can bind to any address or port they want and communicate among them using e.g. standard TCP
I'm attempting to use http and the code works fine on my development machine. But when I try to execute the same thing on heroku, the source process can't connect to the target process. One process is running using nodejs and the other process is running using python.
Here's the contents of the Procfile:
web: npm run start
worker: python3 -m scripts.app
Here's part of the axios error message from the originating node process:
020-11-17T18:30:22.385020+00:00 app[web.1]: Inside nltk error block
2020-11-17T18:30:22.387506+00:00 app[web.1]: Error: connect ECONNREFUSED 127.0.0.1:5010
2020-11-17T18:30:22.387507+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
2020-11-17T18:30:22.387508+00:00 app[web.1]: errno: 'ECONNREFUSED',
2020-11-17T18:30:22.387508+00:00 app[web.1]: code: 'ECONNREFUSED',
2020-11-17T18:30:22.387509+00:00 app[web.1]: syscall: 'connect',
2020-11-17T18:30:22.387509+00:00 app[web.1]: address: '127.0.0.1',
2020-11-17T18:30:22.387509+00:00 app[web.1]: port: 5010,
The Procfile defines the process types. They will be run in separate containers.
If you want to run multiple processes in one dyno, your Procfile should have only one entry and one processes that will have your services are children.
There are several methods and buildpacks to achieve this.

I cannot install any node package with npm

I upgraded my npm to the latest version and now I can't run any npm command again, I uninstalled the node js and downloaded it again,
when I ran npm install -g ionic#latest I got this error in my command prompt:
npm WARN deprecated ionic#5.4.16: The Ionic CLI now uses ✨ #ionic/cli ✨ for its package name! 👉 https://twitter.com/ionicframework/status/1223268498362851330
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/env-paths failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\De Stone Of David\AppData\Roaming\npm-cache\_logs\2020-03-23T11_48_48_277Z-debug.log
I don't know what to do now, I also ran npm cache clean --force in powershell as admin and got the same error.
This is a case where reading the error message carefully can help. The key line is
npm ERR! network request to https://registry.npmjs.org/env-paths failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org
ENOTFOUND is a message delivered by your OS to npm. It means npm's attempt to use the Domain Name Service (DNS) to look up that registry machine's hostname failed.
So, you have a networking-connectivity problem, or, less likely, a firewall problem. Try this on a command line on your machine.
curl https://registry.npmjs.org
If it, too, doesn't work, try rebooting your machine. If that doesn't work, ask a network engineer for help and mention the curl command as evidence of the problem.
Some home ISPs (I'm looking at you, Comcast) sometimes have connectivity trouble that shows up as DNS failures. Power-cycle your cable modem and router. If that doesn't help, call tech support and ask them to reset your modem remotely.
If you have a VPN in use try disconnecting from it, then try your npm operation again. If it works without the VPN, then ask the person who maintains the VPN for help.
I have no trouble getting to that hostname from my location.

Meteor MUP PhantomJS error

I'm using mup to deploy the Meteor app:
docker Image : abernix/meteord:base
using ongoworks:spiderable for phantomjs / docker compatibility
Spiderable works fine in local development environment.
I am getting error when trying to
$curl http://hostname?_escaped_fragment_=
Internal Server Error
And, in mup logs, I see this:
spiderable: phantomjs failed: Error: Command failed: /bin/bash -c exec phantomjs --load-images=no --ignore-ssl-errors=yes /tmp/meteor_2576971355
at ChildProcess.exithandler (child_process.js:200:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:862:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)
stderr:
Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
at Object.Meteor.nodeCodeMustBeInFiber (packages/meteor.js:1075:11)
at [object Object]..extend.get (packages/meteor.js:1087:12)
at [object Object].RouteController.lookupOption (packages/iron_router.js:143:29)
at new Controller.extend.constructor (packages/iron_router.js:103:21)
at [object Object].ctor (packages/iron_core.js:144:17)
at Function.Router.createController (packages/iron_router.js:810:18)
at Function.Router.dispatch (packages/iron_router.js:1335:25)
at Object.router (packages/iron_router.js:624:12)
at next (/bundle/bundle/programs/server/npm/node_modules/meteor/webapp/node_modules/connect/lib/proto.js:174:15)
at Object.handle (packages/cfs_http-methods.js:444:12)
Spiderable works fine when I deploy build with "debug: true" option in mup.js file under buildOptions section. Strange!
Ref: https://www.npmjs.com/package/mup#build-options

Meteor deploy Bcrypt error Invoking deployment process

I want to deploy a meteor app (v1.2) to digital ocean. I am using MUP with this tutorial.
When I run mup deploy verbose I get this error (see below). I tried this as well being how i am on linux. meteor build myAppHere --architecture os.linux.x86_64 . But I still get the error.
Any ideas?
Started TaskList: Deploy app 'myAppHere' (linux)
[162.243.58.84] - Uploading bundle
[162.243.58.84] - Uploading bundle: SUCCESS
[162.243.58.84] - Setting up Environment Variables
[162.243.58.84] - Setting up Environment Variables: SUCCESS
[162.243.58.84] - Invoking deployment process
[162.243.58.84] x Invoking deployment process: FAILED
-----------------------------------STDERR-----------------------------------
ile=node.lib',
gyp info spawn args '-Dmodule_root_dir=/opt/myAppHere/tmp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
gyp info ok
npm WARN package.json meteor-dev-bundle#0.0.0 No description
npm WARN package.json meteor-dev-bundle#0.0.0 No repository field.
npm WARN package.json meteor-dev-bundle#0.0.0 No README data
stop: Unknown instance:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (7) Failed to connect to localhost port 81: Connection refused
Latest deployment failed! Reverted back to the previous version.
What is your node version? Most probably installed nodejs version is old. You can try with "nodeVersion": "0.10.40" in your mup.json

Resources