CN113778549A - Implementation method, device, equipment and medium for replacing rear-end environment variables - Google Patents

Implementation method, device, equipment and medium for replacing rear-end environment variables Download PDF

Info

Publication number
CN113778549A
CN113778549A CN202110936327.XA CN202110936327A CN113778549A CN 113778549 A CN113778549 A CN 113778549A CN 202110936327 A CN202110936327 A CN 202110936327A CN 113778549 A CN113778549 A CN 113778549A
Authority
CN
China
Prior art keywords
configuration file
environment variable
configuration
environment
variable information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110936327.XA
Other languages
Chinese (zh)
Other versions
CN113778549B (en
Inventor
毕亮亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinan Inspur Data Technology Co Ltd
Original Assignee
Jinan Inspur Data Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinan Inspur Data Technology Co Ltd filed Critical Jinan Inspur Data Technology Co Ltd
Priority to CN202110936327.XA priority Critical patent/CN113778549B/en
Publication of CN113778549A publication Critical patent/CN113778549A/en
Application granted granted Critical
Publication of CN113778549B publication Critical patent/CN113778549B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method for realizing back-end environment variable replacement, which is applied to a micro-service architecture and comprises the following steps: acquiring an application version to be deployed, a deployment environment and environment variable information, and generating an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information; reading micro service environment variable information in a first configuration file, and rendering the read micro service environment variable information to container environment variable configuration in a second configuration file; scheduling and deploying the second configuration file, generating a corresponding container, and setting a system environment variable for the container according to the second configuration file; the invention also provides a device, equipment and medium for realizing the replacement of the rear-end environment variable, which effectively improves the deployment efficiency of the installation package when the installation package is deployed in different environments.

Description

Implementation method, device, equipment and medium for replacing rear-end environment variables
Technical Field
The invention relates to the field of variable replacement, in particular to a method, a device, equipment and a medium for realizing rear-end environment variable replacement.
Background
An ICM platform (abbreviated as a wave cloud management platform, a cloud management system designed by wave autonomous research and development) is based on a micro-service architecture (or micro-service, which is a cloud native architecture method, wherein a single application program is composed of a plurality of loosely-coupled and independently-deployable smaller components or services, the micro-service configures the application program into a group of loosely-coupled services, in a micro-service architecture, the services are fine-grained, and a protocol is lightweight), and the micro-service is deployed through kubernets (K8s, which is an open source and is used for managing containerized applications on a plurality of hosts in a cloud platform), and during the completion of new function development of the micro-service, the micro-service is sequentially deployed into a research and development environment (for development testing), a test environment (for acceptance), and a production environment (for use).
A GitLab (Git warehouse management tool) integrated by an ICM platform is used for performing a CI (persistent integration) process, and after performing socket _ build (container creation) and chart _ build (chart package creation) steps of GitlabCI in a micro service program, there is an issuing package (i.e., an installation package) of a hellm (package manager of Kubernetes) that can be deployed corresponding to a successful CI process.
Typically, the addresses of infrastructure, such as databases, are different in different environments, and the requirements for deploying services are: the installation package generated by packaging once can be deployed in different environments without repackaging the source code.
The method comprises the following steps that currently, a SpringBoot framework (a framework for simplifying the initial construction and development process of a new springapplication) provides support of environment variables, the SpringBoot supports externalized configuration, and a user is allowed to carry out externalized configuration on services through attribute files, YAML files (resource configuration files), environment variables and command line parameters; meanwhile, the @ Value and the @ configuration properties are allowed to be annotated to access the variables, but the scheme has limitations and cannot involve a packaging process, repackaging is needed when the environments to be deployed of the installation package are different, the environment variables cannot be directly replaced, and the deployment efficiency of the installation package is low.
Disclosure of Invention
In order to solve the problems in the prior art, the invention innovatively provides a method, a device, equipment and a medium for realizing the back-end environment variable replacement, effectively solves the problem of low deployment efficiency of an installation package when the installation package is deployed in different environments in the prior art, and effectively improves the deployment efficiency of the installation package when the installation package is deployed in different environments.
The invention provides a method for realizing back-end environment variable replacement, which is applied to a micro-service architecture and comprises the following steps:
acquiring an application version to be deployed, a deployment environment and environment variable information, and generating an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information;
reading micro service environment variable information in a first configuration file, and rendering the read micro service environment variable information to container environment variable configuration in a second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes;
scheduling and deploying the second configuration file, generating a corresponding container, and setting a system environment variable for the container according to the second configuration file;
and the container reads and sets system environment variables, and replaces the read environment variables with environment variable information with the same name in the original application program.
Optionally, before reading the micro service environment variable information in the first configuration file, the method further includes:
merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is the configuration file specified by the user through the command line, and the priority of the configuration items of the third configuration file is greater than that of the configuration items in the first configuration file.
Further, the specific way that the third configuration file covers the configuration items with the same name in the first configuration file is that: and replacing the first configuration item with a second configuration item, wherein the first configuration item is a configuration item with the same name as the configuration item in the third configuration file in the first configuration file, and the second configuration item is a configuration item with the same name as the first configuration item in the third configuration file.
Optionally, the third configuration file includes a plurality of sub-configuration files, and the file names of the third configuration file and the plurality of sub-configuration files both support custom settings.
Optionally, the reading of the micro service environment variable information in the first configuration file specifically includes: and directly accessing the micro service environment variable information in the first configuration file through a placeholder value mode.
Optionally, the micro-service environment variable is a lower key value pair, and the step of replacing the read environment variable with the environment variable information with the same name in the original application program specifically includes: and replacing the lower key value pair with the same name in the original application program.
Optionally, the installation package further includes a fourth configuration file, where the fourth configuration file is used to store attribute information of the installation package, and the attribute information of the installation package remains unchanged in the backend environment variable replacement process.
The second aspect of the present invention provides an apparatus for implementing back-end environment variable replacement, which is applied under a microservice architecture, and includes:
the acquisition module is used for acquiring the application version to be deployed, the deployment environment and the environment variable information and generating an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information;
the reading module is used for reading micro-service environment variable information in the first configuration file and rendering the read micro-service environment variable information to container environment variable configuration in the second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes;
the scheduling deployment module is used for scheduling and deploying the second configuration file, generating a corresponding container and setting system environment variables for the container according to the second configuration file;
and the replacing module is used for reading the set system environment variable by the container and replacing the read environment variable with the environment variable information with the same name in the original application program.
A third aspect of the present invention provides an electronic device comprising: a memory for storing a computer program; a processor for implementing the steps of a method for implementing a back-end environment variable replacement according to the first aspect of the present invention when executing the computer program.
A fourth aspect of the present invention provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, implements the steps of a method for implementing a back-end environment variable replacement according to the first aspect of the present invention.
The technical scheme adopted by the invention comprises the following technical effects:
1. in the technical scheme of the invention, the configuration file containing the environment variable information is set with the priority, the environment variable information configuration file with the high priority covers the environment variable information configuration file with the low priority, and the environment variable configuration file is directly modified without being repackaged, so that the problem of low deployment efficiency when the installation package is deployed in different environments in the prior art is effectively solved, and the deployment efficiency when the installation package is deployed in different environments is effectively improved.
2. In the technical solution of the present invention, before reading the micro service environment variable information in the first configuration file, the method further includes: merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is a configuration file specified by a user through a command line; and reading the micro-service environment variable information in the merged first configuration file, so that a user can replace the environment variable according to the actual condition without directly modifying the first configuration file in the installation package, and the installation package can be deployed in different environments.
3. In the technical scheme of the invention, the file name of the third configuration file supports the user-defined setting, so that the convenience and the flexibility of the name naming of the configuration file specified by a user are improved.
4. According to the technical scheme, the micro-service environment variable information in the first configuration file is directly accessed through the placeholder value taking mode, and the access efficiency of the environment variable is improved.
5. In the technical scheme of the invention, the micro service environment variable is the lower key value pair, and in the process of replacing the micro service environment variable, only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program, so that the replacement efficiency of the environment variable is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Drawings
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present invention, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained based on these drawings without any creative effort.
FIG. 1 is a schematic flow diagram of a process according to an embodiment of the present invention;
FIG. 2 is another schematic flow diagram of a process according to an embodiment of the present invention;
FIG. 3 is a schematic view showing the structure of an apparatus according to a second embodiment of the present invention;
FIG. 4 is another schematic structural diagram of an apparatus according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a third apparatus in an embodiment of the present invention.
Detailed Description
In order to clearly explain the technical features of the present invention, the following detailed description of the present invention is provided with reference to the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different features of the invention. To simplify the disclosure of the present invention, the components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and procedures are omitted so as to not unnecessarily limit the invention.
Example one
As shown in fig. 1, the present invention provides a method for implementing a back-end environment variable replacement, which is applied under a micro-service architecture, and includes:
s1, acquiring the application version to be deployed, the deployment environment and the environment variable information, and generating an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information;
s3, reading micro service environment variable information in the first configuration file, and rendering the read micro service environment variable information to container environment variable configuration in the second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes;
s5, scheduling and deploying the second configuration file, generating a corresponding container, and setting system environment variables for the container according to the second configuration file;
and S7, the container reads the set system environment variables and replaces the read environment variables with the environment variable information with the same name in the original application program.
In step S1, the deployment environment refers to the type or name information of the environment to be deployed, and the environment variable information specifically refers to the variable information in the environment under the micro service architecture to be deployed. The installation package is specifically a chart package.
In step S3, the template file in the installation package (chart package) reads the micro service environment variable information in the first configuration file, and renders the read micro service environment variable information into the container environment variable configuration in the second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes; the first configuration file, that is, a values.yaml file (directory is/book/definitions-service/values.yaml) in the installation package, stores environment variable information to be deployed, where the environment variable information may specifically be a key-value pair under the env.open and starts with the env.open. In the process of replacing the micro service environment variable, only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program. The second profile, the deployment profile in the keyenetes. The reading of the micro service environment variable information in the first configuration file specifically includes: the micro-service environment variable information in the first configuration file is directly accessed through a placeholder value form, namely the micro-service environment variable information is realized through the form of { {. value.
Figure BDA0003213000920000071
Figure BDA0003213000920000081
The installation package further includes a fourth configuration file, i.e., a chart. yaml file, which stores attribute information of the installation package. The attribute information of the installation package includes, but is not limited to, name information, version information, and attribute description information of the installation package, and the attribute information of the installation package remains unchanged in the process of replacing the backend environment variable. For example, name: [ must ] the name of the chart package; version [ must ] the version number of the chart packet, the version number must accord with SemVer2 (semantic version specification); description [ optional ] brief description of Chart packet; keyword- [ optional ] keyword list for easy search; home: [ optional ] item address; source- [ optional ] download address list of current Chart; email is [ optional ] mailbox; engine, gotpl # [ optional ] template engine, default is gotpl; icon [ optional ] a picture address in SVG (Scalable Vector Graphics) or PNG (Portable Network Graphics Format) Format.
In steps S5-S7, the keyenetes schedules and deploys a second configuration file (deployment file), generates a corresponding docker container, and sets a system environment variable for the container according to a key value pair in spec.template.spec.contacts.env in the second configuration file; starting a springboot project running in the container, reading and setting system environment variables, and replacing (covering) the read environment variables with environment variable information with the same name in the original application program (jar package). The jar package in the original application program (the project management tool software maven packages the springboot project into the jar package) comprises two initial configuration files, namely boot.yml and application.yml, and when a container reads and replaces and sets system environment variables, the read environment variables are replaced (covered) by environment variable information with the same name in the two initial configuration files (boot.yml and application.yml), namely the covering (replacing) priority of the first configuration file in the boot package is greater than the priority of the initial configuration file of the original application program.
After step S7, a release file that can be directly deployed is finally generated, deployment of the installation package in the corresponding environment is achieved, when the application environment changes, the environment variable information in the first configuration file can be modified, and only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program, so that quick replacement of the environment variable information is achieved, and therefore quick installation of the same installation package in different environments is achieved, repackaging is not needed, and deployment efficiency is improved.
Further, as shown in fig. 2, before step S3, the embodiment of the present invention further includes:
s2, merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is the configuration file specified by the user through the command line, and the priority of the configuration items of the third configuration file is greater than that of the configuration items in the first configuration file.
Wherein, the specific way that the third configuration file covers the configuration items with the same name in the first configuration file is as follows: and replacing the first configuration item with a second configuration item, wherein the first configuration item is a configuration item with the same name as the configuration item in the third configuration file in the first configuration file, and the second configuration item is a configuration item with the same name as the first configuration item in the third configuration file.
The third configuration file is a configuration file specified by a user through a command line (helminthall or helmupgrade), the third configuration file includes a plurality of sub-configuration files, and the file names of the third configuration file and the plurality of sub-configuration files support custom settings, such as value and other custom file names, which is not limited herein.
Therefore, in the trial process, when the third configuration file specified by the user is searched, the second configuration item in the third configuration file is firstly replaced by the first configuration item in the first configuration file, and the third configuration file and the first configuration file are merged into a new first configuration file. And reading the micro service environment variable information in the merged new first configuration file by the template file.
It should be noted that, steps S1-S7 of the present invention can be implemented by hardware or software language programming, and the implementation idea corresponds to the steps, and can also be implemented by other manners, which is not limited herein.
In the technical scheme of the invention, the configuration file containing the environment variable information is set with the priority, the environment variable information configuration file with the high priority covers the environment variable information configuration file with the low priority, and the environment variable configuration file is directly modified without being repackaged, so that the problem of low deployment efficiency when the installation package is deployed in different environments in the prior art is effectively solved, and the deployment efficiency when the installation package is deployed in different environments is effectively improved.
In the technical solution of the present invention, before reading the micro service environment variable information in the first configuration file, the method further includes: merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is a configuration file specified by a user through a command line; and reading the micro-service environment variable information in the merged first configuration file, so that a user can replace the environment variable according to the actual condition without directly modifying the first configuration file in the installation package, and the installation package can be deployed in different environments.
In the technical scheme of the invention, the file name of the third configuration file supports the user-defined setting, so that the convenience and the flexibility of the name naming of the configuration file specified by a user are improved.
According to the technical scheme, the micro-service environment variable information in the first configuration file is directly accessed through the placeholder value taking mode, and the access efficiency of the environment variable is improved.
In the technical scheme of the invention, the micro service environment variable is the lower key value pair, and in the process of replacing the micro service environment variable, only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program, so that the replacement efficiency of the environment variable is improved.
Example two
As shown in fig. 3, the technical solution of the present invention further provides an implementation apparatus for replacing a back-end environment variable, which is applied under a microservice architecture, and includes:
the acquiring module 101 acquires an application version to be deployed, a deployment environment and environment variable information, and generates an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information;
the reading module 102 is used for reading micro-service environment variable information in the first configuration file and rendering the read micro-service environment variable information into container environment variable configuration in the second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes;
the scheduling deployment module 103 is used for scheduling and deploying the second configuration file, generating a corresponding container and setting a system environment variable for the container according to the second configuration file;
and a replacing module 104, in which the container reads and sets the system environment variable, and replaces the read environment variable with the environment variable information with the same name in the original application program.
In the obtaining module 101, the deployment environment refers to the type or name information of the environment to be deployed, and the environment variable information specifically refers to variable information in the environment to be deployed. The installation package is specifically a chart package.
In the reading module 102, a template file in an installation package (chart package) reads micro service environment variable information in a first configuration file, and renders the read micro service environment variable information into a container environment variable configuration in a second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes; the first configuration file, that is, a values.yaml file (directory is/book/definitions-service/values.yaml) in the installation package, stores environment variable information to be deployed, where the environment variable information may specifically be a key-value pair under the env.open and starts with the env.open. The second profile, the deployment profile in the keyenetes. The reading of the micro service environment variable information in the first configuration file specifically includes: the micro-service environment variable information in the first configuration file is directly accessed through a placeholder value form, namely the micro-service environment variable information is realized through the form of { {. value.
The installation package further includes a fourth configuration file, i.e., a chart. yaml file, which stores attribute information of the installation package. The attribute information of the installation package includes, but is not limited to, name information, version information, and attribute description information of the installation package, and the attribute information of the installation package remains unchanged in the process of replacing the backend environment variable. For example, name: [ must ] the name of the chart package; version [ must ] the version number of the chart packet, the version number must accord with SemVer2 (semantic version specification); description [ optional ] brief description of Chart packet; keyword- [ optional ] keyword list for easy search; home: [ optional ] item address; source- [ optional ] download address list of current Chart; email is [ optional ] mailbox; engine, gotpl # [ optional ] template engine, default is gotpl; icon [ optional ] a picture address in SVG (Scalable Vector Graphics) or PNG (Portable Network Graphics Format) Format.
In the scheduling deployment module 103 and the replacement module 104, the keyenetes schedules and deploys a second configuration file (deployment file), generates a corresponding docker container, and sets a system environment variable for the container according to a key value pair in spec.template.spec.contacts.env in the second configuration file; starting a springboot project running in the container, reading and setting system environment variables, and replacing (covering) the read environment variables with environment variable information with the same name in the original application program (jar package). The jar package in the original application program (the project management tool software maven packages the springboot project into the jar package) comprises two initial configuration files, namely boot.yml and application.yml, and when a container reads and replaces and sets system environment variables, the read environment variables are replaced (covered) by environment variable information with the same name in the two initial configuration files (boot.yml and application.yml), namely the covering (replacing) priority of the first configuration file in the boot package is greater than the priority of the initial configuration file of the original application program.
After passing through the replacement module 104, a release file capable of being directly deployed is finally generated, deployment of the installation package in a corresponding environment is achieved, and when an application environment is changed, replacement of environment variable information can be achieved by modifying the environment variable information in the first configuration file, so that the same installation package can be quickly installed in different environments without repacking, and deployment efficiency is improved.
Further, as shown in fig. 4, the embodiment of the present invention further includes:
the merging module 105 merges the third configuration file with the first configuration file, and the third configuration file covers the configuration items with the same name in the first configuration file; and the third configuration file is the configuration file specified by the user through the command line.
Wherein, the specific way that the third configuration file covers the configuration items with the same name in the first configuration file is as follows: and replacing the first configuration item with a second configuration item, wherein the first configuration item is a configuration item with the same name as the configuration item in the third configuration file in the first configuration file, and the second configuration item is a configuration item with the same name as the first configuration item in the third configuration file.
The third configuration file is a configuration file specified by a user through a command line (film insert or film upgrade), the third configuration file includes a plurality of sub configuration files, and the file names of the third configuration file and the plurality of sub configuration files both support custom settings, for example, the third configuration file may be a value or other custom file names, which is not limited herein.
Therefore, in the trial process, when the third configuration file specified by the user is searched, the second configuration item in the third configuration file is firstly replaced by the first configuration item in the first configuration file, and the third configuration file and the first configuration file are merged into a new first configuration file. And then reading the micro service environment variable information in the merged first configuration file by the template file.
In the technical scheme of the invention, the configuration file containing the environment variable information is set with the priority, the environment variable information configuration file with the high priority covers the environment variable information configuration file with the low priority, and the environment variable configuration file is directly modified without being repackaged, so that the problem of low deployment efficiency when the installation package is deployed in different environments in the prior art is effectively solved, and the deployment efficiency when the installation package is deployed in different environments is effectively improved.
In the technical solution of the present invention, before reading the micro service environment variable information in the first configuration file, the method further includes: merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is a configuration file specified by a user through a command line; and reading the micro-service environment variable information in the merged first configuration file, so that a user can replace the environment variable according to the actual condition without directly modifying the first configuration file in the installation package, and the installation package can be deployed in different environments.
In the technical scheme of the invention, the file name of the third configuration file supports the user-defined setting, so that the convenience and the flexibility of the name naming of the configuration file specified by a user are improved.
According to the technical scheme, the micro-service environment variable information in the first configuration file is directly accessed through the placeholder value taking mode, and the access efficiency of the environment variable is improved.
In the technical scheme of the invention, the micro service environment variable is the lower key value pair, and in the process of replacing the micro service environment variable, only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program, so that the replacement efficiency of the environment variable is improved.
EXAMPLE III
As shown in fig. 5, the present invention further provides an electronic device, including: a memory 201 for storing a computer program; the processor 202 is configured to implement the steps of the method according to the first embodiment when executing the computer program.
The memory 201 in the embodiments of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program for operating on an electronic device. It will be appreciated that the memory 201 can be either volatile memory or nonvolatile memory, and can include both volatile and nonvolatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical disk, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Enhanced Synchronous Dynamic Random Access Memory (Enhanced DRAM), Synchronous Dynamic Random Access Memory (SLDRAM), Direct Memory (DRmb Access), and Random Access Memory (DRAM). The memory 201 described in embodiments herein is intended to comprise, without being limited to, these and any other suitable types of memory. The method disclosed in the embodiments of the present application may be applied to the processor 202, or implemented by the processor 202. The processor 202 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 202. The processor 202 may be a general-purpose processor, a DSP (Digital Signal Processing, i.e., a chip capable of implementing Digital Signal Processing), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc. Processor 202 may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium located in the memory 201, and the processor 202 reads the program in the memory 201 and performs the steps of the foregoing method in combination with its hardware. When the processor 202 executes the program, the corresponding processes in the methods according to the embodiments of the present application are realized, and for brevity, are not described herein again.
In the technical scheme of the invention, the configuration file containing the environment variable information is set with the priority, the environment variable information configuration file with the high priority covers the environment variable information configuration file with the low priority, and the environment variable configuration file is directly modified without being repackaged, so that the problem of low deployment efficiency when the installation package is deployed in different environments in the prior art is effectively solved, and the deployment efficiency when the installation package is deployed in different environments is effectively improved.
In the technical solution of the present invention, before reading the micro service environment variable information in the first configuration file, the method further includes: merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is a configuration file specified by a user through a command line; and reading the micro-service environment variable information in the merged first configuration file, so that a user can replace the environment variable according to the actual condition without directly modifying the first configuration file in the installation package, and the installation package can be deployed in different environments.
In the technical scheme of the invention, the file name of the third configuration file supports the user-defined setting, so that the convenience and the flexibility of the name naming of the configuration file specified by a user are improved.
According to the technical scheme, the micro-service environment variable information in the first configuration file is directly accessed through the placeholder value taking mode, and the access efficiency of the environment variable is improved.
In the technical scheme of the invention, the micro service environment variable is the lower key value pair, and in the process of replacing the micro service environment variable, only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program, so that the replacement efficiency of the environment variable is improved.
Example four
The technical solution of the present invention further provides a computer-readable storage medium, which is characterized in that a computer program is stored on the computer-readable storage medium, and the computer program, when executed by a processor, implements the steps of the method according to the first embodiment.
For example, comprising a memory 201 storing a computer program executable by a processor 202 for performing the steps of the method as described above. The computer readable storage medium may be memory such as FRAM, ROM, PROM, EPROM, EEPROM, FlashMemory, magnetic surface memory, optical disk, or CD-ROM.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code. Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof that contribute to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
In the technical scheme of the invention, the configuration file containing the environment variable information is set with the priority, the environment variable information configuration file with the high priority covers the environment variable information configuration file with the low priority, and the environment variable configuration file is directly modified without being repackaged, so that the problem of low deployment efficiency when the installation package is deployed in different environments in the prior art is effectively solved, and the deployment efficiency when the installation package is deployed in different environments is effectively improved.
In the technical solution of the present invention, before reading the micro service environment variable information in the first configuration file, the method further includes: merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is a configuration file specified by a user through a command line; and reading the micro-service environment variable information in the merged first configuration file, so that a user can replace the environment variable according to the actual condition without directly modifying the first configuration file in the installation package, and the installation package can be deployed in different environments.
In the technical scheme of the invention, the file name of the third configuration file supports the user-defined setting, so that the convenience and the flexibility of the name naming of the configuration file specified by a user are improved.
According to the technical scheme, the micro-service environment variable information in the first configuration file is directly accessed through the placeholder value taking mode, and the access efficiency of the environment variable is improved.
In the technical scheme of the invention, the micro service environment variable is the lower key value pair, and in the process of replacing the micro service environment variable, only the read lower key value pair needs to be replaced by the lower key value pair with the same name in the original application program, so that the replacement efficiency of the environment variable is improved.
Although the embodiments of the present invention have been described with reference to the accompanying drawings, it is not intended to limit the scope of the present invention, and it should be understood by those skilled in the art that various modifications and variations can be made without inventive efforts by those skilled in the art based on the technical solution of the present invention.

Claims (10)

1. A method for realizing back-end environment variable replacement is characterized by being applied to a micro-service architecture and comprising the following steps:
acquiring an application version to be deployed, a deployment environment and environment variable information, and generating an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information;
reading micro service environment variable information in a first configuration file, and rendering the read micro service environment variable information to container environment variable configuration in a second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes;
scheduling and deploying the second configuration file, generating a corresponding container, and setting a system environment variable for the container according to the second configuration file;
and the container reads and sets system environment variables, and replaces the read environment variables with environment variable information with the same name in the original application program.
2. The method of claim 1, wherein before reading the information about the micro-service environment variables in the first configuration file, the method further comprises:
merging the third configuration file and the first configuration file into a new first configuration file, wherein the third configuration file covers the configuration items with the same name in the first configuration file; the third configuration file is the configuration file specified by the user through the command line, and the priority of the configuration items of the third configuration file is greater than that of the configuration items in the first configuration file.
3. The method for implementing the replacement of the back-end environment variable according to claim 2, wherein the third configuration file covers the configuration items with the same name in the first configuration file specifically includes: and replacing the first configuration item with a second configuration item, wherein the first configuration item is a configuration item with the same name as the configuration item in the third configuration file in the first configuration file, and the second configuration item is a configuration item with the same name as the first configuration item in the third configuration file.
4. The method as claimed in claim 2, wherein the third configuration file includes a plurality of sub-configuration files, and the file names of the third configuration file and the plurality of sub-configuration files support custom settings.
5. The method for implementing the replacement of the back-end environment variable according to claim 1, wherein the reading of the micro-service environment variable information in the first configuration file specifically includes: and directly accessing the micro service environment variable information in the first configuration file through a placeholder value mode.
6. The method for implementing the replacement of the back-end environment variable according to any one of claims 1 to 5, wherein the micro-service environment variable is a lower key value pair, and the step of replacing the read environment variable with the environment variable information with the same name in the original application program is specifically as follows: and replacing the lower key value pair with the same name in the original application program.
7. The method for implementing the replacement of the back-end environment variables according to any one of claims 1 to 5, wherein the installation package further includes a fourth configuration file, the fourth configuration file is used for storing attribute information of the installation package, and the attribute information of the installation package remains unchanged in the process of the replacement of the back-end environment variables.
8. An implementation device for replacing a back-end environment variable is applied to a micro-service architecture, and comprises:
the acquisition module is used for acquiring the application version to be deployed, the deployment environment and the environment variable information and generating an installation package according to the acquired application version to be deployed, the deployment environment and the environment variable information;
the reading module is used for reading micro-service environment variable information in the first configuration file and rendering the read micro-service environment variable information to container environment variable configuration in the second configuration file; the first configuration file is a configuration file of all variable default configuration values in the installation package, and the second configuration file is a variable configuration file in the keyenetes;
the scheduling deployment module is used for scheduling and deploying the second configuration file, generating a corresponding container and setting system environment variables for the container according to the second configuration file;
and the replacing module is used for reading the set system environment variable by the container and replacing the read environment variable with the environment variable information with the same name in the original application program.
9. An electronic device, comprising: a memory for storing a computer program; a processor for implementing the steps of a method for implementing a back-end environment variable replacement as claimed in any one of claims 1 to 7 when executing said computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of a method for implementing a back-end environment variable replacement according to any one of claims 1 to 7.
CN202110936327.XA 2021-08-16 2021-08-16 Method, device, equipment and medium for realizing back-end environment variable replacement Active CN113778549B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110936327.XA CN113778549B (en) 2021-08-16 2021-08-16 Method, device, equipment and medium for realizing back-end environment variable replacement

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110936327.XA CN113778549B (en) 2021-08-16 2021-08-16 Method, device, equipment and medium for realizing back-end environment variable replacement

Publications (2)

Publication Number Publication Date
CN113778549A true CN113778549A (en) 2021-12-10
CN113778549B CN113778549B (en) 2023-12-22

Family

ID=78837824

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110936327.XA Active CN113778549B (en) 2021-08-16 2021-08-16 Method, device, equipment and medium for realizing back-end environment variable replacement

Country Status (1)

Country Link
CN (1) CN113778549B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107959579A (en) * 2016-10-14 2018-04-24 北京京东尚科信息技术有限公司 The dispositions method and deployment system of multisystem
US10558455B1 (en) * 2018-10-23 2020-02-11 International Business Machines Corporation Managing an update of a software module in a layered filesystem
CN111309441A (en) * 2020-02-19 2020-06-19 北京中数智汇科技股份有限公司 Micro-service deployment method for realizing DevOps based on Jenkins
CN112835676A (en) * 2021-01-27 2021-05-25 北京远盟普惠健康科技有限公司 Deployment method and device of containerized application, computer equipment and medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107959579A (en) * 2016-10-14 2018-04-24 北京京东尚科信息技术有限公司 The dispositions method and deployment system of multisystem
US10558455B1 (en) * 2018-10-23 2020-02-11 International Business Machines Corporation Managing an update of a software module in a layered filesystem
CN111309441A (en) * 2020-02-19 2020-06-19 北京中数智汇科技股份有限公司 Micro-service deployment method for realizing DevOps based on Jenkins
CN112835676A (en) * 2021-01-27 2021-05-25 北京远盟普惠健康科技有限公司 Deployment method and device of containerized application, computer equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
毛祺;卢胜林;: "基于Docker Swarm集群的容器迁移策略的实现", 信息技术, no. 09 *

Also Published As

Publication number Publication date
CN113778549B (en) 2023-12-22

Similar Documents

Publication Publication Date Title
EP3441876B1 (en) Patch upgrade-based file processing method and device, terminal, and storage medium
CN108958796B (en) Service request processing method and device and service request processing system
US20200410031A1 (en) Systems and methods for cloud computing
US10599413B2 (en) Method and device for identifying file
WO2021164367A1 (en) Container mirror image providing method, container mirror image loading method, and related device and system
CN107368331B (en) Configuration file updating method and device for application program
CN112181588A (en) Application containerization method and device, electronic equipment and storage medium
US9747303B1 (en) File location application programming interface
CN111897623B (en) Cluster management method, device, equipment and storage medium
US9513762B1 (en) Static content updates
CN112346818A (en) Container application deployment method and device, electronic equipment and storage medium
CN114780198A (en) Client screen adapting method and device and electronic equipment
CN112235132B (en) Method, device, medium and server for dynamically configuring service
CN115080114B (en) Application program transplanting processing method, device and medium
CN113778549A (en) Implementation method, device, equipment and medium for replacing rear-end environment variables
WO2020135129A1 (en) Method and device for loading plug-in of application, and terminal
CN110968333B (en) Configuration information replacement method and device, machine-readable storage medium and processor
CN115658109A (en) Micro-service heat deployment method, system, electronic device and storage medium
CN116303309A (en) File mounting method and device and electronic equipment
CN115237631A (en) Easily-extensible data sharing system and method based on data sharing plug-in
CN115586872A (en) Container mirror image management method, device, equipment and storage medium
CN114816772A (en) Debugging method, debugging system and computing device for application running based on compatible layer
CN113010206A (en) Containerization method, system and device for WEB application system
CN110888649B (en) Application deployment method, application baseline creation method and device
CN113507529A (en) Method for realizing file downloading based on Web application

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant