Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better integration with Kubernetes healthcheck #863

Open
5 tasks
hirisov opened this issue Aug 14, 2024 · 2 comments
Open
5 tasks

better integration with Kubernetes healthcheck #863

hirisov opened this issue Aug 14, 2024 · 2 comments
Labels
needs-investigation An issue where futhur investigation is required question A question about NuxtAuth

Comments

@hirisov
Copy link

hirisov commented Aug 14, 2024

Describe the feature

When we try to host our nuxt3 + nuxt-auth project in kubernetes, we run into the following problem:

For kubernetes, we need a healthcheck which responds with 200 if the application is up. This healthcheck must be provided before nuxt-auth is initialized, since nuxt-auth returns 503 until it is able to reach the own hostname.

In kubernetes, the own hostname is reachable, if the healthcheck is successful.

This is now a chicken-egg problem, nuxt-auth cannot initialize correctly as the hostname is not assigned to the container, but kubernetes does not assign the hostname as the application is not correctly initialized.

How would you implement this?

It would be great to have a healthckech route provided this package that returns 200 status even before nuxt-auth is fully initialized. If we just add a simple healthcheck server middleware, that still returns 503 as the nuxt-auth package itself returns 503.

Additional information

  • Would you be willing to help implement this feature?

Provider

  • AuthJS
  • Local
  • Refresh
  • New Provider
@hirisov hirisov added enhancement An improvement that needs to be added pending An issue waiting for triage labels Aug 14, 2024
@hirisov hirisov changed the title better integration with Kubernetes healthckeck better integration with Kubernetes healthcheck Aug 14, 2024
@warflash
Copy link

Could you share a bit about your setup? I don't quite understand why a startup or readiness probe would need to interact with authentication state

@phoenix-ru phoenix-ru added question A question about NuxtAuth needs-investigation An issue where futhur investigation is required and removed enhancement An improvement that needs to be added pending An issue waiting for triage labels Aug 15, 2024
@zoey-kaiser
Copy link
Member

zoey-kaiser commented Aug 20, 2024

Hi @hirisov 👋

We also use this health check for our Kubernetes applications. In our case we just created a non-protected API route that we then defined as our health check URL.

// file: ~/server/api/health.get.ts
const startupTime = new Date()

export default defineEventHandler(() => ({
    status: 'healthy',
    time: new Date(),
    startupTime,
    version: useRuntimeConfig().version
}))

Is this possible to do in your setup?

Returning 200 from e.g. a client-side route (such as the index page) for a health check would not be the solution here in my opinion. If we returned 200, even though the page was protected, this would be a "lie", as the response code should be 401 and not 200.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-investigation An issue where futhur investigation is required question A question about NuxtAuth
Projects
None yet
Development

No branches or pull requests

4 participants