[kolla] Image building question

Sean Mooney smooney at redhat.com
Fri Mar 31 17:31:01 UTC 2023


On Fri, 2023-03-31 at 10:25 -0400, Satish Patel wrote:
> Thank you Sean,
> 
> What a wonderful explanation of the process. Yes I can download images from
> the public domain and push them to a local repository but in some cases I
> would like to add my own tools like monitoring agents, utilities etc
> for debugging so i decided to build my own images.
> 
> I believe https://tarballs.opendev.org is the right place to source
> software correctly?
that is the offcial location where all opendev/openstack projects are released
and its the location distros use to build there packages.
> 
> If I want to add some tools or packages inside images then I should use
> Dockerfile.j2 to add and compile images. correct?

yes so one of the great things about kolla images is tiem was taken to write
down the image api when the project was first started
https://docs.openstack.org/kolla/yoga/admin/kolla_api.html

over time the common usecaes were then docuemnted in the admin image-building guide
https://docs.openstack.org/kolla/yoga/admin/image-building.html#dockerfile-customisation


all of the templated imnages have convension/contract that they provide delement that operator can
use to add customisations.

for examplel the nova_base_footer block and be used to add addtional content to the nova-base image
https://github.com/openstack/kolla/blob/master/docker/nova/nova-base/Dockerfile.j2#L82

to customise the iamges you provide what is know as a template override file

the contrib folder has a number of exmaples

https://github.com/openstack/kolla/blob/master/contrib/template-override/ovs-dpdk.j2
https://github.com/openstack/kolla/blob/master/contrib/neutron-plugins/template_override-networking-mlnx.j2
https://github.com/openstack/kolla/blob/master/contrib/neutron-plugins/template_override-vmware-nsx.j2


the way they work is you starte it with 

{% extends parent_template %}

then you just create a block that mages the name of the one you want to repalce
{% extends parent_template %}

{% block nova_base_footer %} 
 RUN /bin/true
{% endblock %}


what ever content you put in the block will be injected directly into the rendered docer file


https://docs.openstack.org/kolla/yoga/admin/image-building.html#plugin-functionality

show how to use that for neutron 

in addtion to replacing block you can set the conten of specal variables
like horizon_packages_append or horizon_packages_remove

https://docs.openstack.org/kolla/yoga/admin/image-building.html#packages-customisation

that allow you add an remove packages in a simple way
there is also a set of macros that you can use

you include them with 
{% import "macros.j2" as macros with context %}

they are defiend here
https://github.com/openstack/kolla/blob/master/docker/macros.j2

if you know that the docs exist the capablitys are coverd pretty well in the kolla docs you just need to know where to look
hopefully that helps.

the ovs-dpdk template overide docs can be fouund here https://docs.openstack.org/kolla/yoga/admin/template-override/ovs-dpdk.html

its a liltle differnt then the other since there i used the template override mechanium to allow compiling ovs with dpdk form souces

kolla normlly does not support that but it serves as a demonstration for how operator can do that if they really need too.
i.e. compile a replacment for a minary componet like mariadb. it salso show how to use git as the souce localtion instead
of tars if that is your prefernce.

