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

HAL on OpenShift #708

Merged
merged 8 commits into from
Dec 19, 2024
Merged

HAL on OpenShift #708

merged 8 commits into from
Dec 19, 2024

Conversation

hpehl
Copy link
Contributor

@hpehl hpehl commented Dec 18, 2024

Blog post about how to access the management console for WildFly instances running on OpenShift.

Preview: https://hpehl.github.io/wildfly.org/news/2024/12/18/Management-Console-on-OpenShift/

Copy link
Member

@jmesnil jmesnil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hpehl That looks great but I have a few questions :)

_posts/2024-12-18-Management-Console-on-OpenShift.adoc Outdated Show resolved Hide resolved
_posts/2024-12-18-Management-Console-on-OpenShift.adoc Outdated Show resolved Hide resolved
. Open https://hal.github.io/console
. Add a management interface to the public route:
+
Give an arbitrary name, select *https* as scheme, enter the hostname of the public route _without_ https and port *80*:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I do this and click on Ping, nothing happens. Is it normal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally that should show the browser login modal and prompt for the username and password. Somehow this does not work for OpenShift. But you are able to login anyway, aren't you?

+
image::hal/add-management-interface.png[Add management interface]
. Click *Add* and then *Connect*
. Login using `admin:admin`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I did this to connect to the deployment created with ocnew-app quay.io/halconsole/wildfly, I got the error:

Status 401 - Unauthorized.

The management console could not be loaded.

If you changed your access control provider to RBAC, make sure that your configuration has current user mapped to one of the RBAC roles, preferably with at least one in the Administrator or SuperUser role.

If you have started with one of the standard xml configurations shipped with WildFly, the "$local" user should be mapped to the "SuperUser" role and the "local" authentication scheme should be enabled. This should allow a user running the CLI on the same system as the WildFly process to have full administrative permissions. Remote CLI users and web-based admin console users will have no permissions.

You should map at least one user besides "$local". Try to use CLI or shut the installation down and edit the xml configuration.

That seems weird as I was able to connect as admin:admin on the local HAL console.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does a browser refresh or private mode help?

Copy link
Contributor Author

@hpehl hpehl Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried to reproduce that. This is what I did:

  1. Create the app
oc new-app quay.io/halconsole/wildfly
oc create route edge --service wildfly --port 9990
  1. Open https://hal.github.io/console
  2. Add the management interface. Please make sure to use port 80.
  3. Connect and login using admin:admin

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird, it still fails for me.

I thought that was due to the /core-service=management/management-interface=http-interface:list-add(name=allowed-origins,value=https://<hostname>) on my deployment but even with a fresh deployment it fails (using Chrome incognito mode)

@jmesnil
Copy link
Member

jmesnil commented Dec 18, 2024

@hpehl This goes beyond what you are doing in this example but there are a few things to keep in mind:

  • Changing the management configuration of a pod is an anti pattern as it will not outlive a pod restart. At that point, you'll have again to perform the /core-service=management/management-interface operation. We need to find a way to persist that config in the container to survive restart. The route can be created before the deployment so we can now its value ahead of time. We can then pass it to the deployment as an env var and use it for the /core-service=management/management-interface operation. However this operation should ideally be done at build time so it's intrinsically part of the deployment configuration.
  • With a route, you are accessing pods behind a service. If your deployments have multiple pods, it's very complex (and hacky) to access a specific pod.
  • What is missing from quay.io/wildfly/wildfly to use it instead of quay.io/halconsole/wildfly? I've already opened Update README jboss-dockerfiles/wildfly#237 and we can add instructions to configure CORS as required.

@hpehl
Copy link
Contributor Author

hpehl commented Dec 18, 2024

Thanks for the feedback @jmesnil. I think it makes sense to add some of your comments as "Things to keep in mind" in the post.

Copy link
Member

@jmesnil jmesnil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm thanks

On the limitations, I wrote down some notes at jboss-dockerfiles/wildfly#237 (comment) to make the configuration persistent (and still configurable at runtime for the route host)

Copy link
Contributor

@bstansberry bstansberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about admin:admin. It needs to be clear that that's for use in dev, etc type environments where no harm can be done.

The console uses the https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API[fetch API] to talk to the management interface of a running WildFly instance. In an OpenShift environment, the origins of the public route and the management interface itself are different. That's why we need to tell WildFly that it is ok to make requests to the management interface from another origin (see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS[CORS policies] for more details).

You can build such an image on your own based on the official WildFly images available at https://quay.io/repository/wildfly/wildfly[quay.io/wildfly/wildfly] (see "Extending the image"). Another way is to use the pre-built images from https://quay.io/repository/halconsole/wildfly[quay.io/halconsole/wildfly]. These images are mainly meant for HAL development and testing but already meet these requirements, which makes them suitable for our use case. In particular the images add a management user `admin:admin` and have a list of preconfigured allowed origins.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a WARNING admonition block saying this preconfigured admin:admin setup is for development purposes or something? I'd be concerned if people start running this in production and relying only on allowed-origins to control access.


* Changing the management configuration of a pod is an antipattern as it will not outlive a pod restart. At that point, you'll have to reconfigure the allowed origin.
* With a route, you are accessing pods behind a service. If your deployments have multiple pods, it's complex and hacky to access a specific pod or configure all pods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add something about not using admin:admin in an insecure environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@hpehl
Copy link
Contributor Author

hpehl commented Dec 18, 2024

Thanks for the feedback @bstansberry
I've added warnings and updated the preview.


You can build such an image on your own based on the official WildFly images available at https://quay.io/repository/wildfly/wildfly[quay.io/wildfly/wildfly] (see "Extending the image"). Another way is to use the pre-built images from https://quay.io/repository/halconsole/wildfly[quay.io/halconsole/wildfly]. These images are mainly meant for HAL development and testing but already meet these requirements, which makes them suitable for our use case. In particular the images add a management user `admin:admin` and have a list of preconfigured allowed origins.

WARNING: The additions in the https://quay.io/repository/halconsole/wildfly[quay.io/halconsole/wildfly] images are only meant for development and testing purposes. Please do not rely on the management user `admin:admin` or the preconfigured allowed origins. It is strongly recommended not to use that in production!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/It is strongly recommend not to use/Do not use/g

Probably in bold.

Copy link
Contributor

@bstansberry bstansberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Harald.

I suggest a bit stronger wording on the WARNING, although I realize people and cultures can feel differently about that kind of phrasing. Your wording or mine though, I think bolding it would be good.

@hpehl
Copy link
Contributor Author

hpehl commented Dec 19, 2024

Ok, got it 😉

I rephrased the warning and "Things to keep in mind" section to make it unmistakable to not use it in production.

@bstansberry bstansberry merged commit e89b5f5 into wildfly:main Dec 19, 2024
@bstansberry
Copy link
Contributor

Thanks @hpehl and @jmesnil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants