Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker kubernetes无法转发端口_Docker_Kubernetes_Google Kubernetes Engine_Kubernetes Pod - Fatal编程技术网

Docker kubernetes无法转发端口

Docker kubernetes无法转发端口,docker,kubernetes,google-kubernetes-engine,kubernetes-pod,Docker,Kubernetes,Google Kubernetes Engine,Kubernetes Pod,我是kubernetes的新手,我有deployment.yaml文件 apiVersion: apps/v1 kind: Deployment metadata: name: pdemo namespace: default spec: replicas: 1 selector: matchLabels: papi: web template: metadata: labels: papi: web spec:

我是kubernetes的新手,我有deployment.yaml文件

apiVersion: apps/v1
kind: Deployment
metadata:
  name: pdemo
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      papi: web
  template:
    metadata:
      labels:
        papi: web
    spec:
      containers:
      - name: pdemodemo-site
        image:pdemoapi:4.0
        ports:
        - containerPort: 443
---
apiVersion: v1
kind: Service
metadata:
  name: pdemo-entrypoint
  namespace: default
spec:
  type: LoadBalancer
  selector:
    bb: web
  ports:
  - port: 44328
    targetPort: 443
我应用了这个deployment.yaml文件并请求kubectl get服务

NAME                          TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)           AGE
kubernetes                    ClusterIP      10.96.0.1       <none>        443/TCP           19h
pdemo-entrypoint              LoadBalancer   10.111.16.228   localhost     44328:31656/TCP   60m
然后,当我试图从浏览器请求时,我得到

E1116 09:35:14.268697    2692 portforward.go:400] an error occurred forwarding 31656 -> 443: error forwarding port 443 to pod 54c1096fd343af2d0bc356c3ee52a54ac0db586e0f978fd3a0062278fe7aeb98, uid : exit status 1: 2019/11/16 14:35:14 socat[33825] E connect(21, AF=2 127.0.0.1:443, 16): Connection refused
这是我的docker图像文件

FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.8 AS base
WORKDIR /app
EXPOSE 443
COPY ./xyz/publish .
ENV ASPNETCORE_URLS=https://+:443;http://+80
ENTRYPOINT ["dotnet","xyz.dll"]


仅供参考:我使用的是docker desktop

如果您在浏览器中键入
localhost:31656
,这并不意味着路由到https的流量在默认浏览器中将其转换为
http://localhost:31656
,换句话说,您将未加密的流量路由到加密的端点

通过键入,尝试指定您想要的
https://


您是否可以检查是否尝试作为
https
资源(而不是
http
)请求它<代码>旋度-低https://localhost:31656您使用的是spec.ports“44328”吗?我认为您输入了错误,如果不是,您应该在构建中公开端口,而不仅仅是443。
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-alpine3.8 AS base
WORKDIR /app
EXPOSE 443
COPY ./xyz/publish .
ENV ASPNETCORE_URLS=https://+:443;http://+80
ENTRYPOINT ["dotnet","xyz.dll"]

curl -LO https://localhost:31656