新聞中心
什么是 Serverless?
Serverless 是一種新型的計(jì)算模式,它將應(yīng)用程序的開(kāi)發(fā)、部署和運(yùn)維工作抽象為三個(gè)核心功能:函數(shù)(Function)、存儲(chǔ)(Store)和網(wǎng)絡(luò)(Network),在這種模式下,開(kāi)發(fā)者只需要關(guān)注業(yè)務(wù)邏輯的實(shí)現(xiàn),而不需要關(guān)心底層的基礎(chǔ)設(shè)施,Serverless 架構(gòu)可以大大降低企業(yè)的 IT 成本,提高開(kāi)發(fā)效率。

創(chuàng)新互聯(lián)公司:于2013年創(chuàng)立為各行業(yè)開(kāi)拓出企業(yè)自己的“網(wǎng)站建設(shè)”服務(wù),為近千家公司企業(yè)提供了專(zhuān)業(yè)的成都網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)和網(wǎng)站推廣服務(wù), 按需求定制制作由設(shè)計(jì)師親自精心設(shè)計(jì),設(shè)計(jì)的效果完全按照客戶(hù)的要求,并適當(dāng)?shù)奶岢龊侠淼慕ㄗh,擁有的視覺(jué)效果,策劃師分析客戶(hù)的同行競(jìng)爭(zhēng)對(duì)手,根據(jù)客戶(hù)的實(shí)際情況給出合理的網(wǎng)站構(gòu)架,制作客戶(hù)同行業(yè)具有領(lǐng)先地位的。
Serverless CI/CD 自動(dòng)化部署的優(yōu)勢(shì)
1、無(wú)需手動(dòng)配置服務(wù)器:Serverless 架構(gòu)自動(dòng)管理底層基礎(chǔ)設(shè)施,開(kāi)發(fā)者無(wú)需關(guān)心服務(wù)器的配置和維護(hù)。
2、按需付費(fèi):Serverless 服務(wù)按實(shí)際使用的資源計(jì)費(fèi),避免了傳統(tǒng)架構(gòu)中資源閑置和浪費(fèi)的問(wèn)題。
3、高度可擴(kuò)展:Serverless 架構(gòu)可以根據(jù)業(yè)務(wù)需求自動(dòng)擴(kuò)展或收縮資源,滿(mǎn)足不同階段的業(yè)務(wù)需求。
4、快速迭代:開(kāi)發(fā)者可以快速構(gòu)建、測(cè)試和部署應(yīng)用程序,縮短產(chǎn)品上市時(shí)間。
如何進(jìn)行 Serverless CI/CD 自動(dòng)化部署?
1、選擇合適的云服務(wù)商:首先需要選擇一個(gè)支持 Serverless 服務(wù)的云服務(wù)商,如 AWS、阿里云、騰訊云等。
2、創(chuàng)建函數(shù):在云服務(wù)商的管理控制臺(tái)中創(chuàng)建函數(shù),編寫(xiě)業(yè)務(wù)邏輯代碼,并將其部署到云端。
3、配置 Git 倉(cāng)庫(kù):將代碼托管到 Git 倉(cāng)庫(kù),如 GitHub、GitLab 等,在 Git 倉(cāng)庫(kù)中配置 CI/CD 流程,以便在代碼提交時(shí)自動(dòng)觸發(fā)構(gòu)建和部署。
4、安裝 CI/CD 工具:根據(jù)所選云服務(wù)商的支持情況,選擇合適的 CI/CD 工具,如 AWS CodePipeline、GitHub Actions、GitLab CI/CD 等,在項(xiàng)目根目錄下創(chuàng)建一個(gè) .ci/ 文件夾,用于存放 CI/CD 配置文件。
5、編寫(xiě) CI/CD 配置文件:根據(jù)所選 CI/CD 工具的文檔,編寫(xiě)相應(yīng)的配置文件,包括源代碼倉(cāng)庫(kù)地址、構(gòu)建觸發(fā)器、構(gòu)建步驟、部署步驟等,對(duì)于 AWS CodePipeline,可以編寫(xiě)如下 pipeline.yml 文件:
version: 1
parameters:
sourceRepository: ${CODEBUILD_SOURCE_REPO_URL}
baseImage: nodejs12.x
stages:
name: Build
steps:
name: Build application code
command: npm install && npm run build
name: Upload built package to S3 bucket
step: uploadArtifactToS3Bucket
artifacts:
name: builtPackage
path: path/to/built/package
inputArtifacts:
name: sourcePackage
path: path/to/source/package
actions:
name: uploadArtifactToS3BucketActionType
type: AmazonS3$PutObjectAction.v1
actionEndpoint: https://s3.amazonaws.com/mybucketname/action/uploadArtifactToS3Bucket/AWSLambda_1.0.0.lambda_abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ.zip/$(inputArtifactAt)(default).zip
inputs:
name: inputArtifactAt
key: path/to/source/package/*.zip
locationNamePattern: S3LocationConstraint=us-west-2,bucket=mybucketname,prefix=path/to/built/package/*.zip
lambdaPayloadFormatVersion: '1.0'
outputArtifacts:
name: builtPackageInS3BucketPathAndNameFormatStringKeyPrefixedWithOutputArtifactNameAndSuffixWithTimestampAndBuildNumber_$(outputArtifactName)_$(timestamp)_$(buildNumber)/$(inputArtifactAt)(default).zip
locationNamePattern: S3LocationConstraint=us-west-2,bucket=mybucketname,prefix=path/to/built/package/*.zip/*.zip
lambdaPayloadFormatVersion: '1.0'
runtimeOptions: RuntimeOption=nodejs12.x or any other runtime option for the base image you have chosen (e.g. nodejs10.x)
outputArtifactsPathsMapEntryList: [] this will be populated by the action during execution of the pipeline stage (i.e. when the built package is uploaded to S3) with the following structure: "{'artifactName': {'S3Location': {'bucket': 'mybucketname', 'key': 'path/to/built/package/*.zip/*.zip'}}}" this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.e. "bucket=mybucketname,key=path/to/built/package/*.zip/*.zip") this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.e. "bucket=mybucketname,key=path/to/built/package/*.zip/*.zip") this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.g. "bucket=mybucketname,key=path/to/built/package/*.zip/*.zip") this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.e. "bucket=mybucketname,key=path/to/built/package/*.zip/*.zip") this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.e. "bucket=mybucketname,key=path/to/built/package/*.zip/*.zip") this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.e. "bucket=mybucketname,key=path/to/built/package/*.zip/*.zip") this is a JSON string that contains the S3 bucket and key where the built package is stored in the format specified above (i.e. "bucket=mybucketname,key=path/to/built/package/*.zip/*
名稱(chēng)欄目:如何進(jìn)行ServerlessCI/CD自動(dòng)化部署
轉(zhuǎn)載來(lái)于:http://m.fisionsoft.com.cn/article/cdocddc.html


咨詢(xún)
建站咨詢(xún)
