[英]Unable to launch the web application (asp.net app) in the Azure Kubernetes service (AKS). Getting site is not reachable error
我已尝试将 Web 应用程序托管到 AKS(Azure Kubernetes 服务)。
创建一个支持 docker 的示例应用程序(windows 容器)。
泊坞文件
从 mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 ARG source WORKDIR /inetpub/wwwroot COPY ${source:-obj/Docker/publish}
docker-compose 详细信息如下:
version: '3.4'
services:
akstestapp:
image: ${DOCKER_REGISTRY-}akstestapp
build:
context: .\AKSTestApp
dockerfile: Dockerfile
尝试将应用程序部署到 Kubernetes。
virtualservice.networking.istio.io/aks-test-web-app 已创建 deployment.apps/aks-test-web-app 已创建 service/aks-test-web-app 已创建
c:/AKSConfigs>kubectl.exe 获取服务/aks-test-web-app -w
名称类型群集 IP 外部 IP 端口年龄 aks-test-web-app LoadBalancer 10.206.4.251 20.253.252.26 80:30614/TCP 4m14s
. 5. 当我点击启动应用程序(外部 IP)时。 我收到网站无法访问的错误。
部署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: sample.azurecr.io/akstestwebapp:1
Image ID: sample.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>
使用以下过程复制场景
第 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 访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.