gpt4 book ai didi

angular - 如何编写正确的 yaml 以在 Azure Devops 中部署 kubernetes 集群?

转载 作者:行者123 更新时间:2023-12-03 00:57:28 25 4
gpt4 key购买 nike

我正在尝试使用 kubernetes 在 azure 云中建立 Dockerized Angular 应用程序,但我做不到。一切看起来都很好,但当我进入时我看不到 Angular 应用程序浏览器上的 web url。我的 Dockerfile 或 yml 文件有什么问题?你能给我一些建议吗?我在两天内进行了大量搜索,但没有找到解决方案。

部署.yml:


apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: xxx-pod
name: xxx-deployment
spec:
replicas: 5
selector:
matchLabels:
app: xxx-pod
strategy: {}
template:
metadata:
labels:
app: xxx-pod
spec:
containers:
- image: xxx.azurecr.io/cm-webui:v1
name: webapp
imagePullPolicy: Always
resources: {}
ports:
- containerPort: 3080
status: {}

service.yml:


apiVersion: v1
kind: Service
metadata:
name: xxx-service
labels:
run: xxx-pod
spec:
selector:
app: xxx-pod
ports:
- port: 3080
targetPort: 80
type: LoadBalancer

Dockerfile:


FROM node:10 AS ui-build
WORKDIR /usr/src/app
COPY my-app/ ./my-app/
RUN cd my-app && npm install @angular/cli && npm install && npm run build

FROM node:10 AS server-build
WORKDIR /root/
COPY --from=ui-build /usr/src/app/my-app/dist ./my-app/dist
COPY package*.json ./
RUN npm install
COPY server.js .

EXPOSE 3080

CMD ["node", "server.js"]

我的日志:


8m13s Normal EnsuredLoadBalancer service/xxx-service Ensured load balancer
8m17s Warning FailedToUpdateEndpoint endpoints/xxx-service Failed to update endpoint default/xxx-service: Operation cannot be fulfilled on endpoints "xxx-service": the object has been modified; please apply your changes to the latest version and try again
8m17s Warning FailedToUpdateEndpointSlices service/xxx-service Error updating Endpoint Slices for Service default/xxx-service: failed to update xxx-service-p429q EndpointSlice for Service default/xxx-service: Operation cannot be fulfilled on endpointslices.discovery.k8s.io "xxx-service-p429q": the object has been modified; please apply your changes to the latest version and try again

最佳答案

在服务定义中,您交换了 porttargetPort 值。 port 应为 80,targetPort 为 3080。

关于angular - 如何编写正确的 yaml 以在 Azure Devops 中部署 kubernetes 集群?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65655300/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com