.netcore webapi 迁移到到 k8s
1. k create deployment aaa --image=aaa-image:1.2 -r=2, 然后把生成的 deploy, -oyaml, 删除不必要信息,保存为yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: app: my-app name: my-app namespace: app-ns spec: replicas: 2 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: volumes: - name: app-json configMap: name: app-json containers: - image: my-app:1.2.0.188 #- image: nexus-cn:443/mcr.microsoft.com/dotnet/aspnet:7.0 # command: [ "/bin/bash", "-c", "--" ] # args: [ "while true; do sleep 30; done;" ] imagePullPolicy: IfNotPresent name: fso-nms-vehicle terminationMessagePath: /dev/termination-log terminationMessagePolicy: File lifecycle: postStart: exec: command: - "/bin/sh" - "-c" - "cp /app2/app.json /app/appsettings.Int2.json" volumeMounts: - name: app-json mountPath: /app2 env: - name: ASPNETCORE_ENVIRONMENT value: "Int2"这里用到了 lifecycle, 但是这个不保证在应用执行之前执行。所以这样不合适
还要用 subpath.
标签:webapi,name,netcore,app,json,k8s,my,image From: https://www.cnblogs.com/qgbo/p/17989566