@@ -525,6 +525,98 @@ The template becomes now:
525
525
RUN cp /additions/jenkins/jenkins.json /jenkins.json
526
526
{% endblock %}
527
527
528
+ Custom docker templates
529
+ -----------------------
530
+
531
+ In order to unify the process of managing OpenStack-related projects, Kolla
532
+ provides a way of building images for external 'non-built-in' projects.
533
+
534
+ If the template for a 'non-built-in' project meets Kolla template standards,
535
+ an operator can provide a root directory with a template via the
536
+ ``--docker-dir `` CLI option (can be specified multiple times).
537
+
538
+ All Kolla's jinja2 macros should be available the same as for built-in
539
+ projects with some notes:
540
+
541
+ - The ``configure_user `` macro. As the 'non-built-in' user is unknown to Kolla,
542
+ there are no default values for user ID and group ID to use.
543
+ To use this macro, an operator should specify "non-default" user details
544
+ with ``<custom_user_name>-user `` configuration section and include info
545
+ for ``uid `` and ``gid `` at least.
546
+
547
+ Let's look into how an operator can build an image for an in-house project
548
+ with Kolla using `openstack/releases <https://opendev.org/openstack/releases >`_
549
+ project.
550
+
551
+ First, create a ``Dockerfile.j2 `` template for the project.
552
+
553
+ .. path /home/kolla/custom-kolla-docker-templates/releaser/Dockerfile.j2
554
+ .. code-block :: jinja
555
+
556
+ FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }}
557
+
558
+ {% block labels %}
559
+ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build_date }}"
560
+ {% endblock %}
561
+
562
+ {% block releaser_header %}{% endblock %}
563
+
564
+ {% import "macros.j2" as macros with context %}
565
+
566
+ {{ macros.configure_user(name='releaser') }}
567
+
568
+ RUN ln -s releaser-source/* /releaser \
569
+ && {{ macros.install_pip(['/releaser-source'] | customizable("pip_packages")) }} \
570
+ && mkdir -p /etc/releaser \
571
+ && chown -R releaser: /etc/releaser \
572
+ && chmod 750 /etc/sudoers.d \
573
+ && touch /usr/local/bin/kolla_releaser_extend_start \
574
+ && chmod 644 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_releaser_extend_start
575
+
576
+ {% block footer %}{% endblock %}
577
+
578
+ Suggested directory structure:
579
+
580
+ .. code-block :: console
581
+
582
+ custom-kolla-docker-templates
583
+ |__ releaser
584
+ |__ Dockerfile.j2
585
+
586
+ Then, modify Kolla's configuration so the engine can download sources and
587
+ configure users.
588
+
589
+ .. path /etc/kolla/kolla-build.conf
590
+ .. code-block :: ini
591
+
592
+ [releaser]
593
+ type = git
594
+ location = https://opendev.org/openstack/releases
595
+ reference = master
596
+
597
+ [releaser-user]
598
+ uid = 53001
599
+ gid = 53001
600
+
601
+ Last pre-check before building a new image - ensure that the new template
602
+ is visible for Kolla:
603
+
604
+ .. code-block :: console
605
+
606
+ $ kolla-build --list-images --docker-dir custom-kolla-docker-templates "^releaser$"
607
+ 1 : base
608
+ 2 : releaser
609
+ 3 : openstack-base
610
+
611
+ And finally, build the ``releaser `` image, passing the ``--docker-dir ``
612
+ argument:
613
+
614
+ .. code-block :: console
615
+
616
+ kolla-build --docker-dir custom-kolla-docker-templates "^releaser$"
617
+
618
+ Can I use the ``--template-override `` option for custom templates? Yes!
619
+
528
620
Custom repos
529
621
------------
530
622
0 commit comments