github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/docs/design/mutil_arch_build.md (about)

     1  # Multi-arch build
     2  
     3  ## Build cloud image
     4  
     5  Kubefile:
     6  
     7  ```shell
     8  FROM kubernetes:v1.19.8
     9  COPY dashborad.yaml manifests
    10  COPY ${ARCH}/helm bin # copy binary file,make sure the build context have the same number platform binary files.
    11  COPY my-mysql charts
    12  CMD helm install my-mysql bitnami/mysql --version 8.8.26
    13  CMD kubectl apply -f manifests/dashborad.yaml
    14  ```
    15  
    16  build context tree:
    17  
    18  ```yaml
    19  ├── amd64
    20  │   └── helm
    21  ├── arm64
    22  │   └── helm
    23  ├── dashboard.yaml
    24  ├── Kubefile
    25  └── my-mysql
    26  ```
    27  
    28  sealer build cmd line:
    29  
    30  ```shell
    31  sealer build --platform linux/arm64,linux/amd64 -t kubernetes-multi-arch:v1.19.8
    32  ```
    33  
    34  ### Cloud image manifests list
    35  
    36  ```json
    37  {
    38    "kubernetes-multi-arch:v1.19.8": {
    39      "manifests": [
    40        {
    41          "id": "52c3b10849c852649e66c2f7ed531f05bd97586ab61fa2cc82b4e79d80484b82",
    42          "created": "2022-03-08T14:23:18.571666683+08:00",
    43          "size": 826082517,
    44          "platform": {
    45            "architecture": "amd64",
    46            "os": "linux"
    47          }
    48        },
    49        {
    50          "id": "9e596d0a54177f29093236f65a9c6098590c67ea8b0dde4e09a5a49124cec7d0",
    51          "created": "2022-03-08T14:23:18.571666683+08:00",
    52          "size": 826082517,
    53          "platform": {
    54            "architecture": "arm64",
    55            "os": "linux",
    56            "variant": "v8"
    57          }
    58        }
    59      ]
    60    }
    61  }
    62  ```
    63  
    64  ### Cloud image manifests
    65  
    66  #### amd64 cloud image
    67  
    68  `cat 52c3b10849c852649e66c2f7ed531f05bd97586ab61fa2cc82b4e79d80484b82.yaml`
    69  
    70  ```yaml
    71  kind: Image
    72  metadata:
    73    annotations:
    74      sea.aliyun.com/ClusterFile: |
    75        apiVersion: sealer.cloud/v2
    76        kind: Cluster
    77        metadata:
    78          creationTimestamp: null
    79          name: my-cluster
    80        spec:
    81          image: kubernetes-multi-arch:v1.19.8
    82          ssh:
    83            port: "22"
    84            user: root
    85        status: {}
    86    creationTimestamp: null
    87    name: kubernetes-multi-arch:v1.19.8
    88  spec:
    89    id: 52c3b10849c852649e66c2f7ed531f05bd97586ab61fa2cc82b4e79d80484b82
    90    image_config:
    91      cmd:
    92        current:
    93          - helm install my-mysql bitnami/mysql --version 8.8.26
    94          - kubectl apply -f manifests/dashborad.yaml
    95    layers:
    96      - id: sha256:ba2221cfa297f483e195fd61b30651f2426303965f8f1dc69cf5d4eff635af9a
    97        type: COPY
    98        value: . .
    99      - id: sha256:e00f3ade42dc8cebffa2314b8bee4ee5472c5a915c2ba3687a588d47657b3d6a
   100        type: COPY
   101        value: dashborad.yaml manifests
   102      - id: sha256:5cd1d3347ba4d9a0edea555da8489633f73a42266e33cc8c55245b8791c6ff72
   103        type: COPY
   104        value: my-mysql charts
   105      - id: sha256:4f782a7c667b104f59140aa7836af9138836eef971764a426c309df4f9334ac6
   106        type: BASE ## only amd64 docker images
   107        value: rootfs cache
   108    platform:
   109      architecture: amd64
   110      os: linux
   111    sealer_version: latest
   112  status: { }
   113  ```
   114  
   115  #### arm64 v8 cloud image
   116  
   117  `cat 9e596d0a54177f29093236f65a9c6098590c67ea8b0dde4e09a5a49124cec7d0.yaml`
   118  
   119  ```yaml
   120  kind: Image
   121  metadata:
   122    annotations:
   123      sea.aliyun.com/ClusterFile: |
   124        apiVersion: sealer.cloud/v2
   125        kind: Cluster
   126        metadata:
   127          creationTimestamp: null
   128          name: my-cluster
   129        spec:
   130          image: kubernetes-multi-arch:v1.19.8
   131          ssh:
   132            port: "22"
   133            user: root
   134        status: {}
   135    creationTimestamp: null
   136    name: kubernetes-multi-arch:v1.19.8
   137  spec:
   138    id: 9e596d0a54177f29093236f65a9c6098590c67ea8b0dde4e09a5a49124cec7d0
   139    image_config:
   140      cmd:
   141        current:
   142          - helm install my-mysql bitnami/mysql --version 8.8.26
   143          - kubectl apply -f manifests/dashborad.yaml
   144    layers:
   145      - id: sha256:ba2221cfa297f483e195fd61b30651f2426303965f8f1dc69cf5d4eff635af9a
   146        type: COPY
   147        value: . .
   148      - id: sha256:e00f3ade42dc8cebffa2314b8bee4ee5472c5a915c2ba3687a588d47657b3d6a
   149        type: COPY
   150        value: dashborad.yaml manifests
   151      - id: sha256:5cd1d3347ba4d9a0edea555da8489633f73a42266e33cc8c55245b8791c6ff72
   152        type: COPY
   153        value: my-mysql charts
   154      - id: sha256:11c980114032d5f583c3861f1077bcc2f6d4e0e38b15219205fe22de044fd3a5
   155        type: BASE ## only save arm64 v8 docker images
   156        value: rootfs cache
   157    platform:
   158      architecture: arm64
   159      os: linux
   160      variant: v8
   161    sealer_version: latest
   162  status: { }
   163  ```
   164  
   165  ## Run cloud image
   166  
   167  | IP      | Platform | OS    |
   168  | :---        |    :----:   |          ---: |
   169  | 192.168.1.1      | amd64       | linux  |
   170  | 192.168.1.2   | arm64        | linux      |
   171  
   172  sealer run cmd line:
   173  
   174  ```shell
   175  sealer run -m 192.168.1.1 -n 192.168.1.2 kubernetes-multi-arch:v1.19.8
   176  ```
   177  
   178  ### Mount image
   179  
   180  we have three mounter point:
   181  
   182  1. amdMounter : lower layers include base amd rootfs and all image data.
   183  2. armMounter : lower layers include base arm rootfs and all image data.
   184  3. registryMounter : ${amdMounter}/registry + ${armMounter}/registry.
   185  
   186  ### Mount rootfs
   187  
   188  1. For master:only have amdMounter data
   189  2. For node :only have armMounter data
   190  
   191  ## Save cloud image
   192  
   193  if not specify the platform will save them all. save two image_metadata.yaml and all manifests file.
   194  
   195  If you want save amd64 images of kubernetes-multi-arch:v1.19.8 using platform arg
   196  
   197  `sealer save -o kubernetes.tar kubernetes-multi-arch:v1.19.8 --platform linux/amd64`
   198  
   199  manifests file and one image_metadata.yaml :
   200  
   201  ```json
   202  {
   203    "kubernetes-multi-arch:v1.19.8": {
   204      "manifests": [
   205        {
   206          "id": "52c3b10849c852649e66c2f7ed531f05bd97586ab61fa2cc82b4e79d80484b82",
   207          "created": "2022-03-08T14:23:18.571666683+08:00",
   208          "size": 826082517,
   209          "platform": {
   210            "architecture": "amd64",
   211            "os": "linux"
   212          }
   213        }
   214      ]
   215    }
   216  }
   217  ```
   218  
   219  ## Load cloud image
   220  
   221  `sealer load -i kubernetes.tar`
   222  
   223  ## Inspect cloud image
   224  
   225  `sealer inspect b934b329d0e6f7abc4c37425a99a4683852e1308225ada4c1941f5df0d9a19f0`
   226  
   227  ## Delete cloud image
   228  
   229  if not specify the platform will delete them all. If you only want to delete amd64 images of `kubernetes-multi-arch:
   230  v1.19.8`.
   231  
   232  `sealer rmi kubernetes-multi-arch:v1.19.8 --platform linux/amd64`
   233  
   234  ## Pull cloud image
   235  
   236  `sealer pull kubernetes-multi-arch:v1.19.8 --platform linux/amd64`
   237  
   238  ## Push cloud image
   239  
   240  `sealer push kubernetes-multi-arch:v1.19.8 --platform linux/amd64`
   241  
   242  ## Merge cloud image
   243  
   244  if not specify platform will use default arch with runtime. if specify platform, will merge them all.
   245  
   246  `sealer merge app1:v1 app2:v2 -t new:v1 --platform linux/amd64`