无法在Azure Kubernetes服务(AKS)中启动Web应用程序(ASP.NET应用),无法访问获取站点错误

jaxagkaj  于 2022-12-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(107)

我已经尝试将Web应用程序托管到AKS(Azure Kubernetes服务)。
1.创建一个支持Docker的示例应用程序(Windows容器)。
多工锉
来自mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019阿根廷源代码WORKDIR /inetpub/wwwroot副本${源代码:-obj/Docker/publish}
docker-compose详细信息如下:

version: '3.4'

services:
  akstestapp:
    image: ${DOCKER_REGISTRY-}akstestapp
    build:
      context: .\AKSTestApp
      dockerfile: Dockerfile

1.我已经将应用程序部署到桌面Docker容器。我可以部署和启动应用程序。

1.已将映像推送到Azure内容注册表。

1.已尝试将应用程序部署到Kubernetes。
virtualservice.networking.istio.io/aks-test-web-app 创建部署应用程序/aks-test-web-app创建服务/aks-test-web-app创建
c:/AKSConfigs〉kubectl.exe获取服务/aks-test-web-app -w
名称类型群集-IP外部-IP端口(S)年龄aks-测试-Web-应用程序负载均衡器10.206.4.251 20.253.252.26 80:30614/TCP 4 m14 s
。5。当我点击启动应用程序(外部IP)。我得到网站无法到达的错误。
1.部署yaml文件如下所示。

apiVersion: apps/v1
     kind: Deployment  
     metadata:  
       name: aks-test-web-app  
       labels:
         app: aks-test-web-app 
     spec:  
       replicas: 1  
       template:  
         metadata:  
           labels:  
             app: aks-test-web-app   
         spec:  
           nodeSelector:
             "beta.kubernetes.io/os": windows
           containers:
           - name: aks-test-web-app
             image: sample.azurecr.io/akstestwebapp:1
             ports:
               - containerPort: 80
       selector:
         matchLabels:
           app: aks-test-web-app
     ---  
     apiVersion: v1  
     kind: Service  
     metadata:  
       name: aks-test-web-app   
     spec:  
       type: LoadBalancer  
       ports:  
       - port: 80  
       selector:  
         app: aks-test-web-app

我在谷歌上搜索了一下,也添加了路由配置。

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: aks-test-web-app
spec:
  hosts:
  - "sample.com"
  - "sample.internal"
  gateways:
  - sample
  http:
    - match:
      - uri:
          prefix: /aks-test-webapp
      route:
      - destination:
          host: aks-test-web-app.sample.svc.cluster.local
          port:
            number: 8080

但是,我仍然面临着网站无法到达的错误。你能帮我找出我的错误吗?
POD正在运行

C:\Users\munirajn> kubectl.exe describe pod aks-test-web-app-84647d8585-ht9wv
Name:             aks-test-web-app-84647d8585-ht9wv
Namespace:        agys-pay
Priority:         0
Service Account:  default
Node:             akspaypgw000000/10.240.132.62
Start Time:       Thu, 15 Dec 2022 15:38:52 +0530
Labels:           app=aks-test-web-app
                  pod-template-hash=84647d8585
Annotations:      <none>
Status:           Running
IP:               10.240.132.63
IPs:
  IP:           10.240.132.63
Controlled By:  ReplicaSet/aks-test-web-app-84647d8585
Containers:
  aks-test-web-app:
    Container ID:   containerd://7cf9d9221ffc011860fde2bbe5f9e226b862a6fc432912c00f475d71d24f29d3
    Image:          agysacrdev.azurecr.io/akstestwebapp:1
    Image ID:       agysacrdev.azurecr.io/akstestwebapp@sha256:aa70ce0eb14095c198472db68dfd6372f7f6905a593c508da40fdf30b055f899
    Port:           80/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Thu, 15 Dec 2022 15:39:00 +0530
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-6bl9z (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  kube-api-access-6bl9z:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              beta.kubernetes.io/os=windows
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>
h5qlskok

h5qlskok1#

使用以下流程复制方案

**步骤1:**使用以下代码创建了一个群集

az aks create --resource-group v-swarna-*****--name democluster --node-count 1 --enable-addons monitoring --generate-ssh-keys

输出:

**步骤2:**使用此命令在创建群集时连接到群集

az aks get-credentials --resource-group v-swarna-*****--name demoCluster

对部署yaml文件进行了轻微修改

apiVersion: apps/v1
     kind: Deployment  
     metadata:  
       name: aks-test-web-app  
       labels:
         app: aks-test-web-app 
     spec:  
       replicas: 1  
       selector:
         matchLabels:
           app: aks-test-web-app
       template:  
         metadata:  
           labels:  
             app: aks-test-web-app   
         spec:  
           containers:
           - name: aks-test-web-app
             image: *****.azurecr.io/akstestwebapp:1
             ports:
               - containerPort: 80
     ---  
     apiVersion: v1  
     kind: Service  
     metadata:  
       name: aks-test-web-app   
     spec:  
       type: LoadBalancer  
       ports:  
       - port: 80  
       selector:  
         app: aks-test-web-app

在群集上应用更改

kubecetl apply -f deployment.yaml

使用以下命令验证pod或是否启动并运行

kubectl get pods
kubectl get service

验证:
在以下命令下运行:

kubectl get service

注:从上述输出中获取公共IP [外部IP],将通过公共IP访问站点。

相关问题