How to run sed command in init container in kubernetes?

5/8/2020

I have keycloak running in my cluster so i wanted to change the default context-web path which is auth to somehting like keycloak/auth so i can access it through myhost/keycloak/auth/ i added an init container to run this command but it shows me :

Error from server (BadRequest): container "keycloak" in pod "keycloak-6df9d8968d-l7t9b" is waiting to start: PodInitializing

i believe that the command syntax in the init container is wrong because i tried it manually and it worked

Here is the init container :

...
initContainers:
       - name: keycloak-init
         image: busybox
         command: [sed, -i, -e, 's/<web-context>auth<\/web-context>/<web-context>keycloak\/auth<\/web-context>/', /opt/jboss/keycloak/standalone/configuration/standalone.xml]
...
-- touati ahmed
keycloak
kubernetes
shell

1 Answer

5/8/2020

The main container is not starting because there is an error in the initContainer container, as you could see from the logs.

sed: /opt/jboss/keycloak/standalone/configuration/standalone.xml: No such file or directory 

Probably you are forgetting to mount the volume with this file also in the initContainer

-- Marcelo
Source: StackOverflow