Kubernetes上部署的IdentityServer4无响应

时间:2018-12-17 13:08:40

标签: kubernetes identityserver4 azure-aks

我使用IdentityServer4开发了一个简单的演示应用程序,可以作为微服务进行部署。它可以在Windows的Docker上正常运行。但是,我无法使其在AKS上运行,我也不知道为什么。这是我的入门班:

            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个字节。

0 个答案:

没有答案