appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.35k stars 3.72k forks source link

[Bug]: Unable to Install Appsmith When Kubernetes Namespace Is Not Default #23095

Closed ame-appsmith closed 1 year ago

ame-appsmith commented 1 year ago

Is there an existing issue for this?

Description

When trying to install Appsmith using the K8s installation guide, it does not work if using a different namespace than default: helm install appsmith appsmith/appsmith -n appsmith. The error returned is MongoDB replica set is not enabled. Front thread

Steps To Reproduce

Install Appsmith on Kubernetes, using a namespace that is not default: helm install appsmith appsmith/appsmith -n appsmith

Public Sample App

No response

Environment

Production

Issue video log

No response

Version

Self Hosted

Front logo Front conversations

ErlendFax commented 1 year ago

You probably have this information but I'll include the discord thread just in case.

Let me know if you need anything, we would love to get Appsmith back up again! 💪

ErlendFax commented 1 year ago

So I have found a workaround but it includes deleting the local mongo PVC ...

Since we already had Appsmith Kubernetes resources in this namespace prior to this upgrade we had to delete them to start with a clean slate:

  1. k get pvc -n appsmith
  2. k delete pvc -n appsmith datadir-appsmith-mongodb-x (for all instances)
  3. Install as normal

NB: Deleting volumes makes you lose stuff, be sure to have code in git and secrets stored in a safe password manager so you can set up Appsmith again.

pratapaprasanna commented 1 year ago

We couldn't replicate this . Can you try with the latest helm charts and let us know if you face the same issue?

Thankyou

darkmatter18 commented 1 year ago

Got same issue.

