perryao / mikeperry.io-comments

Comments mikeperry.io
0 stars 0 forks source link

posts/copy-helm-images/ #2

Open utterances-bot opened 5 years ago

utterances-bot commented 5 years ago

Copy Helm Chart Images to a Corporate Registry | Mike Perry

https://mikeperry.io/posts/copy-helm-images/

swhite24 commented 5 years ago

I love it!

kmluoh commented 5 years ago

Any reason not using ‘sort -u’?

perryao commented 5 years ago

Hi @kmluoh. I actually wasn't aware that sort had a -u flag to provide unique results. Works great. I'll update this post to simplify to that. Thanks!

kmluoh commented 5 years ago

You are welcome. Good to know it helps.

jk2K commented 3 years ago

I got error "docker tag" requires exactly 2 arguments,

maybe miss &&

before fix

xargs -I % -n 1 -P 4 bash -c "docker pull % && docker tag % my.registry.com/% docker push my.registry.com/%"

after fix

xargs -I % -n 1 -P 4 bash -c "docker pull % && docker tag % my.registry.com/% && docker push my.registry.com/%"
jk2K commented 3 years ago

some image cannot push,got error invalid reference format, I didn't find the reason.

I split the script into 3 parts and it was executed successfully.

# docker pull image
helm template sentry-8.1.0.tgz | yq '..|.image? | select(.)' \
| sort \
| uniq \
| xargs -I % -n 1 -P 4 bash -c "docker pull %"

# retag
helm template sentry-8.1.0.tgz | yq '..|.image? | select(.)' \
| sort \
| uniq \
| xargs -I % -n 1 -P 4 bash -c "docker tag % my.registry.com/%"

# docker push image
helm template sentry-8.1.0.tgz | yq '..|.image? | select(.)' \
| sort \
| uniq \
| xargs -I % -n 1 -P 4 bash -c "docker push my.registry.com/%"

my image list

$ helm template sentry-8.1.0.tgz | yq '..|.image? | select(.)' \
| sort \
| uniq \
| xargs -I % -n 1 -P 4 bash -c "echo %"
busybox:1.30.1
busybox:1.31.0
docker.io/bitnami/kafka:2.6.0-debian-10-r78
docker.io/bitnami/minideb:stretch
docker.io/bitnami/nginx:1.19.1-debian-10-r23
docker.io/bitnami/postgresql:11.6.0-debian-10-r5
docker.io/bitnami/redis:5.0.5-debian-9-r141
docker.io/bitnami/zookeeper:3.6.2-debian-10-r58
getsentry/relay:20.12.1
getsentry/sentry:20.12.1
getsentry/snuba:20.12.1
rabbitmq:3.8.0-alpine
spoonest/clickhouse-tabix-web-client:stable
yandex/clickhouse-server:20.8.9.6
cruzanstx commented 2 years ago

Thanks for the write up. I had to make the following change to the yq command on centos8 adding an e before the yq arguments and ending it with a -. It looks like its trying to parse that last argument as a file on centos.

helm template . |  yq e '..|.image? | select(.)' -