Hello, I’m trying to get the CTFd deployed on my kubernetes cluster, and I can get it locally but I can’t get it to my external IP Address, I keep getting this error:
Traceback (most recent call last):
File "/opt/CTFd/ping.py", line 23, in <module>
engine = create_engine(url)
^^^^^^^^^^^^^^^^^^
File "<string>", line 2, in create_engine
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 544, in create_engine
dbapi = dialect_cls.dbapi(**dbapi_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/venv/lib/python3.11/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 811, in dbapi
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
But I’m not sure how to fix it, I have a .yaml file and a docker file that is supposed to force an install of “psycopg2” but I keep running into the error.
The docker file is this:
******# Use CTFd as base image
FROM ctfd/ctfd:3.5.0
# Switch to root user to install dependencies
USER root
# Fix potential missing files and allow changes in package releases
RUN apt-get clean && \
apt-get update --allow-releaseinfo-change && \
apt-get install -y libpq-dev gcc
# Switch back to the original user for security
USER ctfd
# Install psycopg2 for PostgreSQL connection
RUN pip install psycopg2
# Start CTFd
CMD ["python", "serve.py"]**
The .yaml
is this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: ctfd
spec:
replicas: 1
selector:
matchLabels:
app: ctfd
template:
metadata:
labels:
app: ctfd
spec:
containers:
- name: ctfd
image: nathanw898/my-ctfd:latest
imagePullPolicy: Always
ports:
- containerPort: 8000
env:
-
name: DATABASE_URL
value: "postgresql://postgres:TestPassword@ctfd-db-postgresql.default.svc.cluster.local:5432/postgres"
---
apiVersion: v1
kind: Service
metadata:
name: ctfd-service
spec:
type: LoadBalancer
selector:
app: ctfd
ports:
- protocol: TCP
port: 80
targetPort: 8000
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey there 👋
It sounds like you’re almost there! The error suggests that the package didn’t get installed properly inside the correct
venv
.Have you tried using the venv from the error message? For example:
Let me know how it goes!
- Bobby