I've been doing container based CI/CD, A simple idea of automatic deployment is :

  • from Git Repo play git tag, As a mirror image Tag
  • ssh Log in remotely to the deployment machine
  • Inject images into the deployment environment Tag, Pull the mirror image , Redeployment

Let's share how I stay K8s、docker-compose Image injection in TAG( Continuous deployment )?

k8s

be familiar with k8s My classmates know , K8s There is a powerful native configuration management tool :Kustomize Tools .

Kustomize Customize application configuration in a template free way , This simplifies the use of existing applications . Now? kustomize Have already used apply -k It's built in a way that kubectl.

It can be used here Kustomize Of edit Command modification is defined in Kustomization.yaml In the mirror TAG:

Here's a simple one 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 // Continuously modified Tag

When doing auto deployment , Generally by CI Import this Git Tag, As a mirror image Tag.

#!/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 : Get into Kustomization.yaml Catalog , towards Kustomization.yaml File injection new image Tag, Build and apply new configurations .

docker-compose

Docker Platforms don't have such good tools , Plaintext allows you to modify the image configuration .

We can use shell Script To modify the mirror configuration :

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

version: '3'
services:
app:
image: username/app:d7s8f12
ports:
- 80:80

adopt shell The script modifies the string app: The back image Tag, Reach the goal of Tag Purpose

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

Again , When doing automatic deployment , from CI Import this Git Tag, As a mirror image Tag.

#!/bin/sh
cd /home/wd-deploy/app/
sed -E -i'' "s/(.*app:).*/\1$COMMIT/" 'docker-compose.yml'
docker-compose pull app && docker-compose up -d

The above deployment script : Get into docker-compose.yml Catalog , towards Compose File injection new image Tag, Pull the image and apply the new configuration .

Conclusion

In this paper, we record the direction of K8s, Docker-Compose Platform injection image Tag The way , Why should we focus on this ? Because of injection Tag It is a necessary process for automatic deployment .

This article is just a superficial 、 Simple injection of ideas (Devops Ecology has many components to do this ), Welcome to leave more messages , Take me on the road .

How to be in K8s,Docker-Compose Injection image Tag More articles about

  1. docker and docker compose Common operation command

    First of all, make a distinction docker There are several concepts in this paper Image: Mirror image , Equivalent to one root file system , It doesn't contain any dynamic data Container: Containers , Mirror runtime entities , The essence is the process , Container processes run in their own separate namespace d ...

  2. turn docker Create private warehouses and k8s Using private images in

    docker Private Warehouse Establishment The environment shows that we choose 192.168.5.2 Do private warehouse address yum install docker -y1. start-up docker Warehouse port service docker run -d -p 5000:5 ...

  3. docker Install the specified version TAG Mirror image

    stay docker Install the image in , The general process is ,docker search Software name . This article takes tomcat For example , Explain how to download the specified version TAG Of tomcat. Search for tomcat Mirror image $ sudo docker sear ...

  4. Start from scratch, build step by step Ubuntu Server The server 、 Modify the data source 、 install Docker、 Configure image Accelerator 、Compose Deploy Gitlab service

    scene The ultimate goal is to use Docker Compose Deploy a Gitlab service . effect notes : Blog : https://blog.csdn.net/badao_liumang_qizhi Official account Overbearing procedures ...

  5. Use docker compose Building multiple mirrors

    Definition docker compose version: ' services: composedb: image: mysql/mysql-server container_name: composedb ...

  6. Rancher + k8s + docker Deployment information

    One .k8s file : https://jimmysong.io/kubernetes-handbook/concepts/deployment.html Command line https://kubernetes ...

  7. docker Starting from scratch ( 3、 ... and ) First experience of service docker compose

    Prerequisite install Docker 1.13 Or later . obtain Docker Compose. Apply to Mac Of Docker And apply to Windows Of Docker On , It's pre installed , So you are free to use . stay Linux System ...

  8. k8s kubernetes Core notes Mirror warehouse project k8s reform ( Including the latest k8s v1.16.2 edition )

    k8s kubernetes Core notes Mirror warehouse project k8s reform 2019/10/24 Chenxin One Basic information One Reference resources : https://kubernetes.io/ Official website https://k ...

  9. Docker Compose Project package deployment

    Docker Compose We used Docker When , Definition Dockerfile file , And then use docker build.docker run Wait for the command to operate the container . However, the application system of microservice architecture is one ...

  10. be based on Docker Compose Of .NET Core Microservices continue to release

    Is it right now that every team needs to be on K8s It's trendy , no need K8s Is it out of date . today , I'll answer it through this article . One . Let's give my opinions and suggestions first What I want to say is , For a lot of small teams , Maybe it doesn't have to be K8s, After all, it is K ...

Random recommendation

  1. Java Common interview questions in

    1.sleep() and wait() The difference between : Both can control linear processes , Blocking process . The difference is that : -----|sleep(): Release CPU, Don't release resources ( lock ). You can make it wake up automatically by setting a time , Less than time can only call iter ...

  2. Android Wireless debugging

    First of all, make sure that computers and mobile phones are in a unified LAN . And know the LAN of mobile phone ip1. use usb Connect the phone and computer with the cable , And input... At the computer terminal adb tcpip 5555 adb connect <ip>2. Cancel usb Connect ...

  3. Android Development of music player implementation

    Android Music player Use to Android Of Actiivity and Service Components The code that plays the audio should run in the service , Define a playback service MusicService, The definition of service is play.stop.paus ...

  4. mongodb Update array appears can&#39;t append to array using string field name

    The contents of the database are as follows : { _id:, "hero_list" : { " : { , , "equip" : [ [ ], [ ], [ ], { , ...

  5. Codeigniter- Implement authority authentication

    The two methods Hook function Integration core Controller Method 1 , Hook function : Never found CI Permission authentication extension for , I seem to have found a foreigner's extension before , But it doesn't work very well , Now I can't remember , Later, I imitated jsp firter In the way of CI ...

  6. Java Regular expression removal in html label

    Java Regular expression removal in html The label of , The main purpose is to display the content more accurately , For example, some time ago, I was doing something similar to blog post function , After inputting content in the editor, the style label will also be transferred to the background and saved in the database , But when you display the summary , For example, display positive ...

  7. Play Use

        play frame   Packing command : play war e:/codes/cn.ngmc.frontend -o f:/backup_ngmc/20160614frontend_001Dev; namely :p ...

  8. Big Event in HDU HDU - 1171

    Topic link :http://acm.hdu.edu.cn/showproblem.php?pid=1171 The question : Give the value of each object and the number of objects , How to make A,B The value is closest and A You can't be less valuable than B Ideas ...

  9. The.Glory.of.Innovation The road to innovation 3 Let go of curiosity

    The most important thing in education is The problem is not to teach him all kinds of knowledge , But to cultivate his interest in learning , And when that interest is fully growing , Teach him how to study knowledge . ————   Rousseau     How to identify different views , The focus of the teacher's examination is not on the students ...

  10. Linux- Showdown Detailed command

    grammar shutdown( Options )( Parameters ) [ Options ] -c: When executed "shutdown -h 11:50" When the command , Just press + Key can interrupt the shutdown command : -f: Do not execute on restart fsck: -F ...