K8s Deployment Configuration #15
-
Hi! I've been playing around with deploying fief onto a kubernetes cluster today after running it on docker and have been trying to figure out a few things, specifically around the I had made a few modifications to the boot-up process to remove requiring the user to interact with the container. # run_init.py
...
_donefile = Path('/data/db/.init_run')
async def run_app_startup():
if _donefile.exists():
typer.secho('Init already completed!', fg = 'green')
return
# allow for migration to take place
time.sleep(15)
typer.secho('Running Init!', fg = 'green')
try:
await create_main_fief_workspace()
typer.echo("Main Fief workspace created")
except MainWorkspaceAlreadyExists as e:
typer.echo("Main Fief workspace already exists")
main_user = os.getenv('MAIN_USER_EMAIL', 'ts@....')
main_pass = os.getenv('MAIN_USER_PASS')
if not main_pass:
main_pass = str(uuid4())
typer.echo(f'Generating User Pass: {main_pass}')
try:
await create_main_fief_user(main_user, main_pass)
typer.echo(f"Main Fief user {main_user} created")
except CreateMainFiefUserError as e:
typer.echo("An error occured")
typer.echo('Completed Fief Startup')
_donefile.write_text('completed')
if __name__ == '__main__':
anyio.run(run_app_startup) # start.sh
#!/bin/sh
# this part was later added after failing to set proper vars.
if [ "$RUN_K8S" == "true" ]; then
echo "Setting Env Vals"
export FIEF_BASE_URL="http://$HOSTNAME:$PORT"
export FIEF_DOMAIN="$HOSTNAME:$PORT"
echo "FIEF_BASE_URL = $FIEF_BASE_URL"
echo "FIEF_DOMAIN = $FIEF_DOMAIN"
fi
nohup python /run_init.py &
/usr/bin/supervisord -c /etc/supervisord.conf
Like this issue originally mentioned, whenever accessing Settings that have been attempted: ROOT_DOMAIN=v1.domain.com
# ROOT_DOMAIN=fief-server.kops.svc:8000
# ROOT_DOMAIN=auth.v1.domain.com:80
# ROOT_DOMAIN=auth.v1.domain.com:443
FIEF_DOMAIN=auth.v1.domain.com
# FIEF_DOMAIN=fief-server.kops.svc:8000
# FIEF_DOMAIN=auth.v1.domain.com
# FIEF_DOMAIN=auth.v1.domain.com:80
# FIEF_BASE_URL=https://auth.v1.domain.com
# FIEF_BASE_URL=http://fief-server.kops.svc:8000
# FIEF_BASE_URL=http://auth.v1.domain.com:800
ALLOW_ORIGIN_REGEX=https://*
# all _COOKIE_SECURE both False/True Some permutations look like they're working when they're set to In addition, I've also played with trying to add # deployment.yaml
spec:
hostAliases:
- ip: "127.0.0.1"
hostnames:
- "auth.v1.domain.com"
- "fief-server.kops.svc"
# IP Address of Ingress Controller that is forwarding requests
- ip: "10.0.45.151"
hostnames:
- "localhost"
- "auth.v1.domain.com"
- "fief-server.kops.svc"
As for Any tips would be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 11 replies
-
Hi @trisongz 👋 Welcome to Fief! First of all, I would like to say that I'm not very versed in the arts of Kubernetes... But I'll try to help as much as I can! The key thing to understand is that your main workspace should be accessible both from the inside and the outside with the same host. Fief determines the right workspace to use following the I think your best bet is to stick with the "public domain":
I'll let you explore this and let us know what happens :) |
Beta Was this translation helpful? Give feedback.
-
Hi Guys, I am running it on k8s as well, however the application is being killed for no reason. The only message i see on the logs is this one: 2023-12-05 12:06:12,084 WARN exited: fief-server (terminated by SIGKILL; not expected) The server is stopping, but i dont have any clue why it is happening. https://docs.fief.dev/self-hosting/environment-variables/ on the documentation is says i can add LOG_LEVEL env var, but i tried to add debug or 1, as a value, but it doesn't accept. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
For anyone interested, I was able to get running on k8s with this helm chart. values.yaml
deployment.yaml
email-config.yaml
ingress.yaml
postgresql-pvc.yaml
service.yaml
|
Beta Was this translation helpful? Give feedback.
Hi @trisongz 👋 Welcome to Fief!
First of all, I would like to say that I'm not very versed in the arts of Kubernetes... But I'll try to help as much as I can!
The key thing to understand is that your main workspace should be accessible both from the inside and the outside with the same host. Fief determines the right workspace to use following the
Host
header.I think your best bet is to stick with the "public domain":
domain
: it should be the value ofFIEF_DOMAIN
, i.e.auth.v1.domain.com