使用 kubectl 运行为 AKS 创建服务的部署对象会引发服务器报告的 400 问题



在对象和关联的副本集对象中创建部署对象时。ReplicaSet 有两个 Pod,每个 Pod 都运行 akswebapp 应用程序。它引发以下异常。

错误:无法读取 URL"https://mystorage12111.file.core.windows.net/aksfiles/akswebapp-application.yaml",服务器报告 400 其中一个 HTTP 标头的值格式不正确。状态代码 = 400

雅姆尔文件:

apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-webapp
spec:
selector:
matchLabels:
run: load-balancer-example
replicas: 2
template:
metadata:
labels:
run: load-balancer-example
spec:
containers:
- name: docker-webapp
image: dockerwebapp
ports:
- containerPort: 8080
protocol: TCP

对于您的问题,问题是标签的名称和值在您的部署和服务中。您需要在部署和服务中使它们相同。所以 YAML 文件中的代码应该是这样的:

apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-webapp
spec:
selector:
matchLabels:
run: load-balancer-example
replicas: 2
template:
metadata:
labels:
run: load-balancer-example
spec:
containers:
- name: docker-webapp
image: dockerwebapp
ports:
- containerPort: 8080
protocol: TCP
---
kind: Service
apiVersion: v1 
metadata: 
name: dockerwebservice 
spec: 
selector: 
run: load-balancer-example
ports: 
- protocol: TCP 
port: 80 
targetPort: 80 
type: LoadBalancer

最新更新