> 
> ~S
> 
> On Fri, Mar 31, 2023 at 7:01 AM Sean Mooney <smooney at redhat.com> wrote:
> 
> > On Thu, 2023-03-30 at 16:49 -0400, Satish Patel wrote:
> > > Folks,
> > > 
> > > I am playing with kolla image building to understand how it works. I am
> > > using the following command to build images and wanted to check with you
> > > folks if that is the correct way to do it.
> > > 
> > > $ kolla-build -b ubuntu -t source keystone nova neutron glance
> > > 
> > > Does the above command compile code from source or just download images
> > > from remote repositories and re-compile them?
> > > 
> > openstack is mainly python so in general ther is no complie step.
> > but to answer your question that builds the image using the source tarballs
> > or the openstakc packages.
> > 
> > the defaults soruce locations are rendered into a file which you can
> > override
> > from the data stored in
> > https://github.com/openstack/kolla/blob/master/kolla/common/sources.py
> > the other build config defaults are generated form this code
> > https://github.com/openstack/kolla/blob/master/kolla/common/config.py
> > 
> > when you invoke kolla-build its executing
> > https://github.com/openstack/kolla/blob/master/kolla/cmd/build.py
> > but the main build workflow is here
> > https://github.com/openstack/kolla/blob/be15d6212f278027c257f9dd67e5b2719e9f730a/kolla/image/build.py#L95
> > 
> > the tl;dr is the build worklow starts by creating  build director and
> > locating the docker file templats.
> > in otherwords the content of the
> > https://github.com/openstack/kolla/tree/be15d6212f278027c257f9dd67e5b2719e9f730a/docker
> > directory
> > 
> > each project has a direcoty in the docker directory and then each
> > contaienr that project has has a directory in the project directory
> > 
> > so the aodh project has a aodh folder
> > https://github.com/openstack/kolla/tree/be15d6212f278027c257f9dd67e5b2719e9f730a/docker/aodh
> > the convention is to have a <project>-base contaienr which handels the
> > depency installation and then one addtional contaienr for each binary deamon
> > the project has i.e. aodh-api
> > 
> > the name of the folder in teh project dir is used as the name of the
> > contaienr
> > 
> > if we look at the content of the docker files we will see that they are
> > not actuly dockerfiles
> > 
> > https://github.com/openstack/kolla/blob/be15d6212f278027c257f9dd67e5b2719e9f730a/docker/aodh/aodh-api/Dockerfile.j2
> > 
> > they are jinja2 templates that produce docker files
> > 
> > kolla as far as i am aware has drop support for binary images and
> > alternitiv distos
> > 
> > but looking at an older release we can se ehow this worked
> > 
> > https://github.com/openstack/kolla/blob/stable/wallaby/docker/nova/nova-base/Dockerfile.j2#L13-L52
> > 
> > each docker file template would use the jinja2 to generate a set of
> > concreate docker files form the template
> > and make dession based on the parmater passed in.
> > 
> > so when you are invokeing
> > kolla-build -b ubuntu -t source keystone nova neutron glance
> > 
> > what actully happening is that the -t flag is being set as teh
> > install_type parmater in the the jinja2 environemtn when
> > the docker file is rendered.
> > 
> > after all the docer files are rendered into normal docker files kolla just
> > invokes the build.
> > 
> > in the case of a source build that inovles pre fetching the source tar
> > from https://tarballs.opendev.org
> > and puting it in the build directory so that it can be included into the
> > contianer.
> > 
> > kolla also used to supprot git repo as a alternitve  source fromat
> > 
> > i have glossed over a lot of the details of how this actully work but that
> > is the essence of what that command is doing
> > creating a build dir, downloading the source, rendering the dockerfile
> > templates to docker files, invokeing docker build on those
> > and then taging them with the contaienr nameand build tag
> > 
> > 
> > https://docs.openstack.org/kolla/latest/admin/image-building.html
> > covers this form a high level
> > 
> > >   because in command output
> > > I've not noticed anything related to the compiling process going on.
> > > 
> > > Here is the output of all images produced by kolla-build command. Do I
> > need
> > > anything else or is this enough to deploy kolla?
> > you can deploy coll with what you have yes although since the kolla files
> > are automaticaly
> > built by ci kolla-ansible can just use the ones form the docker hub or
> > quay instead you do not need to build them yourself
> > 
> > if you do build them your self then there is basically one other stpe that
> > you shoudl take if this si a multi node deployment
> > you should push the iamges to an interally host docker registry although
> > based on the hostname in the prompt below
> > it looks like you ahve alredy done that.
> > > 
> > > root at docker-reg:~# docker images
> > > REPOSITORY                            TAG       IMAGE ID       CREATED
> > >         SIZE
> > > kolla/mariadb-server                  15.1.0    2a497eee8269   26 minutes
> > > ago      595MB
> > > kolla/cron                            15.1.0    342877f26a8a   30 minutes
> > > ago      250MB
> > > kolla/memcached                       15.1.0    0d19a4902644   31 minutes
> > > ago      250MB
> > > kolla/mariadb-clustercheck            15.1.0    d84427d3c639   31 minutes
> > > ago      314MB
> > > kolla/mariadb-base                    15.1.0    34447e3e59b6   31 minutes
> > > ago      314MB
> > > kolla/keepalived                      15.1.0    82133b09fbf0   31 minutes
> > > ago      260MB
> > > kolla/prometheus-memcached-exporter   15.1.0    6c2d605f70ee   31 minutes
> > > ago      262MB
> > > <none>                                <none>    e66b228c2a07   31 minutes
> > > ago      248MB
> > > kolla/rabbitmq                        15.1.0    8de5c39379d3   32 minutes
> > > ago      309MB
> > > kolla/fluentd                         15.1.0    adfd19027862   33 minutes
> > > ago      519MB
> > > kolla/haproxy-ssh                     15.1.0    514357ac4d36   36 minutes
> > > ago      255MB
> > > kolla/haproxy                         15.1.0    e5b9cfdf6dfc   37 minutes
> > > ago      257MB
> > > kolla/prometheus-haproxy-exporter     15.1.0    a679f65fd735   37 minutes
> > > ago      263MB
> > > kolla/prometheus-base                 15.1.0    afeff3ed5dce   37 minutes
> > > ago      248MB
> > > kolla/glance-api                      15.1.0    a2241f68f23a   38 minutes
> > > ago      1.04GB
> > > kolla/glance-base                     15.1.0    7286772a03a4   About an
> > > hour ago   1.03GB
> > > kolla/neutron-infoblox-ipam-agent     15.1.0    f90ffc1a3326   About an
> > > hour ago   1.05GB
> > > kolla/neutron-server                  15.1.0    69c844a2e3a9   About an
> > > hour ago   1.05GB
> > > kolla/neutron-l3-agent                15.1.0    4d87e6963c96   About an
> > > hour ago   1.05GB
> > > <none>                                <none>    486da9a6562e   About an
> > > hour ago   1.05GB
> > > kolla/neutron-linuxbridge-agent       15.1.0    e5b3ca7e099c   About an
> > > hour ago   1.04GB
> > > kolla/neutron-bgp-dragent             15.1.0    ac37377820c6   About an
> > > hour ago   1.04GB
> > > kolla/ironic-neutron-agent            15.1.0    90993adcd74b   About an
> > > hour ago   1.04GB
> > > kolla/neutron-metadata-agent          15.1.0    8522f147f88d   About an
> > > hour ago   1.04GB
> > > kolla/neutron-sriov-agent             15.1.0    8a92ce7d13c0   About an
> > > hour ago   1.04GB
> > > kolla/neutron-dhcp-agent              15.1.0    5c214b0171f5   About an
> > > hour ago   1.04GB
> > > kolla/neutron-metering-agent          15.1.0    7b3b91ecd77b   About an
> > > hour ago   1.04GB
> > > kolla/neutron-openvswitch-agent       15.1.0    1f8807308814   About an
> > > hour ago   1.04GB
> > > kolla/neutron-base                    15.1.0    f85b6a2e2725   About an
> > > hour ago   1.04GB
> > > kolla/nova-libvirt                    15.1.0    0f3ecefe4752   About an
> > > hour ago   987MB
> > > kolla/nova-compute                    15.1.0    241b7e7fafbe   About an
> > > hour ago   1.47GB
> > > kolla/nova-spicehtml5proxy            15.1.0    b740820a7ad1   About an
> > > hour ago   1.15GB
> > > kolla/nova-novncproxy                 15.1.0    1ba2f443d5c3   About an
> > > hour ago   1.22GB
> > > kolla/nova-compute-ironic             15.1.0    716612107532   About an
> > > hour ago   1.12GB
> > > kolla/nova-ssh                        15.1.0    ae2397f4e1c1   About an
> > > hour ago   1.11GB
> > > kolla/nova-api                        15.1.0    2aef02667ff8   About an
> > > hour ago   1.11GB
> > > kolla/nova-conductor                  15.1.0    6f1da3400901   About an
> > > hour ago   1.11GB
> > > kolla/nova-scheduler                  15.1.0    628326776b1d   About an
> > > hour ago   1.11GB
> > > kolla/nova-serialproxy                15.1.0    28eb7a4a13f8   About an
> > > hour ago   1.11GB
> > > kolla/nova-base                       15.1.0    e47420013283   About an
> > > hour ago   1.11GB
> > > kolla/keystone                        15.1.0    e5530d829d5f   2 hours
> > ago
> > >         947MB
> > > kolla/keystone-ssh                    15.1.0    eaa7e3f3985a   2 hours
> > ago
> > >         953MB
> > > kolla/keystone-fernet                 15.1.0    8a4fa24853a8   2 hours
> > ago
> > >         951MB
> > > kolla/keystone-base                   15.1.0    b6f9562364a9   2 hours
> > ago
> > >         945MB
> > > kolla/barbican-base                   15.1.0    b2fdef1afb44   2 hours
> > ago
> > >         915MB
> > > kolla/barbican-keystone-listener      15.1.0    58bd59de2c63   2 hours
> > ago
> > >         915MB
> > > kolla/openstack-base                  15.1.0    c805b4b3b1c1   2 hours
> > ago
> > >         893MB
> > > kolla/base                            15.1.0    f68e9ef3dd30   2 hours
> > ago
> > >         248MB
> > > registry                              2         8db46f9d7550   19 hours
> > ago
> > >        24.2MB
> > > ubuntu                                22.04     08d22c0ceb15   3 weeks
> > ago
> > >         77.8MB
> > 
> > 




More information about the openstack-discuss mailing list