refactor:Save multi image into one tar file.

This commit is contained in:
fumingwei
2024-11-06 20:44:46 +08:00
parent db1eff5d0e
commit 3537c65b15
6 changed files with 90 additions and 101 deletions

View File

@@ -9,6 +9,7 @@ variables:
CLIENT_IMAGE_TAG: registry.gdnt-cloud.website/tsg/diagnose/client:latest CLIENT_IMAGE_TAG: registry.gdnt-cloud.website/tsg/diagnose/client:latest
SERVER_WEB_IMAGE_TAG: registry.gdnt-cloud.website/tsg/diagnose/server-web:latest SERVER_WEB_IMAGE_TAG: registry.gdnt-cloud.website/tsg/diagnose/server-web:latest
SERVER_DNS_IMAGE_TAG: registry.gdnt-cloud.website/tsg/diagnose/server-dns:latest SERVER_DNS_IMAGE_TAG: registry.gdnt-cloud.website/tsg/diagnose/server-dns:latest
IMAGES_TAG: tsg-diagnose-images.tar
before_script: before_script:
- mkdir -p images;rm -rf images/* - mkdir -p images;rm -rf images/*
- mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/ - mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
@@ -23,11 +24,9 @@ variables:
- buildah login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - buildah login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script: script:
- buildah build -t $CLIENT_IMAGE_TAG -f ./images_build/client/Dockerfile ./images_build/client/ - buildah build -t $CLIENT_IMAGE_TAG -f ./images_build/client/Dockerfile ./images_build/client/
- podman save -o images/tsg_diagnose_client.tar -m $CLIENT_IMAGE_TAG
- buildah build -t $SERVER_WEB_IMAGE_TAG -f ./images_build/server_web/Dockerfile ./images_build/server_web/ - buildah build -t $SERVER_WEB_IMAGE_TAG -f ./images_build/server_web/Dockerfile ./images_build/server_web/
- podman save -o images/tsg_diagnose_server_web.tar -m $SERVER_WEB_IMAGE_TAG
- buildah build -t $SERVER_DNS_IMAGE_TAG -f ./images_build/server_dns/Dockerfile ./images_build/server_dns/ - buildah build -t $SERVER_DNS_IMAGE_TAG -f ./images_build/server_dns/Dockerfile ./images_build/server_dns/
- podman save -o images/tsg_diagnose_server_dns.tar -m $SERVER_DNS_IMAGE_TAG - podman save -o images/$IMAGES_TAG -m $CLIENT_IMAGE_TAG $SERVER_WEB_IMAGE_TAG $SERVER_DNS_IMAGE_TAG
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH - cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
- ./ci/travis.sh - ./ci/travis.sh

View File

@@ -12,19 +12,14 @@ dnf install tsg-diagnose
### Docker ### Docker
If you have installed TSG Diagnose with Docker support, you can use the following command to build the TSG Diagnose runtime environment. If you have installed TSG Diagnose with Docker support, you can use the following command to build the TSG Diagnose runtime environment.
```bash ```bash
docker load < /opt/tsg/tsg-diagnose/images/tsg_diagnose_server_web.tar docker load < /opt/tsg/tsg-diagnose/images/tsg-diagnose-images.tar
docker load < /opt/tsg/tsg-diagnose/images/tsg_diagnose_server_dns.tar
docker load < /opt/tsg/tsg-diagnose/images/tsg_diagnose_client.tar
docker-compose down --remove-orphans; docker-compose up -d --remove-orphans docker-compose down --remove-orphans; docker-compose up -d --remove-orphans
``` ```
### k3s ### k3s
If you have installed TSG Diagnose with k3s support, you can use the following command to build the TSG Diagnose runtime environment. If you have installed TSG Diagnose with k3s support, you can use the following command to build the TSG Diagnose runtime environment.
```bash ```bash
k3s ctr image import /opt/tsg/tsg-diagnose/images/tsg_diagnose_server_web.tar k3s ctr image import /opt/tsg/tsg-diagnose/images/tsg-diagnose-images.tar
k3s ctr image import /opt/tsg/tsg-diagnose/images/tsg_diagnose_server_dns.tar kubectl apply -f /opt/tsg/tsg-diagnose/k8s-resource/tsg-diagnose.yaml
k3s ctr image import /opt/tsg/tsg-diagnose/images/tsg_diagnose_client.tar
kubectl apply -f /opt/tsg/tsg-diagnose/k8s-resource/tsg-diagnose-client.yaml
kubectl apply -f /opt/tsg/tsg-diagnose/k8s-resource/tsg-diagnose-server.yaml
``` ```
## Usage ## Usage
There are two commands available to run TSG Diagnose: There are two commands available to run TSG Diagnose:

View File

@@ -20,8 +20,7 @@ set(CPACK_RPM_DEBUGINFO_PACKAGE on)
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in) set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in)
install(FILES compose/docker-compose.yml DESTINATION ./compose) install(FILES compose/docker-compose.yml DESTINATION ./compose)
install(FILES k8s-resource/tsg-diagnose-client.yaml DESTINATION ./k8s-resource) install(DIRECTORY k8s-resource/ DESTINATION ./k8s-resource)
install(FILES k8s-resource/tsg-diagnose-server.yaml DESTINATION ./k8s-resource)
install(FILES compose/docker-compose.yml DESTINATION ./compose) install(FILES compose/docker-compose.yml DESTINATION ./compose)
install(FILES images_build/client/dign_client/etc/client.conf DESTINATION ./etc) install(FILES images_build/client/dign_client/etc/client.conf DESTINATION ./etc)
install(FILES service/tsg-diagnose.service DESTINATION /usr/lib/systemd/system) install(FILES service/tsg-diagnose.service DESTINATION /usr/lib/systemd/system)

View File

@@ -1,84 +0,0 @@
---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
namespace: tsg-os-system
name: br-dign-client
spec:
config: '{
"cniVersion": "0.3.0",
"type": "bridge",
"bridge": "br_dign_c",
"ipam": {
"type": "host-local",
"ranges": [
[ {
"subnet": "192.0.2.0/24",
"rangeStart": "192.0.2.211",
"rangeEnd": "192.0.2.220",
"gateway": "192.0.2.1"
} ]
]
}
}'
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: tsg-os-system
name: dign-client
labels:
app: dign-client
spec:
selector:
matchLabels:
app: dign-client
template:
metadata:
labels:
app: dign-client
annotations:
k8s.v1.cni.cncf.io/networks: br-dign-client
spec:
containers:
- name: dign-client
image: "registry.gdnt-cloud.website/tsg/diagnose/client:latest"
imagePullPolicy: Never
workingDir: /opt/dign_client
command: ["/bin/sh", "-c", "update-ca-certificates; tail -f /dev/null"]
securityContext:
privileged: true
volumeMounts:
- name: localtime-node
mountPath: /etc/localtime
readOnly: true
- name: ca-cert-file
mountPath: /usr/local/share/ca-certificates
- name: log-path
mountPath: /opt/dign_client/log
- name: config-path
mountPath: /opt/dign_client/etc/client.conf
subPath: "client.conf"
- name: share-path
mountPath: /opt/dign_client/share
volumes:
- name: localtime-node
hostPath:
path: /etc/localtime
- name: ca-cert-file
hostPath:
path: /opt/tsg/tsg-diagnose/etc/.certs_import/certs/sets/current/gen/crt
- name: log-path
hostPath:
path: /opt/tsg/tsg-diagnose/log
- name: config-path
hostPath:
path: /opt/tsg/tsg-diagnose/etc
- name: share-path
hostPath:
path: /opt/tsg/clixon/share
---

View File

@@ -1,6 +1,88 @@
--- ---
apiVersion: "k8s.cni.cncf.io/v1" apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition kind: NetworkAttachmentDefinition
metadata:
namespace: tsg-os-system
name: br-dign-client
spec:
config: '{
"cniVersion": "0.3.0",
"type": "bridge",
"bridge": "br_dign_c",
"ipam": {
"type": "host-local",
"ranges": [
[ {
"subnet": "192.0.2.0/24",
"rangeStart": "192.0.2.211",
"rangeEnd": "192.0.2.220",
"gateway": "192.0.2.1"
} ]
]
}
}'
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: tsg-os-system
name: dign-client
labels:
app: dign-client
spec:
selector:
matchLabels:
app: dign-client
template:
metadata:
labels:
app: dign-client
annotations:
k8s.v1.cni.cncf.io/networks: br-dign-client
spec:
containers:
- name: dign-client
image: "registry.gdnt-cloud.website/tsg/diagnose/client:latest"
imagePullPolicy: Never
workingDir: /opt/dign_client
command: ["/bin/sh", "-c", "update-ca-certificates; tail -f /dev/null"]
securityContext:
privileged: true
volumeMounts:
- name: localtime-node
mountPath: /etc/localtime
readOnly: true
- name: ca-cert-file
mountPath: /usr/local/share/ca-certificates
- name: log-path
mountPath: /opt/dign_client/log
- name: config-path
mountPath: /opt/dign_client/etc/client.conf
subPath: "client.conf"
- name: share-path
mountPath: /opt/dign_client/share
volumes:
- name: localtime-node
hostPath:
path: /etc/localtime
- name: ca-cert-file
hostPath:
path: /opt/tsg/tsg-diagnose/etc/.certs_import/certs/sets/current/gen/crt
- name: log-path
hostPath:
path: /opt/tsg/tsg-diagnose/log
- name: config-path
hostPath:
path: /opt/tsg/tsg-diagnose/etc
- name: share-path
hostPath:
path: /opt/tsg/clixon/share
---
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata: metadata:
namespace: tsg-os-system namespace: tsg-os-system
name: br-dign-server name: br-dign-server

View File

@@ -7,9 +7,7 @@ After=docker.service
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
WorkingDirectory=/opt/tsg/tsg-diagnose/compose/%i WorkingDirectory=/opt/tsg/tsg-diagnose/compose/%i
ExecStartPre=/bin/sh -c "docker load < /opt/tsg/tsg-diagnose/images/tsg_diagnose_server_web.tar" ExecStartPre=/bin/sh -c "docker load < /opt/tsg/tsg-diagnose/images/tsg-diagnose-images.tar"
ExecStartPre=/bin/sh -c "docker load < /opt/tsg/tsg-diagnose/images/tsg_diagnose_server_dns.tar"
ExecStartPre=/bin/sh -c "docker load < /opt/tsg/tsg-diagnose/images/tsg_diagnose_client.tar"
ExecStart=/bin/sh -c "docker-compose down --remove-orphans; docker-compose up -d --remove-orphans" ExecStart=/bin/sh -c "docker-compose down --remove-orphans; docker-compose up -d --remove-orphans"
ExecStop=/bin/sh -c "docker-compose down --remove-orphans" ExecStop=/bin/sh -c "docker-compose down --remove-orphans"