Worker-pod Crashing, unable to start. (demo-voting-app)

Hi Team,

Need help in addressing issue with worker-pod which is part of demo-voting-app.

As checked from the cluster Below are the details for error.

Normal Started 7s (x3 over 24s) kubelet Started container worker-app
Warning BackOff 6s (x3 over 22s) kubelet Back-off restarting failed container

Logs:
kubectl logs worker-app-pod
System.NotSupportedException: Authentication method not supported (Received: 10)
at Npgsql.NpgsqlConnector.ParseServerMessage(ReadBuffer buf, BackendMessageCode code, Int32 len, DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode)
at Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
at Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout)
at Npgsql.NpgsqlConnection.OpenInternal()
at Worker.Program.OpenDbConnection(String connectionString) in /code/src/Worker/Program.cs:line 78
at Worker.Program.Main(String[] args) in /code/src/Worker/Program.cs:line 19

worker-app-prod.yaml
apiVersion: v1
kind: Pod
metadata:
name: worker-app-pod
labels:
name: worker-app-pod
app: demo-voting-app
spec:
containers:
- name: worker-app
image: kodekloud/examplevotingapp_worker:v1

Please check and advise, rest of the pods/service running without any issues except the worker-pod.

Thanks
Srini

Hello @sri.lynx,
Please follow these full steps to know what you have missed and try again :

Note: We will create deployments again so please before following the steps, Run kubectl delete deployment --all to delete old deployments and avoid any conflicts.

  1. Run git clone https://github.com/mmumshad/example-voting-app-kubernetes-v2.git

  2. Run cd example-voting-app-kubernetes-v2/

  3. Run vim postgres-deployment.yml and modify it’s content as below then save and exit.

Note: It’s a new update from Postgres.

apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: postgres-deployment
   labels:
     app: demo-voting-app
 spec:
   replicas: 1
   selector:
     matchLabels:
       name: postgres-pod
       app: demo-voting-app
   template:
     metadata:
       name: postgres-pod
       labels:
         name: postgres-pod
         app: demo-voting-app
     spec:
       containers:
       - name: postgres
         image: postgres:9.4
         env:
         - name: POSTGRES_USER
           value: postgres
         - name: POSTGRES_PASSWORD
           value: postgres
         - name: POSTGRES_HOST_AUTH_METHOD
           value: trust
         ports:
         - containerPort: 5432
  1. Run kubectl create -f . if you create deployments for the first time, if you created the same deployments before Run kubectl apply -f . .

  2. Run kubectl get service to get the exposed ports.

For example if the output of the command as above you can accces the voting app by hitting One_of_the_worker_nodes_IP:32733 on your browser and the same for the resulting app >> One_of_the_worker_nodes_IP:30013.

Check :

Note: The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.

Hope this helps!

Fantastic, Works fine. Just want to understand as far as worker-app-pod is concerned the image do not contain the tag information, does it means it’s taking up the latest one?

spec:
containers:
- name: worker-app
image: dockersamples/examplevotingapp_worker

Thanks
Srini

yes, it will take the latest tag.

Should we use POSTGRES_HOST_AUTH_METHOD=trust? As per postgres it is not recommended. We should be using user/password instead, but that that it does not work. What can be the issue?
See below:

WARNING: POSTGRES_HOST_AUTH_METHOD has been set to “trust”. This will allow
example-voting-app-db-1 | anyone with access to the Postgres port to access your database without
example-voting-app-db-1 | a password, even if POSTGRES_PASSWORD is set. See PostgreSQL
example-voting-app-db-1 | documentation about “trust”:
example-voting-app-db-1 | PostgreSQL: Documentation: 16: 21.4. Trust Authentication
example-voting-app-db-1 | In Docker’s default configuration, this is effectively any other
example-voting-app-db-1 | container on the same system.
example-voting-app-db-1 |
example-voting-app-db-1 | It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace
example-voting-app-db-1 | it with “-e POSTGRES_PASSWORD=password” instead to set a password in
example-voting-app-db-1 | “docker run”.

This is the error it throws via docker compose, should be similar for gke deployment

