services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
b => b.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
var host = Configuration.GetSection("Hosts")?.GetSection("Externals")?.GetSection("CurrentUri")?.Value;
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryApiResources(InMemoryConfiguration.ApiResources())
.AddInMemoryClients(InMemoryConfiguration.Clients())
.AddTestUsers(InMemoryConfiguration.Users().ToList())
.AddJwtBearerClientAuthentication();
您可以查看整个应用程序代码here。
然后我使用yaml文件进行部署:
apiVersion: v1
kind: Service
metadata:
name: identity
labels:
app: identity
spec:
ports:
- port: 80
targetPort: 7066
protocol: TCP
name: http
selector:
app: identity
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: identity
spec:
replicas: 1
template:
metadata:
labels:
app: identity
version: v1
spec:
containers:
- name: identity
image: registry.hub.docker.com/przemekwojcik/identity:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 7066
resources:
requests:
memory: "400Mi"
cpu: "100m"
limits:
memory: "400Mi"
cpu: "100m"
pod成功部署并运行后,我正在使用kubectl进行端口转发:
kubectl port-forward identity-b59787975-7b6l7 7066:7066
当我尝试浏览它时,这就是我得到的:
服务器未对此请求返回完整的响应。服务器 返回0个字节。