目录

arm平台镜像适配操作

项目笔记:记录如何更新自定义镜像arm版本的操作步骤:

环境

harbor已配置支持多芯片平台半版本,可以按amd和arm来区分不同平台的镜像。

initcontainer

1
2
# 导入镜像
docker load -i initstorcontainer_arm64.img.tar
1
2
3
# initstorcontainer:arm64

# 168.170.141.42为 harbor ip

将环境中的多平台版本镜像信息写到manifest

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
HARBOR_SVC=168.170.141.42:5000

# tag and push arm64, amd64 images

docker tag initstorcontainer:arm64 ${HARBOR_SVC}/example/initstorcontainer:arm64
docker push ${HARBOR_SVC}/example/initstorcontainer:arm64

docker tag ${HARBOR_SVC}/example/initstorcontainer:v1 ${HARBOR_SVC}/example/initstorcontainer:amd64
docker push ${HARBOR_SVC}/example/initstorcontainer:amd64

# manifest images: arm64;amd64

docker manifest create ${HARBOR_SVC}/example/initstorcontainer:v1 ${HARBOR_SVC}/example/initstorcontainer:amd64 ${HARBOR_SVC}/example/initstorcontainer:arm64 --insecure




docker manifest annotate ${HARBOR_SVC}/example/initstorcontainer:v1 ${HARBOR_SVC}/example/initstorcontainer:arm64 --os linux --arch arm64

docker manifest annotate ${HARBOR_SVC}/example/initstorcontainer:v1 ${HARBOR_SVC}/example/initstorcontainer:amd64 --os linux --arch amd64



docker manifest push ${HARBOR_SVC}/example/initstorcontainer:v1 --insecure


# check mainifest info
docker manifest inspect ${HARBOR_SVC}/example/initstorcontainer:v1
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@node1 initstorcontainer]# docker manifest inspect ${HARBOR_SVC}/example/initstorcontainer:v1
{
   "schemaVersion": 2,
   "mediaType": "application/vnd.docker.distribution.manifest.list.v2+json",
   "manifests": [
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 3044,
         "digest": "sha256:ef012768aa11318ca71a07c57a1b289b0a07221dbf662a2eb02edb79a7f44a93",
         "platform": {
            "architecture": "amd64",
            "os": "linux"
         }
      },
      {
         "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
         "size": 2202,
         "digest": "sha256:591cef09d5c11e6ab6bc63398b592420805d4fcb0f5eef2060b2b86c14cfe1be",
         "platform": {
            "architecture": "arm64",
            "os": "linux",
            "variant": "v8"
         }
      }
   ]
}

dataset-agent

因为版本更新,所以替换dataset-agent分3部分完成

  1. 先构建dataset-agent的arm版本镜像,该镜像版本可能不是安装匹配版本

  2. 在arm节点上,更新arm版本镜像中的dataset-agent组件

  3. 保存最新的dataset-agent镜像,并推送到harbor仓库中

1
2
# 导入镜像
docker load -i dataset-agent_arm64.img.tar
1
2
3
# example/dataset-agent-arm64:v1

# 168.170.141.42为 harbor ip

导入多版本基础镜像

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
HARBOR_SVC=168.170.141.42:5000

docker tag example/dataset-agent-arm64:v1 ${HARBOR_SVC}/example/dataset-agent:arm64
docker push ${HARBOR_SVC}/example/dataset-agent:arm64

docker tag ${HARBOR_SVC}/example/dataset-agent:latest  ${HARBOR_SVC}/example/dataset-agent:amd64
docker push ${HARBOR_SVC}/example/dataset-agent:amd64




docker manifest create ${HARBOR_SVC}/example/dataset-agent ${HARBOR_SVC}/example/dataset-agent:amd64 ${HARBOR_SVC}/example/dataset-agent:arm64 --insecure


docker manifest annotate ${HARBOR_SVC}/example/dataset-agent ${HARBOR_SVC}/example/dataset-agent:arm64 --os linux --arch arm64

docker manifest annotate ${HARBOR_SVC}/example/dataset-agent ${HARBOR_SVC}/example/dataset-agent:amd64 --os linux --arch amd64

docker manifest push ${HARBOR_SVC}/example/dataset-agent --insecure


docker manifest inspect ${HARBOR_SVC}/example/dataset-agent --insecure
1
2
3
# 在k8s master节点上,执行命令,重启准备操作arm节点上的dataset-agent的pod

### example        dataset-4rzhl 为 arm节点上的dataset-agent的pod
1
kubectl delete pod -n example        dataset-4rzhl
1
# 将 dataset-agent-3.4.0-SNAPSHOT.jar 拷贝到arm节点上

node-22-arm是arm节点的hostname

1
scp -r dataset-agent-3.4.0-SNAPSHOT.jar node-22-arm:/tmp/
1
# 在要操作的arm节点上,找到要更新的dataset-agent容器的容器id
1
docker ps -a |grep dataset-agent

示例,dataset-agent的容器id是49fa7e36c208:

1
2
docker ps -a |grep dataset-agent
49fa7e36c208   168.170.141.42:5000/example/dataset-agent        "/deployments/run-ja…"  
1
2
 # 对dataset-agent容器进行最新版本更新

1
2
3
4
5
6
cidname=49fa7e36c208

docker cp /tmp/dataset-agent-3.4.0-SNAPSHOT.jar ${cidname}:/deployments/example/


docker commit -m 'make image' ${cidname} ${HARBOR_SVC}/example/dataset-agent:arm64

说明: 如果该命令执行失败:docker push ${HARBOR_SVC}/example/dataset-agent:arm64 –insecure,则需login docker,或者在harbor节点上 推送该镜像

失败时,则需继续下面步骤操作

1
# 把dataset镜像打包拷贝到master节点 即harbor所在节点
1
docker save ${HARBOR_SVC}/example/dataset-agent:arm64 -o /tmp/dataset-agent-arm64.img.tar
1
# 在master节点 即harbor所在节点
1
2
3
4
scp -r node-22-arm:/tmp/dataset-agent-arm64.img.tar /tmp/

docker load -i /tmp/dataset-agent-arm64.img.tar
docker push ${HARBOR_SVC}/example/dataset-agent:arm64
1
# 再次重启所有节点的dataset-agent