adfinis / openshift-mariadb-galera

Kubernetes / OpenShift Images for a MariaDB Galera Cluster
GNU General Public License v3.0
37 stars 42 forks source link

Add the required user security context for 1.6+ clusters #14

Closed lewismarshall closed 6 years ago

lewismarshall commented 6 years ago

When testing with kubernetes 1.8 (should be 1.6+), get a permission denied with the mkdir -p /var/lib/mysql/mysql unless the correct user context is set.

lewismarshall commented 6 years ago

Hi @tongpu, I've pushed a change as I had the initial group context wrong and had missed the securityContext for the container. I also fixed the README.md where the new file was referenced.

karras commented 6 years ago

@tongpu bump

lewismarshall commented 6 years ago

@tongpu OK tested the change: you happy if I squash?

> docker build -t galtest ./k8s-mariadb-galera-centos/ && \
     mkdir -p /tmp/galtest && \
     sudo chown 27:27 /tmp/galtest && \
     docker run -d -v /tmp/galtest:/var/lib/mysql --name galtestrun galtest && \
     docker exec -it galtestrun ps xo pid,cmd,uid,gid

...

Successfully built ce7740cc4e1a
Successfully tagged galtest:latest
8c3dbed7bbe6291637bd66f71ef25fd5465248a6789c57d45721237ceef26427
  PID CMD                           UID   GID
    1 /bin/bash /usr/bin/containe    27    27
    7 /bin/bash /usr/share/contai    27    27
    8 /bin/sh /usr/bin/mysql_inst    27    27
   28 /bin/sh /usr/bin/mysql_inst    27    27
   29 /usr/sbin/mysqld --lc-messa    27    27
   32 ps xo pid,cmd,uid,gid          27    27

And...

> docker logs galtestrun 2>&1 | tail -5
2018-02-27 12:14:21 140667170846464 [Note] InnoDB: Dumping buffer pool(s) not yet started
2018-02-27 12:14:21 140667975141632 [Note] Plugin 'FEEDBACK' is disabled.
2018-02-27 12:14:21 140667975141632 [Note] Server socket created on IP: '0.0.0.0'.
2018-02-27 12:14:21 140667975141632 [Note] mysqld: ready for connections.
Version: '10.1.30-MariaDB'  socket: '/var/run/mysql/mysql.sock'  port: 3306  MariaDB Server
tongpu commented 6 years ago

Feel free to squash. I'll test the changes and merge the PR if successful.

lewismarshall commented 6 years ago

@tongpu all squashed

tongpu commented 6 years ago

Thanks for the contribution @lewismarshall. We're going to release the changes docker images with USER 27:27 as v004, so you'll need to update the docker image version in the future.