Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kubespray
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirror
Kubespray
Commits
ee2dd4fd
Unverified
Commit
ee2dd4fd
authored
1 year ago
by
my-git9
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
support other other runtime tool for manage-offline-container-images (#10740)
Signed-off-by:
xin.li
<
xin.li@daocloud.io
>
parent
c3b67452
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
contrib/offline/manage-offline-container-images.sh
+25
-13
25 additions, 13 deletions
contrib/offline/manage-offline-container-images.sh
with
25 additions
and
13 deletions
contrib/offline/manage-offline-container-images.sh
+
25
−
13
View file @
ee2dd4fd
...
@@ -23,8 +23,8 @@ function create_container_image_tar() {
...
@@ -23,8 +23,8 @@ function create_container_image_tar() {
mkdir
${
IMAGE_DIR
}
mkdir
${
IMAGE_DIR
}
cd
${
IMAGE_DIR
}
cd
${
IMAGE_DIR
}
sudo
docker
pull registry:latest
sudo
${
runtime
}
pull registry:latest
sudo
docker
save
-o
registry-latest.tar registry:latest
sudo
${
runtime
}
save
-o
registry-latest.tar registry:latest
for
image
in
${
IMAGES
}
for
image
in
${
IMAGES
}
do
do
...
@@ -32,7 +32,7 @@ function create_container_image_tar() {
...
@@ -32,7 +32,7 @@ function create_container_image_tar() {
set
+e
set
+e
for
step
in
$(
seq
1
${
RETRY_COUNT
}
)
for
step
in
$(
seq
1
${
RETRY_COUNT
}
)
do
do
sudo
docker
pull
${
image
}
sudo
${
runtime
}
pull
${
image
}
if
[
$?
-eq
0
]
;
then
if
[
$?
-eq
0
]
;
then
break
break
fi
fi
...
@@ -42,7 +42,7 @@ function create_container_image_tar() {
...
@@ -42,7 +42,7 @@ function create_container_image_tar() {
fi
fi
done
done
set
-e
set
-e
sudo
docker
save
-o
${
FILE_NAME
}
${
image
}
sudo
${
runtime
}
save
-o
${
FILE_NAME
}
${
image
}
# NOTE: Here removes the following repo parts from each image
# NOTE: Here removes the following repo parts from each image
# so that these parts will be replaced with Kubespray.
# so that these parts will be replaced with Kubespray.
...
@@ -95,16 +95,16 @@ function register_container_images() {
...
@@ -95,16 +95,16 @@ function register_container_images() {
sed
-i
s@
"HOSTNAME"
@
"
${
LOCALHOST_NAME
}
"
@
${
TEMP_DIR
}
/registries.conf
sed
-i
s@
"HOSTNAME"
@
"
${
LOCALHOST_NAME
}
"
@
${
TEMP_DIR
}
/registries.conf
sudo cp
${
TEMP_DIR
}
/registries.conf /etc/containers/registries.conf
sudo cp
${
TEMP_DIR
}
/registries.conf /etc/containers/registries.conf
else
else
echo
"
docker
package(docker-ce, etc.) should be installed"
echo
"
runtime
package(docker-ce,
podman, nerctl,
etc.) should be installed"
exit
1
exit
1
fi
fi
tar
-zxvf
${
IMAGE_TAR_FILE
}
tar
-zxvf
${
IMAGE_TAR_FILE
}
sudo
docker
load
-i
${
IMAGE_DIR
}
/registry-latest.tar
sudo
${
runtime
}
load
-i
${
IMAGE_DIR
}
/registry-latest.tar
set
+e
set
+e
sudo
docker
container inspect registry
>
/dev/null 2>&1
sudo
${
runtime
}
container inspect registry
>
/dev/null 2>&1
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
sudo
docker
run
--restart
=
always
-d
-p
5000:5000
--name
registry registry:latest
sudo
${
runtime
}
run
--restart
=
always
-d
-p
5000:5000
--name
registry registry:latest
fi
fi
set
-e
set
-e
...
@@ -112,8 +112,8 @@ function register_container_images() {
...
@@ -112,8 +112,8 @@ function register_container_images() {
file_name
=
$(
echo
${
line
}
|
awk
'{print $1}'
)
file_name
=
$(
echo
${
line
}
|
awk
'{print $1}'
)
raw_image
=
$(
echo
${
line
}
|
awk
'{print $2}'
)
raw_image
=
$(
echo
${
line
}
|
awk
'{print $2}'
)
new_image
=
"
${
LOCALHOST_NAME
}
:5000/
${
raw_image
}
"
new_image
=
"
${
LOCALHOST_NAME
}
:5000/
${
raw_image
}
"
org_image
=
$(
sudo
docker
load
-i
${
IMAGE_DIR
}
/
${
file_name
}
|
head
-n1
|
awk
'{print $3}'
)
org_image
=
$(
sudo
${
runtime
}
load
-i
${
IMAGE_DIR
}
/
${
file_name
}
|
head
-n1
|
awk
'{print $3}'
)
image_id
=
$(
sudo
docker
image inspect
${
org_image
}
|
grep
"
\"
Id
\"
:"
|
awk
-F
:
'{print $3}'
|
sed
s/
'\",'
//
)
image_id
=
$(
sudo
${
runtime
}
image inspect
${
org_image
}
|
grep
"
\"
Id
\"
:"
|
awk
-F
:
'{print $3}'
|
sed
s/
'\",'
//
)
if
[
-z
"
${
file_name
}
"
]
;
then
if
[
-z
"
${
file_name
}
"
]
;
then
echo
"Failed to get file_name for line
${
line
}
"
echo
"Failed to get file_name for line
${
line
}
"
exit
1
exit
1
...
@@ -130,9 +130,9 @@ function register_container_images() {
...
@@ -130,9 +130,9 @@ function register_container_images() {
echo
"Failed to get image_id for file
${
file_name
}
"
echo
"Failed to get image_id for file
${
file_name
}
"
exit
1
exit
1
fi
fi
sudo
docker
load
-i
${
IMAGE_DIR
}
/
${
file_name
}
sudo
${
runtime
}
load
-i
${
IMAGE_DIR
}
/
${
file_name
}
sudo
docker
tag
${
image_id
}
${
new_image
}
sudo
${
runtime
}
tag
${
image_id
}
${
new_image
}
sudo
docker
push
${
new_image
}
sudo
${
runtime
}
push
${
new_image
}
done
<<<
"
$(
cat
${
IMAGE_LIST
}
)
"
done
<<<
"
$(
cat
${
IMAGE_LIST
}
)
"
echo
"Succeeded to register container images to local registry."
echo
"Succeeded to register container images to local registry."
...
@@ -143,6 +143,18 @@ function register_container_images() {
...
@@ -143,6 +143,18 @@ function register_container_images() {
echo
"- quay_image_repo"
echo
"- quay_image_repo"
}
}
# get runtime command
if
command
-v
nerdctl 1>/dev/null 2>&1
;
then
runtime
=
"nerdctl"
elif
command
-v
podman 1>/dev/null 2>&1
;
then
runtime
=
"podman"
elif
command
-v
docker 1>/dev/null 2>&1
;
then
runtime
=
"docker"
else
echo
"No supported container runtime found"
exit
1
fi
if
[
"
${
OPTION
}
"
==
"create"
]
;
then
if
[
"
${
OPTION
}
"
==
"create"
]
;
then
create_container_image_tar
create_container_image_tar
elif
[
"
${
OPTION
}
"
==
"register"
]
;
then
elif
[
"
${
OPTION
}
"
==
"register"
]
;
then
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment