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

Init-Container fails, read-only filesystem - configMap volumes no longer writable #162

Closed
albamoro opened this issue Mar 22, 2018 · 12 comments
Milestone

Comments

@albamoro
Copy link

Just to give you the heads up in case you didn't already know, configMap volumes have been read-only since kubernetes 1.9.4.

kubernetes/kubernetes#58720

@solsson
Copy link
Contributor

solsson commented Mar 22, 2018

Thanks, I read that in the release notes but failed to draw the conclusion. It's a major bummer for this kind of experimentation, and maybe we need to prioritize something like #155.

@solsson solsson added this to the 4.0 milestone Mar 22, 2018
@solsson
Copy link
Contributor

solsson commented Mar 22, 2018

I think I saw some kind of flag to keep the legacy behavior, but right now I can't find it. In case someone wants to keep upgrading.

@solsson
Copy link
Contributor

solsson commented Mar 22, 2018

The first fix that comes to mind, apart from #155, is to mount the configmap only on the init container and share an emptyDir within the pod. init.sh would have to begin with a cp. Other ideas?

@clintfred
Copy link

I also ran into this yesterday. I ended up mounting the ConfigMap to /etc/opt and then wrote the modified files to an empty config volume. I'm not claiming this is the best solution, but it does seem to work.

If anyone wants to save themselves some time, you can grab the code at https://github.com/clintfred/kubernetes-kafka/tree/gke-startup-patch.
Warning: That branch also contains the changes for #160

@solsson I'm happy to PR my fix back here if you want it.

@clintfred
Copy link

I also noticed that the pzoo init container is using a full kafka docker image, but I don't think that's needed. Maybe it could use something slimmer? zoo does use a different container for init.

@albamoro
Copy link
Author

albamoro commented Mar 22, 2018 via email

@solsson
Copy link
Contributor

solsson commented Mar 23, 2018

@clintfred @albamoro Does #163 match your solutions?

I also noticed that the pzoo init container is using a full kafka docker image, but I don't think that's needed

I want to keep using the zk release shipped with Kafka, due to things like https://issues.apache.org/jira/browse/ZOOKEEPER-2960 making it into zk releases. The idea with the default image here is that it should be as plain a Kafka distribution as possible.

@albamoro
Copy link
Author

yup, #163 describes the same workaround I used.

@clintfred
Copy link

It's close to my solution. The one functional difference I see is that mine leaves only the .properties file in /etc/kafka, instead of all the files in the configmap, which I would consider slightly cleaner.

@solsson regarding the container for the init-config I'm just noting the discrepancy between:

50kafka.yml

initContainers:
      - name: init-config
        image: solsson/kafka-initutils@sha256:c98d7fb5e9365eab391a5dcd4230fc6e72caf929c60f29ff091e3b0215124713

vs

50pzoo.yml and 51zoo.yml

initContainers:
      - name: init-config
        image: solsson/kafka:1.0.1@sha256:1a4689d49d6274ac59b9b740f51b0408e1c90a9b66d16ad114ee9f7193bab111

Maybe the whole kafka:1.0.1 is needed in the init container for pzoo and zoo but not for kafka?

@solsson
Copy link
Contributor

solsson commented Mar 23, 2018

Thanks @clintfred for spotting this. I've pushed 2621880 to address this.

With a growing interest for tools like skaffold I think it wil be more commonplace for kubernetes users to iterate on config using image builds. It can be as productive as the ConfigMap use in this repo, but with better support for rolling updates and a more seamless transition to production builds (compared to #155).

We do need to iterate on config in production-to-be clusters, i.e. minikube etc won't do, for things like #78. Maybe the way to go for this repo is to include Dockerfiles and recommend a couple of tools that make config iterations as easy as with docker-compose.

@gladiatr72
Copy link

@clintfred yeah. That does work, but the problem is that this is now just part of the scaffolding of nearly every deployment. I guess that's why Jesus gave us init-containers, hm? So now we can have a shared emptydir with an init-container that says "cp /opt/config/thing /etc/thing/config" for everything. I believe that most file operations will try to use the directory of the target file for any work-related functions unless the program's author explicitly directs such operations to not that directory. (e.g.: sed's in-place editing (maybe perl's too) actually writes its changes to a new file (in the same directory) and then renames it to overwrite the original.

I don't have a magic solution for the mentioned CVE, but this erm... solution was naively imagined and contrary to the other bugs that have to wait a year before a alpha/beta/GAmeh/GA release-cycle, this one seems to have been back-ported all the way to 1.7.

@solsson
Copy link
Contributor

solsson commented Apr 8, 2018

Closed with #163

@solsson solsson closed this as completed Apr 8, 2018
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

No branches or pull requests

4 participants