Error is service

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
{
  "success": true
100   193  100    21  100   172     62    513 --:--:-- --:--:-- --:--:--   577
}Initialize .env file
Load environment configuration
Checking environment configuration
Checking APPSMITH_MONGODB_URI
Checking initialized database
Checking Replica Set of external MongoDB
Error even from changeStream MongoServerError: The $changeStream stage is only supported on replica sets
    at Connection.onMessage (/opt/appsmith/utils/node_modules/mongodb/lib/cmap/connection.js:227:30)
    at MessageStream.<anonymous> (/opt/appsmith/utils/node_modules/mongodb/lib/cmap/connection.js:60:60)
    at MessageStream.emit (node:events:513:28)
    at processIncomingData (/opt/appsmith/utils/node_modules/mongodb/lib/cmap/message_stream.js:125:16)
    at MessageStream._write (/opt/appsmith/utils/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
    at writeOrBuffer (node:internal/streams/writable:391:12)
    at _write (node:internal/streams/writable:332:10)
    at MessageStream.Writable.write (node:internal/streams/writable:336:10)
    at Socket.ondata (node:internal/streams/readable:754:22)
    at Socket.emit (node:events:513:28) {
  ok: 0,
  code: 40573,
  codeName: 'Location40573',
  [Symbol(errorLabels)]: Set(0) {}
}
***************************************************************************************
*      MongoDB Replica Set is not enabled                                             *
*      Please ensure the credentials provided for MongoDB, has 'readWrite' role.      *
***************************************************************************************

Helm command

helm install -f values.yaml -n appsmith appsmith stable-appsmith/appsmith

Values.yaml


## Redis parameters
redis:
  enabled: true
  auth:
    enabled: false
  master:
    nodeSelector: 
      usage: appsmith
    tolerations:
      - effect: NoSchedule
        key: usage
        operator: Equal
        value: appsmith
  replica:
    replicaCount: 1
    nodeSelector: 
      usage: appsmith
    tolerations:
      - effect: NoSchedule
        key: usage
        operator: Equal
        value: appsmith

mongodb:
  enabled: false

global:
  storageClass: "managed-csi-premium"

nodeSelector:
  usage: appsmith

tolerations:
  - effect: NoSchedule
    key: usage
    operator: Equal
    value: appsmith

ingress:
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "8m"
    nginx.ingress.kubernetes.io/whitelist-source-range: 1.2.3.4/32
  hosts:
    - host: a.b.com
  secrets:
    - hosts:
      - "*.b.com"
  className: "nginx"

applicationConfig:
  APPSMITH_CLIENT_LOG_LEVEL: "debug"
  APPSMITH_MAIL_ENABLED: "true"
  APPSMITH_MAIL_HOST: "a.b.c"
  APPSMITH_MAIL_PORT: "587"
  APPSMITH_MAIL_USERNAME: "abcd"
  APPSMITH_MAIL_PASSWORD: "xyz"
  APPSMITH_MAIL_FROM: "x@a.com"
  APPSMITH_REPLY_TO: "x@a.com"
  APPSMITH_MAIL_SMTP_AUTH: "true"
  APPSMITH_MAIL_SMTP_TLS_ENABLED: "true"
  APPSMITH_MONGODB_URI: "mongodb://abcd:xyz@mongodb.mongodb.svc.cluster.local:27017/appsmith?retryWrites=true&authSource=admin"
  APPSMITH_ENCRYPTION_PASSWORD: "1234"
  APPSMITH_ENCRYPTION_SALT: "1234 "
  APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX: "false"
  APPSMITH_ENABLE_EMBEDDED_DB: 0
sharat87 commented 1 year ago

Hey @darkmatter18, sorry for the delay in getting back to this. It looks like you're using an externally managed MongoDB, running in your cluster. The error reports that you don't have replica set enabled on your MongoDB. Can you confirm if replicaSet is enabled please? You can confirm by running rs.status() on your MongoDB. Having replicaSet enabled is required for Appsmith to run.

If you do have replicaSet enabled, and yes see the above error, please open a separate issue mentioning this above comment and we'll take it up. Thank you.

Closing this as the title issue seems to be not reproducible anymore with current Helm charts. if that's not the case, happy to reopen.

ErlendFax commented 10 months ago

Happened again now.

helm upgrade appsmith appsmith/appsmith --version 2.0.7 -f values.yaml -i -n appsmith --set mongodb.auth.rootPassword=xxx

Appsmith pod gives MongoDB replica set is not enabled

melquisedequecosta98 commented 10 months ago

same problem here

pratapaprasanna commented 10 months ago

hey @ErlendFax @melquisedequecosta98 can you please share us the values.yaml used to deploy appsmith.

we did the following and get appsmith up and running

✗ helm upgrade appsmith appsmith/appsmith --version 2.0.7 -f values.yaml -i -n goutham --create-namespace --set mongodb.auth.rootPassword=password
Release "appsmith" does not exist. Installing it now.
coalesce.go:223: warning: destination for appsmith.persistence.localCluster is a table. Ignoring non-table value ([minikube])
coalesce.go:223: warning: destination for mongodb.persistence.existingClaim is a table. Ignoring non-table value ()
coalesce.go:223: warning: destination for appsmith.persistence.localCluster is a table. Ignoring non-table value ([minikube])
NAME: appsmith
LAST DEPLOYED: Thu Dec 14 00:21:31 2023
NAMESPACE: goutham
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
1. Get the application URL by running these commands:
  export POD_NAME=$(kubectl get pods --namespace goutham -l "app.kubernetes.io/name=appsmith,app.kubernetes.io/instance=appsmith" -o jsonpath="{.items[0].metadata.name}")
  export CONTAINER_PORT=$(kubectl get pod --namespace goutham $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
  echo "Visit http://127.0.0.1:8080 to use your application"
  kubectl --namespace goutham port-forward $POD_NAME 8080:$CONTAINER_PORT

To expose your Appsmith service to be accessible from the Internet, please refer to our docs here https://docs.appsmith.com/getting-started/setup/installation-guides/kubernetes/publish-appsmith-online.

and i see the following outputs

kubectl get pods -n goutham
NAME                         READY   STATUS    RESTARTS   AGE
appsmith-0                   1/1     Running   0          4m46s
appsmith-mongodb-0           1/1     Running   0          4m46s
appsmith-mongodb-1           1/1     Running   0          4m26s
appsmith-mongodb-arbiter-0   1/1     Running   0          4m46s
appsmith-redis-master-0      1/1     Running   0          4m46s
appsmith-redis-replicas-0    1/1     Running   0          4m46s
a-suenami commented 2 months ago

I have encountered the same problems.

I set up an ephemeral container on appsmith-mongodb-0 and checked its status with rs.status(), and found that mongodb-arbiter-0 was in an unhelthy state and mongodb-1 was not even a member of the replica set. After further investigation, it turned out that the communication between the pods did not seem to be working, so I drained the pods from the worker node where mongodb-arbiter-0 and mongodb-1 were running, and started them on another node, which restored them.

This is just a hypothesis, but it seems that AWS security group tracking has a limit, and it may have been caught by it; MongoDB Heartbeat communicates frequently, so it may be caught by this limit. (I use AWS EKS)

Hope this helps you guys.