example-voting-app-db-1 | 2023-12-18 22:33:07.692 UTC [1] LOG: starting PostgreSQL 15.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 13.2.1_git20231014) 13.2.1 20231014, 64-bit
example-voting-app-db-1 | 2023-12-18 22:33:07.692 UTC [1] LOG: listening on IPv4 address “0.0.0.0”, port 5432
example-voting-app-db-1 | 2023-12-18 22:33:07.692 UTC [1] LOG: listening on IPv6 address “::”, port 5432
example-voting-app-db-1 | 2023-12-18 22:33:07.694 UTC [1] LOG: listening on Unix socket “/var/run/postgresql/.s.PGSQL.5432”
example-voting-app-db-1 | 2023-12-18 22:33:07.698 UTC [50] LOG: database system was shut down at 2023-12-18 22:33:07 UTC
example-voting-app-db-1 | 2023-12-18 22:33:07.702 UTC [1] LOG: database system is ready to accept connections
example-voting-app-worker-1 | System.NotSupportedException: Authentication method not supported (Received: 10)
example-voting-app-worker-1 | at Npgsql.NpgsqlConnector.ParseServerMessage(ReadBuffer buf, BackendMessageCode code, Int32 len, DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)
example-voting-app-worker-1 | at Npgsql.NpgsqlConnector.DoReadMessage(DataRowLoadingMode dataRowLoadingMode, Boolean isPrependedMessage)
example-voting-app-worker-1 | at Npgsql.NpgsqlConnector.ReadMessageWithPrepended(DataRowLoadingMode dataRowLoadingMode)
example-voting-app-worker-1 | at Npgsql.NpgsqlConnector.HandleAuthentication(String username, NpgsqlTimeout timeout)
example-voting-app-worker-1 | at Npgsql.NpgsqlConnector.Open(NpgsqlTimeout timeout)
example-voting-app-worker-1 | at Npgsql.ConnectorPool.Allocate(NpgsqlConnection conn, NpgsqlTimeout timeout)
example-voting-app-worker-1 | at Npgsql.NpgsqlConnection.OpenInternal()
example-voting-app-worker-1 | at Worker.Program.OpenDbConnection(String connectionString) in /code/src/Worker/Program.cs:line 50
example-voting-app-worker-1 | at Worker.Program.Main(String[] args) in /code/src/Worker/Program.cs:line 19
example-voting-app-worker-1 exited with code 1
example-voting-app-result-1 | /node_modules/pg/lib/connection.js:426
example-voting-app-result-1 | throw new Error(“Unknown authenticationOk message type” + util.inspect(msg));
example-voting-app-result-1 | ^
example-voting-app-result-1 |
example-voting-app-result-1 | Error: Unknown authenticationOk message type{ name: ‘authenticationOk’, length: 23 }
example-voting-app-result-1 | at Connection.parseR (/node_modules/pg/lib/connection.js:426:9)
example-voting-app-result-1 | at Connection.parseMessage (/node_modules/pg/lib/connection.js:345:17)
example-voting-app-result-1 | at Socket. (/node_modules/pg/lib/connection.js:105:22)
example-voting-app-result-1 | at emitOne (events.js:90:13)
example-voting-app-result-1 | at Socket.emit (events.js:182:7)
example-voting-app-result-1 | at readableAddChunk (_stream_readable.js:153:18)
example-voting-app-result-1 | at Socket.Readable.push (_stream_readable.js:111:10)
example-voting-app-result-1 | at TCP.onread (net.js:534:20)

This app has multiple versions (some from kodekloud, some from docker-samples) and the postgres versions differ; one uses Postgresql 9, which is very old. But for now, let’s assume that your postgres version allows for POSTGRES_HOST_AUTH_METHOD. True, you don’t want to do this in production. But getting this particular lab to work right is a bit tricky, so I recommend it for purposes of completing the lab.

Hello, I got the same issue, someone can help me how to make a POST in the terminal making a POST request for the voting-app?

Hello team. I am using minikube in an EC2 instance, how can I open the url in the browser, when I made a curl inside the EC2 using the url using the commad

minikube start voting-app --url

I can observe that the URL is reachable inside the EC2, but not in browser,
Please, suggests me

I don’t believe that minikube is designed to be accessed that way; it’s not designed to be particularly secure, so minikube’s virtual system exposes itself to the host in host-only mode. This will make it difficult to access outside of your EC2 system.

It might be possible to coerce it into doing what you want though; you might want to ask to folks on the #minikube group of Kubernetes Slack.