惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
爱范儿
爱范儿
H
Help Net Security
V
Visual Studio Blog
J
Java Code Geeks
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
MyScale Blog
MyScale Blog
The Cloudflare Blog
Martin Fowler
Martin Fowler
D
Docker
腾讯CDC
F
Fortinet All Blogs
雷峰网
雷峰网
GbyAI
GbyAI
G
Google Developers Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
博客园 - 聂微东
博客园 - 叶小钗

博客园 - 隨風.NET

使用omdd下载ollama 钉钉AI机器人 安全高效跨平台的. NET 模板引擎 Fluid 使用文档 IIS反向代理 anki单词发音 excelPackage.Workbook.Worksheets[0]”引发了类型“System.Collections.Generic.KeyNotFoundException”的异常 vba替换\ red-gate激活要点 简化asp.netcore框架 python 调用dnspod接口修改A记录 windows安装nginx服务 jquery根据json自动生成表格 动态生成类并通过反射调用 excel 链接变图片 搭建prometheus监控系统 异步异常无法catch 虚拟机安装k8s 优化 vue 使用 webpack 打包,出现的缓存问题 及 项目部署问题 Internal.Cryptography.CryptoThrowHelper+WindowsCryptographicException 拒绝访问 / 出现了内部错误 c# – 当使用X509Certificate2加载p12/pfx文件时出现
.net core部署到k8s
隨風.NET · 2023-05-27 · via 博客园 - 隨風.NET

.net core部署到k8s

参考

准备dockerfile

dotnet new mvc --name myweb

dotnet publish -c release -o publish
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80

COPY . .     
ENTRYPOINT ["dotnet", "myweb.dll"]
docker build -t dockerdemo .

#docker测试
#docker run --name test -d -p 8080:80 dockerdemo
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web1
  labels:
    k8s-app: web1
spec:
  replicas: 2
  selector:
    matchLabels:
      k8s-app: web1
  template:
    metadata:
      labels:
        k8s-app: web1
    spec:
      containers:
      - name: web1
        image: dockerdemo
        imagePullPolicy: Never
        ports:
        - containerPort: 80
---
kind: Service
apiVersion: v1
metadata:
  labels:
    k8s-app: web1
  name: web1
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
  selector:
    k8s-app: web1

部署应用

kubectl create -f /k8s/web-pod.yml

#排查错误
kubectl describe pod web1-64b8479fc6-czpkq

#查看详细日志
kubectl describe -f  web-pod.yml

#删除
kubectl delete -f  web-pod.yml

kubectl apply -f /k8s/web-pod.yml
#查看映射的端口
kubectl get pod,svc -o wide

http://192.168.114.134:32285/