新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
16
learn/learn-kubernetes-master/kiamol/ch02/deployment.yaml
Normal file
16
learn/learn-kubernetes-master/kiamol/ch02/deployment.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: hello-kiamol-4
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: hello-kiamol-4
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: hello-kiamol-4
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch02-hello-kiamol
|
||||
@@ -0,0 +1,8 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
ch02-hello-kiamol:
|
||||
image: kiamol/ch02-hello-kiamol:latest-linux-amd64
|
||||
|
||||
ch02-whoami:
|
||||
image: kiamol/ch02-whoami:latest-linux-amd64
|
||||
@@ -0,0 +1,8 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
ch02-hello-kiamol:
|
||||
image: kiamol/ch02-hello-kiamol:latest-linux-arm64
|
||||
|
||||
ch02-whoami:
|
||||
image: kiamol/ch02-whoami:latest-linux-arm64
|
||||
@@ -0,0 +1,12 @@
|
||||
version: "3.7"
|
||||
|
||||
services:
|
||||
ch02-hello-kiamol:
|
||||
image: kiamol/ch02-hello-kiamol:latest
|
||||
build:
|
||||
context: ./hello-kiamol
|
||||
|
||||
ch02-whoami:
|
||||
image: kiamol/ch02-whoami:latest
|
||||
build:
|
||||
context: ./whoami
|
||||
@@ -0,0 +1,2 @@
|
||||
FROM nginx:1.21-alpine
|
||||
COPY html/ /usr/share/nginx/html/
|
||||
@@ -0,0 +1,2 @@
|
||||
# hello-diamol-web
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>
|
||||
Hello from Chapter 2!
|
||||
</h1>
|
||||
<h2>
|
||||
This is
|
||||
<a
|
||||
href="https://www.manning.com/books/learn-kubernetes-in-a-month-of-lunches"
|
||||
>Learn Kubernetes in a Month of Lunches</a
|
||||
>.
|
||||
</h2>
|
||||
<h3>By <a href="https://blog.sixeyed.com">Elton Stoneman</a>.</h3>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,10 @@
|
||||
$images=$(yq e '.services.[].image' docker-compose.yml)
|
||||
|
||||
foreach ($image in $images)
|
||||
{
|
||||
docker manifest create --amend $image `
|
||||
"$($image)-linux-arm64" `
|
||||
"$($image)-linux-amd64"
|
||||
|
||||
docker manifest push $image
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as builder
|
||||
|
||||
WORKDIR /src
|
||||
COPY src/whoami.csproj .
|
||||
RUN dotnet restore
|
||||
|
||||
COPY src /src
|
||||
RUN dotnet publish -c Release -o /out whoami.csproj
|
||||
|
||||
# app image
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["dotnet", "whoami.dll"]
|
||||
|
||||
COPY --from=builder /out/ .
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace whoami.Controllers
|
||||
{
|
||||
[Produces("application/json")]
|
||||
[Route("/")]
|
||||
public class WebController : Controller
|
||||
{
|
||||
private static string _Host = Dns.GetHostName();
|
||||
|
||||
[HttpGet]
|
||||
public ActionResult<string> Get()
|
||||
{
|
||||
var osDescription = RuntimeInformation.OSDescription;
|
||||
return $"I'm {_Host} running on {osDescription}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
|
||||
namespace whoami
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Run();
|
||||
}
|
||||
|
||||
public static IWebHost BuildWebHost(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace whoami
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseRouting();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
15
learn/learn-kubernetes-master/kiamol/ch02/lab/README.md
Normal file
15
learn/learn-kubernetes-master/kiamol/ch02/lab/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
kubectl apply -f solution/deployment.yaml
|
||||
|
||||
kubectl port-forward deploy/whoami 8080:80
|
||||
|
||||
curl http://localhost:8080
|
||||
|
||||
> "I'm whoami-687976f48b-tkxp9 running on Linux 4.19.76-linuxkit #1 SMP Thu Oct 17 19:31:58 UTC 2019"
|
||||
|
||||
kubectl get pods -o custom-columns=NAME:metadata.name
|
||||
|
||||
> whoami-68bf776fd-s6sr9
|
||||
|
||||
kubectl exec deploy/whoami -- sh -c 'hostname'
|
||||
|
||||
> whoami-687976f48b-tkxp9
|
||||
8
learn/learn-kubernetes-master/kiamol/ch02/lab/pod.yaml
Normal file
8
learn/learn-kubernetes-master/kiamol/ch02/lab/pod.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: whoami-1
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch02-whoami
|
||||
@@ -0,0 +1,21 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: whoami
|
||||
labels:
|
||||
app: whoami
|
||||
version: ch02
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: whoami
|
||||
version: ch02
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: whoami
|
||||
version: ch02
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch02-whoami
|
||||
8
learn/learn-kubernetes-master/kiamol/ch02/pod.yaml
Normal file
8
learn/learn-kubernetes-master/kiamol/ch02/pod.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: hello-kiamol-3
|
||||
spec:
|
||||
containers:
|
||||
- name: web
|
||||
image: kiamol/ch02-hello-kiamol
|
||||
Reference in New Issue
Block a user