Commit 1276c837 by 李二毛

Merge branch 'development' into 'release/staging'

新增搜索微服务,测试发布版本v2

See merge request liermao/microservice-autodevopspipelines!112
parents 7d9500eb f7e54dfd
Pipeline #4383 passed with stages
in 1 minute 18 seconds
......@@ -54,6 +54,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MvcExtensions", "src\BuildingBlocks\Extensions\MvcExtensions\MvcExtensions.csproj", "{2FFD7AC6-1A55-4B6E-BF9D-1B85CC5AE193}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Searching", "Searching", "{2176B42B-AC54-48BE-82F7-104ADEEF2FEF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Searching.Api", "src\Services\Searching\Searching.Api\Searching.Api.csproj", "{47530BB8-0971-4D51-9EAA-9F74DFF8458D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -92,6 +96,10 @@ Global
{2FFD7AC6-1A55-4B6E-BF9D-1B85CC5AE193}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2FFD7AC6-1A55-4B6E-BF9D-1B85CC5AE193}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2FFD7AC6-1A55-4B6E-BF9D-1B85CC5AE193}.Release|Any CPU.Build.0 = Release|Any CPU
{47530BB8-0971-4D51-9EAA-9F74DFF8458D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47530BB8-0971-4D51-9EAA-9F74DFF8458D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47530BB8-0971-4D51-9EAA-9F74DFF8458D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47530BB8-0971-4D51-9EAA-9F74DFF8458D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -115,6 +123,8 @@ Global
{E53A0586-2FB1-4708-91A9-4D6814E02E3C} = {779A24FC-0621-4085-AB80-9BD0BB6AF605}
{26EA0840-FACE-4F72-B7D0-64CA9443BD9F} = {E53A0586-2FB1-4708-91A9-4D6814E02E3C}
{2FFD7AC6-1A55-4B6E-BF9D-1B85CC5AE193} = {26EA0840-FACE-4F72-B7D0-64CA9443BD9F}
{2176B42B-AC54-48BE-82F7-104ADEEF2FEF} = {5267E5D9-2B87-4B75-92FD-111624A81E7D}
{47530BB8-0971-4D51-9EAA-9F74DFF8458D} = {2176B42B-AC54-48BE-82F7-104ADEEF2FEF}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94A499F2-8AA4-43FC-9824-F095E42D54AB}
......
#!/bin/bash
set -e
IFS=$'\n\n'
# Import external functions
chmod +x ./devops/PipeLines/Functions.deploy.sh
source ./devops/PipeLines/Functions.deploy.sh
# global variable
RollEnvironmentOf Environment
GetNameSpace namespace
GetReplicas replicas
GetAppName appName
echo "[${Environment}]Auto scaling for ${appName} starting..."
GetCiCdSettings allPublishable noPublishable
if [ "${noPublishable}" == "1" ] ;
if [ "${AllPublishable}" == "1" ];
then
echo ""
echo "Tips: No services need to be cded."
echo "Tips: All micro-services will be scaled, replicas: [${replicas}]."
for servicePrefix in `ls ./src/Services|xargs -d '/'`
do
GetServiceName ${servicePrefix} serviceName
AutoScaling ${namespace} ${serviceName} ${replicas}
done
else
GetNameSpace namespace
GetReplicas replicas
for servicePrefix in `ls ./src/Services|xargs -d '/'`
do
IsPublishableOf ${servicePrefix} isPublishable
GetServiceName ${servicePrefix} serviceName
DynamicVariableValueOf "${servicePrefix}" "Publishable" isPublishable
if [ "${isPublishable}" == "1" ];
then
echo ""
echo "Tips: ${serviceName} begin scaling, replicas: [${replicas}]!!!"
then
echo "Tips: ${servicePrefix} will be scaled, replicas: [${replicas}]."
GetServiceName ${servicePrefix} serviceName
AutoScaling ${namespace} ${serviceName} ${replicas}
else
echo ""
echo "Tips: ${serviceName} will not be scaled!!!"
fi
fi
done
fi
echo ""
echo "[${Environment}]Auto scaling for ${appName} has been successful."
\ No newline at end of file
fi
\ No newline at end of file
#!/bin/bash
set -e
IFS=$'\n\n'
# Import external functions
chmod +x ./devops/PipeLines/Functions.deploy.sh
source ./devops/PipeLines/Functions.deploy.sh
# global variable
RollEnvironmentOf Environment
ReleaseEnvironmentOf Environment
GetAppName appName
GetRollBackVersion version
GetNameSpace namespace
GetRegistryHost registryHost
GetImageUserName registryUserName
echo "Continuous deployment[${Environment}] for ${appName} starting..."
GetCiCdSettings allPublishable noPublishable
if [ "${noPublishable}" == "1" ] ;
if [ "${AllPublishable}" == "1" ];
then
echo ""
echo "Tips: No services need to be cded."
echo "Tips: All micro-services will be roll-backed, version: ${version}."
for servicePrefix in `ls ./src/Services|xargs -d '/'`
do
GetServiceName ${servicePrefix} serviceName
CD ${registryHost} ${registryUserName} ${serviceName} ${version} ${namespace}
done
else
GetRollBackVersion version
GetNameSpace namespace
GetRegistryHost registryHost
GetImageUserName registryUserName
for servicePrefix in `ls ./src/Services|xargs -d '/'`
do
IsPublishableOf ${servicePrefix} isPublishable
GetServiceName ${servicePrefix} serviceName
DynamicVariableValueOf "${servicePrefix}" "Publishable" isPublishable
if [ "${isPublishable}" == "1" ];
then
echo ""
echo "Tips: ${serviceName} begin deployment to K8S!!!"
then
echo "Tips: ${servicePrefix} will be roll-backed, version: ${version}."
GetServiceName ${servicePrefix} serviceName
CD ${registryHost} ${registryUserName} ${serviceName} ${version} ${namespace}
else
echo ""
echo "Tips: ${serviceName} will not be deploymented to K8S!!!"
fi
fi
done
fi
echo ""
echo "Continuous deployment[${Environment}] for ${appName} has been successful."
fi
\ No newline at end of file
......@@ -33,6 +33,10 @@ function AddTailConfig()
if [ "${AllPublishable}" == "1" ];
then
AddHeadConfig "1" "0"
for servicePrefix in `ls ./src/Services|xargs -d '/'`
do
AddConfig "${servicePrefix}" "1"
done
AddTailConfig
echo "All micro-services will be released."
......
<Project>
<PropertyGroup>
<Replicas>1</Replicas>
<Replicas>2</Replicas>
<RollBackStep>1</RollBackStep>
<ImageUserName>devopspipelines</ImageUserName>
</PropertyGroup>
......
<Project>
<PropertyGroup>
<Major>1</Major>
<Major>2</Major>
<Minor>0</Minor>
<Patch>0</Patch>
</PropertyGroup>
......
......@@ -8,23 +8,26 @@ helm install --debug --dry-run /root/AutoDevOpsPipeLinesCharts \
--name=v1 \
--set environment.upper=Production \
--set environment.lower=production \
--set namespace=microservice-autodevopspipeline-v0 \
--set image.version=0.0.0 \
--set namespace=microservice-autodevopspipeline-v1 \
--set image.registryhost=registry.prod.com:8100 \
--set image.username=devopspipelines \
--set image.version=1.0.0 \
--set replicas=1
```
## 发布版本
```shell
helm install /root/AutoDevOpsPipeLinesCharts \
--name=geekbuying-light-v2 \
--name=v1 \
--set environment.upper=Production \
--set environment.lower=production \
--set namespace=geekbuying-light-v3 \
--set image.version=2.0.0
--set namespace=microservice-autodevopspipeline-v1 \
--set image.registryhost=registry.prod.com:8100 \
--set image.username=devopspipelines \
--set image.version=1.0.0 \
--set replicas=1
```
## 检视发布
helm get manifest [release name]
......
......@@ -258,4 +258,48 @@ spec:
subPath: "appsettings.{{ .Values.environment.upper }}.json"
env:
- name: ASPNETCORE_ENVIRONMENT
value: "{{ .Values.environment.upper }}"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: seaching-api
namespace: {{ .Values.namespace }}
spec:
selector:
matchLabels:
app: auto-devops-pipelines
component: seaching
type: webapi
replicas: {{ .Values.replicas }}
template:
metadata:
labels:
app: auto-devops-pipelines
component: seaching
type: webapi
spec:
volumes:
- name: appsetting
configMap:
name: seaching.appsettings.json
- name: appsetting-{{ .Values.environment.lower }}
configMap:
name: seaching.appsettings.{{ .Values.environment.lower }}.json
containers:
- name: seaching-api
image: {{ .Values.image.registryhost }}/{{ .Values.image.username }}/seaching.api:{{ .Values.image.version }}
imagePullPolicy: Always
ports:
- containerPort: 80
volumeMounts:
- name: appsetting
mountPath: "/app/appsettings.json"
subPath: "appsettings.json"
- name: appsetting-{{ .Values.environment.lower }}
mountPath: "/app/appsettings.{{ .Values.environment.upper }}.json"
subPath: "appsettings.{{ .Values.environment.upper }}.json"
env:
- name: ASPNETCORE_ENVIRONMENT
value: "{{ .Values.environment.upper }}"
\ No newline at end of file
......@@ -103,4 +103,22 @@ spec:
selector:
app: auto-devops-pipelines
component: payment
type: webapi
---
apiVersion: v1
kind: Service
metadata:
labels:
app: auto-devops-pipelines
component: seaching
name: seaching-api
namespace: {{ .Values.namespace }}
spec:
type: ClusterIP
ports:
- port: 80
selector:
app: auto-devops-pipelines
component: seaching
type: webapi
\ No newline at end of file
......@@ -7,7 +7,7 @@ using MvcExtensions;
namespace Catalog.API
{
public class Startup
public class Startup
{
public Startup(IConfiguration configuration)
{
......
......@@ -7,7 +7,7 @@ using MvcExtensions;
namespace Identity.API
{
public class Startup
public class Startup
{
public Startup(IConfiguration configuration)
{
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace Searching.Api.Controllers
{
[Route("[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
[HttpGet("{id}")]
public ActionResult<string> Get(int id)
{
return "value";
}
// POST api/values
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}
FROM microsoft/dotnet:2.2.0-aspnetcore-runtime
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
MAINTAINER geekbuy.cn
WORKDIR /app
COPY . .
EXPOSE 80
ENTRYPOINT ["dotnet", "Searching.Api.dll"]
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace Searching.Api
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55470",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Searching.Api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\BuildingBlocks\Extensions\MvcExtensions\MvcExtensions.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using MvcExtensions;
namespace Searching.Api
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(it => it.UseCentralRoutePrefix("/api/searching")).SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseMvc();
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment