github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/docs/design-docs/04-arm-build.md (about)

     1  # Title
     2  
     3  * Author(s): Mike Borozdin, @mikebz
     4  * Approver: Mengqi, Sunil
     5  
     6  ## Why
     7  
     8  More people are getting Apple M1 machines.  The current docker images for
     9  functions do not work.  Here is an example:
    10  https://github.com/GoogleContainerTools/kpt/issues/2874
    11  While it's not a problem for CI/CD pipelines where architecture is mostly amd64
    12  for client development purposes the users are stuck.
    13  
    14  ## Design
    15  
    16  Building arm64 and amd64 multi platform images is possible:
    17  https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
    18  but it has it's caveats.  The build is done in a builder which needs to be 
    19  created:
    20  https://docs.docker.com/engine/reference/commandline/buildx_create/
    21  The caveat is that the multi platform images do not load into docker images:
    22  https://github.com/docker/buildx/blob/master/docs/reference/buildx_build.md#-load-the-single-platform-build-result-to-docker-images---load
    23  
    24  Right now the build pipeline has several steps:
    25  1) build
    26  2) tag
    27  3) push
    28  
    29  In different scenarios only the first two steps are executed.  If we switch to 
    30  `buildx` we will need to build/tag/push in one step.  Locally developers 
    31  might want to build and tag images locally.
    32  
    33  However if we make the changes needed to the shell scripts that produce the
    34  images all that the users of docker images will need to do is just update
    35  to the next version of the function image.  Docker promises to use the right 
    36  architecture automatically.
    37  
    38  ## User Guide
    39  
    40  The user guide for using the new images should not change.  People using
    41  amd64 systems (Linux or Mac) can continue using the same systems.  People using
    42  arm64 systems can already get the arm64 kpt binary and will update their
    43  pipelines to the next version of functions.  The functions should select the 
    44  right architecture to run.
    45  
    46  ## Open Issues/Questions
    47  
    48  Please list any open questions here in the following format:
    49  
    50  ## Alternatives Considered
    51  
    52  An alternative to using a multi architecture images is to build a special image
    53  for each platform and then tag them differently.  The benefits of this are:
    54  - users can select the right architecture in their Kptfile or imperability 
    55  invoking the right function image.
    56  
    57  The problem is that most of the time CI/CD systems are amd64 linux and the arm64
    58  is primarily for the convenience of client systems.  The users most likely
    59  do not want to change their hydration pipeline definition from client to CI/CD
    60  systems.
    61  
    62  NOTE: we have done a test on how the images look in the container registry.
    63  buildx builds two images and the individual images are not any bigger.
    64  
    65  ### \<Approach\>
    66  
    67  Links and description of the approach, the pros and cons identified during the 
    68  design.