angular - 如何编写正确的 yaml 以在 Azure devops 中部署 kubernetes 集群?
问题描述
我正在尝试使用 kubernetes 在 Azure 云中建立 Dockerized Angular 应用程序,但我不能这样做。一切看起来都很好,但是当我在浏览器上输入 web url 时看不到 angular 应用程序。我的 Dockerfile 或 yml 文件有什么问题?你能给我一些建议吗?我在 2 天内进行了很多搜索,但没有找到解决方案。
部署.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: {}
服务.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
解决方案
在您交换的服务定义中port
和targetPort
值。port
应该是 80 和targetPort
3080。
推荐阅读
- python - 在 ::before (xpath, css) 之后抓取文本
- doxygen - doxygen 生成的 make.bat 因错误而停止。如何防止此类停止?
- windows - 7zip最新版本实用吗?
- sql - Sql Query 在服务器中执行的时间太长,而不是在本地执行
- java - 在 PDFBox 中按顺序阅读段落
- r - 在 R 中使用 ggplot2 创建多条平滑/拟合线
- android - 使用地理显示多个标记:意图在指定位置和缩放级别显示地图
- c++ - 带有 std::__shared_ptr 的多定义链接器错误
语境
操作系统:
Ubuntu 18.04
建造:
CMake 3.10.2
编译器:
gcc-9 (Ubuntu 9.2.1-17ubunt
- javascript - Vue 多选插槽插入符号下拉选项显示和隐藏
- sql - 如何将表格从行展平到列