use of nginx.jsonnet in task, and running kapitan in docker

31 views
Skip to first unread message

Yoshiaki Nishimura

unread,
Mar 10, 2019, 12:18:18 PM3/10/19
to kapitan-discuss
Hi mentors and students,

I have a couple of questions with regards to the use of nginx.jsonnet.

1. In my understanding, jsonnet is used to generate yaml files in kapitan, such as in all the examples from https://github.com/ademariag/kapitan-examples (thanks to Pranav for mentioning): as for all other files such as .md and .sh, we use jinja2 templates because they are not well-formed JSON or YAML.

Since nginx.conf is definitely not JSON or YAML, I'm thinking we should use jinja2 templates. But in that case, what is the use of components/nginx/nginx.jsonnet which is given in the task description?

2. Also, should we generate both nginx.conf or default.conf or both?

Another point is on docker: when I ran

docker run -t --rm -v $(pwd):/src:delegated deepmind/kapitan compile

as recommended in the README.md, which runs just fine and compiles, the compiled folder generated within the container and mapped back to the host machine is owned by root and not the user who ran docker, so every time I need to chown/chmod to see the contents of compiled. Are we expected to create our own container on top of deepmind/kapitan image that creates non-root user in the container prior to running compile, or am I doing something wrong?

I referred to this issue and other sources on this docker problem.

Thank you so much for helping out!

Yoshi

Pawel Sarbinowski

unread,
Mar 10, 2019, 1:28:47 PM3/10/19
to Yoshiaki Nishimura, kapitan-discuss
Hi Yoshiaki,

Both very valid questions. :) 

1) You are right about the generation with just jinja2 and jsonnet is not necessary I've updated the task description to avoid future confusion. I had added that as a proposed way based on how most kapitan projects are organized but in this particular case it's not needed.

2) You can generate your_site.conf (and thus put it in /etc/nginx/conf.d ) or you can use nginx.conf and put it under /etc/nginx/. The goal of the task is to use kapitan to generate several templated configs for nginx and accompanying run.sh scripts to run the sample configs. Specific implementation details are left to you since they don't directly have to do with actually using kapitan.

For the docker generation you aren't expected to create your own dockerfile image. It's not really easy to generate the compiled/ output with correct permissions from within the container of kapitan as the user namespaces will differ between various hosts and container. It might just be an easier solution to install kapitan through pip and use it that way to compile your project. Use pyenv https://github.com/pyenv/pyenv if you don't want to install kapitan globally. 

Ideally what we'd like to receive from students would be a directory where we can run `kapitan compile` to generate the configs and then just `./compiled/<dev>/run.sh` to run a sample nginx container with the sample config. That's all. 
We're interested in seeing that you understand how the inventory works and how kapitan is configured/used.

Hope this helps and let me know if there are other questions,
Pawel

--
You received this message because you are subscribed to the Google Groups "kapitan-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kapitan-discu...@googlegroups.com.
To post to this group, send email to kapitan...@googlegroups.com.
Visit this group at https://groups.google.com/group/kapitan-discuss.
To view this discussion on the web visit https://groups.google.com/d/msgid/kapitan-discuss/35c87b4b-87c9-42d3-965e-2bbff038932a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Pawel Sarbinowski | DevOps Engineer | paw...@google.com 

Yoshiaki Nishimura

unread,
Mar 10, 2019, 3:16:52 PM3/10/19
to kapitan-discuss
Hi Pawel,

Thank you for such a swift response!

All the points noted, I will use kapitan on the command line to complete this mini project.

Thank you again for the clarification!

Yoshi
Reply all
Reply to author
Forward
0 new messages