Closed Jaorji closed 4 years ago
I got error when I use basePath here
basePath´ was removed. It was only used in liveness and readiness probes, which are freely configurable anyways. However, since probe configurations are passed through the
tplfunction, you are free to configure
basepath` on your own and use it. It seems you are exactly doing this which should work. I just tested your configuration with out any issues. What error are you getting?
I think the issue is that in previous versions of this helm chart basepath
was used to not only change liveness and readiness probe url but also default context of the Keycloak server from auth
to something else like in the example above to xji/auth
. In 9.0.1 basepath
is not used chart templates and regardless of its setting Keycloak server context is always /auth
.
@unguiculus @damianjaniszewski Thank you so much for answer my question. I'm trying to upgrade keycloak from 7.3.0 to 9.0.1 since we have sync problems between two keycloak pods. However the basepath we have is /{{release.namespace}}/auth. Is there any way to set bathpath like that? Here is the liviness prob and readiness prob link: And I got 404 👍
@damianjaniszewski basepath
was not used for anything else than liveness and readiness probes in previous releases. If you want to have a different path, you'd have to configure that using a WildFly CLI script.
@Jaorji You can do something like this:
livenessProbe: |
httpGet:
path: /{{ .Release.Namespace }}/auth/
port: http
initialDelaySeconds: 300
timeoutSeconds: 5
@unguiculus I have tried this:
httpGet:
path: /xji/auth/
port: http
initialDelaySeconds: 300
timeoutSeconds: 5
However the log shows: (ServerService Thread Pool -- 66) WFLYUT0022: Unregistered web context: '/auth' from server 'default-server'
And I got 404 when I access the endpoint:
If I can use WildFly CLI script., can you please give me an example on this.
@damianjaniszewski
basepath
was not used for anything else than liveness and readiness probes in previous releases. If you want to have a different path, you'd have to configure that using a WildFly CLI script.
cli:
custom: |
is removed too?
Please read upgrade notes for changes and why they were done. https://github.com/codecentric/helm-charts/tree/master/charts/keycloak#from-chart-versions--900
The charts supports the startup script functionality of the official Docker image.
See https://github.com/keycloak/keycloak-containers/tree/master/server#running-custom-scripts-on-startup
startupScripts:
mycustom.cli: |
# CLI contents here
removing this basepath setting is fairly disruptive for our use. we use different basepaths depending on our software configuration. now we have to manually add the liveness, readiness, ingress rule and the custom cli script every time we want to change the basepath.
when we create these wildfly scripts that change our web-context / basepath, do we also need to determine if we are running with replicas > 1 in order to decide if we're using standalone.xml or standalone-ha.xml? the old chart setup was able to handle that difference for us.
I am impacted by the removal of basepath. I used it to shorten the url, removing the /auth/ part.
basePath´ was removed. It was only used in liveness and readiness probes, which are freely configurable anyways. However, since probe configurations are passed through the
tplfunction, you are free to configure
basepath` on your own and use it. It seems you are exactly doing this which should work. I just tested your configuration with out any issues. What error are you getting?
@unguiculus It was also used here : https://github.com/codecentric/helm-charts/blob/keycloak-8.3.0/charts/keycloak/templates/configmap-startup.yaml
@danvy 100%. this was super important. having this single tuneable option for the basepath really made this helm chart worthwhile for us.
You're correct. I was actually used to reconfigure Wildfly. Sorry for my confusion. As mentioned, it is possible to configure the chart for a different basepath. Here's how:
basepath: foo
startupScripts:
basepath.cli: |
embed-server {{- if gt (int .Values.replicas) 1 }} --server-config=standalone-ha.xml{{ end }} --std-out=echo
batch
{{- if ne .Values.basepath "auth" }}
/subsystem=keycloak-server:write-attribute(name=web-context,value={{ if eq .Values.basepath "" }}ROOT{{ else }}{{ .Values.basepath }}{{ end }})
{{- if eq .Values.basepath "" }}
/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module,value=keycloak-server.war)
{{- end }}
{{ end }}
run-batch
stop-embedded-server
livenessProbe: |
httpGet:
path: /{{ .Values.basepath }}/
port: http
initialDelaySeconds: 300
timeoutSeconds: 5
readinessProbe: |
httpGet:
path: /{{ .Values.basepath }}/realms/master
port: http
initialDelaySeconds: 30
timeoutSeconds: 1
I can add a section to the readme. Would that work for everyone?
@unguiculus that would be great if you can add this to readme.
You're correct. I was actually used to reconfigure Wildfly. Sorry for my confusion. As mentioned, it is possible to configure the chart for a different basepath. Here's how:
basepath: foo startupScripts: basepath.cli: | embed-server {{- if gt (int .Values.replicas) 1 }} --server-config=standalone-ha.xml{{ end }} --std-out=echo batch {{- if ne .Values.basepath "auth" }} /subsystem=keycloak-server:write-attribute(name=web-context,value={{ if eq .Values.basepath "" }}ROOT{{ else }}{{ .Values.basepath }}{{ end }}) {{- if eq .Values.basepath "" }} /subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module,value=keycloak-server.war) {{- end }} {{ end }} run-batch stop-embedded-server livenessProbe: | httpGet: path: /{{ .Values.basepath }}/ port: http initialDelaySeconds: 300 timeoutSeconds: 5 readinessProbe: | httpGet: path: /{{ .Values.basepath }}/realms/master port: http initialDelaySeconds: 30 timeoutSeconds: 1
I can add a section to the readme. Would that work for everyone? @unguiculus It partialy works. I edited probes like this so it works with an empty basepath
livenessProbe: |
httpGet:
path: {{ if ne .Values.basepath "" }}/{{ .Values.basepath }}{{ end }}/
port: http
initialDelaySeconds: 300
timeoutSeconds: 5
readinessProbe: |
httpGet:
path: {{ if ne .Values.basepath "" }}/{{ .Values.basepath }}{{ end }}/realms/master
port: http
initialDelaySeconds: 30
timeoutSeconds: 1
the startup creates a file called /opt/jboss/startup-scripts/basepath.cli containing :
embed-server --std-out=echo
batch
/subsystem=keycloak-server:write-attribute(name=web-context,value=ROOT)
/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module,value=keycloak-server.war)
run-batch
stop-embedded-server
I confirm that the standalone.xml file is modified but the service is still bound to /auth
I found that I have to modify the standalone-ha.xml file even if I only have 1 replica. https://hub.docker.com/r/jboss/keycloak/ says : "It's also worth to mention, that by default, keycloak uses standalone-ha.xml configuration (unless other server configuration is specified)." In the end I used :
basepath: ""
startupScripts:
basepath.cli: |
embed-server --server-config=standalone-ha.xml --std-out=echo
batch
{{- if ne .Values.basepath "auth" }}
/subsystem=keycloak-server/:write-attribute(name=web-context,value={{ if eq .Values.basepath "" }}/{{ else }}{{ .Values.basepath }}{{ end }})
{{- if eq .Values.basepath "" }}
/subsystem=undertow/server=default-server/host=default-host:write-attribute(name=default-web-module,value=keycloak-server.war)
{{- end }}
{{- end }}
run-batch
stop-embedded-server
livenessProbe: |
httpGet:
path: {{ if ne .Values.basepath "" }}/{{ .Values.basepath }}{{ end }}/
port: http
initialDelaySeconds: 300
timeoutSeconds: 5
readinessProbe: |
httpGet:
path: {{ if ne .Values.basepath "" }}/{{ .Values.basepath }}{{ end }}/realms/master
port: http
initialDelaySeconds: 30
timeoutSeconds: 1
And now, it works.
@danvy You right, the Docker image automatically uses standalone-ha.xml
unless you specify something else. So, my check for the number of replicas was unnecessary as you realized correctly.
@danvy is this in a values file that you pass to this helm chart? or are you altering this helm chart with that values file? either way, i wasn't aware that you could use if statements inside the values you pass into a helm chart. or are you preprocessing this as a template somehow?
(edit) oh! I missed that these are string blocks that get templated again inside the chart. at least, I think thats what I'm seeing.
@rexroof Exactly, they are templated using the tpl
function.
I added documentation here: https://github.com/codecentric/helm-charts/pull/298
Please have a look and review. Thanks.
@Jaorji @damianjaniszewski @rexroof @danvy @zodiac1214
keycloak: 9.0.1 docker image: 11.0.0