younsl opened a new pull request, #475:
URL: https://github.com/apache/superset-kubernetes-operator/pull/475

   ## Summary
   
   Several examples in the docs and samples fail when users copy them, and the 
reserved env var reference in configuration.md does not match what the operator 
sets. This PR fixes the examples so they deploy as written and brings the env 
var reference in line with the code. Every fix was reproduced on a Kind cluster 
before and after the change.
   
   ## Details
   
   Examples that fail as written:
   
   - [Getting 
Started](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/docs/getting-started.md?plain=1#L55-L58)
 pairs the lean 6.1.0 image with a psycopg2 URI. The lean image has no database 
drivers, so migrate fails with "No module named 'psycopg2'". It now uses 
6.1.0-dev, matching the [basic 
sample](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/config/samples/superset_v1alpha1_superset.yaml#L22-L23).
 The installation guide and the production sample now say the lean image needs 
a driver.
   - The [production 
sample](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/config/samples/superset_v1alpha1_superset_prod.yaml#L70-L74)
 sets runAsNonRoot without runAsUser. The image declares a named user, so the 
kubelet refuses to start the container 
([deployment_builder.go](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/internal/controller/deployment_builder.go#L284-L286)
 explains this). The sample now sets runAsUser and runAsGroup 1000, like the 
dev_full sample.
   - The [rotation 
example](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/docs/user-guide/lifecycle.md?plain=1#L393-L407)
 is a full manifest without the required spec.image, so the API server rejects 
it. The dev mode example in configuration.md had the same gap.
   - The [security context 
example](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/docs/user-guide/configuration.md?plain=1#L812-L819)
 enables readOnlyRootFilesystem, which crashes both the web server and Celery 
beat. It now uses false, as both samples do, with a short note on why.
   
   Env var reference:
   
   - SUPERSET_WEBSERVER_PORT was listed as an env var, but it is a [line in 
superset_config.py](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/internal/config/renderer.go#L188).
 The same claim in overview.md is fixed too.
   - Added the env vars the operator sets that were missing from the table: 
PREVIOUS_SECRET_KEY, VALKEY_USER, FLOWER_URL_PREFIX, and the ten Gunicorn env 
vars.
   - Documented that operator env vars are [merged 
last](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/internal/resolution/merge.go#L220),
 so a user env var with the same name is overridden.
   - The Celery example set CeleryConfig.worker_prefetch_multiplier, which has 
no effect because the operator always passes [the prefetch 
flag](https://github.com/apache/superset-kubernetes-operator/blob/26f993528ea1c30ac1a99f8967eef7e9ed4aa449/internal/config/celery.go#L106)
 on the worker command line. The example and the dev_full sample now use 
celeryWorker.celery.prefetchMultiplier.
   
   <details>
   <summary>Kind test results</summary>
   
   Operator built from this branch and deployed with make deploy on Kind 
(Podman provider), with config/samples/dev-dependencies.yaml.
   
   ```text
   [1] Getting Started example, before (6.1.0 lean)
   migrate: ModuleNotFoundError: No module named 'psycopg2'
   events:  Migrate task failed (attempt 1/3), retrying in 10s
   
   [1] Getting Started example, after (6.1.0-dev)
   NAME          TAG         PHASE     LIFECYCLE   READY   AVAILABLE
   my-superset   6.1.0-dev   Running   Complete    1/1     True
   
   [2] runAsNonRoot only (before) vs runAsUser 1000 added (after)
   nonroot-only-web-server  CreateContainerConfigError
     container has runAsNonRoot and image has non-numeric user (superset), 
cannot verify user is non-root
   nonroot-uid-web-server   Running, ready
   
   [3] Rotation example, kubectl apply --dry-run=server
   before: spec.image: Required value
   after:  superset.superset.apache.org/my-superset created (server dry run)
   
   [4] readOnlyRootFilesystem: true
   web-server:  FileNotFoundError: [Errno 2] No usable temporary directory 
found in ['/tmp', '/var/tmp', '/usr/tmp', '/app']
   celery-beat: OSError: [Errno 30] Read-only file system: '/tmp/celerybeat.pid'
   
   [5] SERVER_WORKER_AMOUNT=16 set in spec.podTemplate.container.env
   web-server env: SERVER_WORKER_AMOUNT=2
   operator log:   operator env var overrides user-specified value, 
var=SERVER_WORKER_AMOUNT
   
   [6] Web server port
   superset_config.py: SUPERSET_WEBSERVER_PORT = 8088
   container env:      no SUPERSET_WEBSERVER_PORT
   
   [7] CeleryConfig.worker_prefetch_multiplier = 1 in spec.config (before)
   worker command: celery ... worker --pool=prefork -O fair -c 4 
--prefetch-multiplier=4
   celeryWorker.celery.prefetchMultiplier: 1 (after)
   worker command: celery ... worker --pool=prefork -O fair -c 4 
--prefetch-multiplier=1
   ```
   
   Also ran make lint-md and make docs-build (zensical build --strict), both 
clean.
   
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to