Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to inject mirror Tag into K8s Docker-Compose

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to inject mirror Tag into K8s Docker-Compose". In daily operation, I believe many people have doubts about how to inject mirror Tag into K8s Docker-Compose. The editor looked up all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how to inject mirror Tag into K8s Docker-Compose". Next, please follow the editor to study!

K8s

Students who are familiar with K8s know that K8s has a powerful native configuration management tool: Kustomize.

Kustomize simplifies the use of existing applications by customizing application configuration in a template-free way. Now kustomize has built in kubectl in the form of apply-k.

Here, use the edit command of Kustomize to modify the image Tag defined in Kustomization.yaml:

Here is a simple Kustomization.yaml file:

Kind: Kustomization

Namespace: wd

Resources:

-.. / base

Images:

-name: hub.docker.com/eap/website / / original image name

NewName: hub.docker.com/eap/website

NewTag: v1.0.7-hotfix5 / / Tag that has been continuously modified

When doing automatic deployment, CI usually imports this git tag (image Tag) to the deployment script.

#! / bin/sh

Cd / home/wd-deploy/localdeploy/wd/overlays/

Kustomize edit set image hub.docker.com/eap/website=hub.docker.com/eap/website:$ {TAG}

Kustomize build. | | kubectl apply-f-|

The above deployment script: go to the Kustomization.yaml directory, inject a new mirror Tag into the Kustomization.yaml file, and build and apply the new configuration.

Docker-compose

The Docker platform does not have such a good tool, which explicitly allows you to modify the image configuration.

We use the shell script curve to modify the mirror configuration:

Suppose you have a simple docker-compose.yml file:

Version:'3'

Services:

App:

Image: username/app:d7s8f12

Ports:

80:80

Modify the image Tag after the `app: `string through the shell script to achieve the purpose of injecting Tag.

Sed-E-iTunes'"s / (. * app:). * /\ 1$ COMMIT/" 'docker-compose.yml'

Similarly, this Git Tag (mirror Tag) is imported by CI to the deployment script during automatic deployment.

#! / bin/sh

Cd / home/wd-deploy/app/

Sed-E-iTunes'"s / (. * app:). * /\ 1$ COMMIT/" 'docker-compose.yml'

Docker-compose pull app & & docker-compose up-d at this point, the study on "how to inject mirror Tag into K8s Docker-Compose" is over. I hope I can solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report