部署在AKS容器中的Probot GitHub应用无法接收Webhook求助
问题:Probot应用部署到AKS后Webhook返回404错误
我使用Probot开发了一个GitHub应用,通过smee.io在本地测试成功。随后将其打包为Docker镜像推送到ACR(Azure容器注册表),并部署到Azure Kubernetes Service(AKS)集群中,同时配置了Ingress路由Webhook,但始终出现404错误。
我的Dockerfile
参考示例构建的Dockerfile如下:
FROM my-image-registry/node:18-alpine3.16 as build # set working directory WORKDIR /app/probot/ ENV PATH /app/node_modules/.bin:$PATH # install and cache app dependencies COPY ./.npmrc ./ COPY ./package.json ./ # COPY ./tsconfig.json ./ RUN npm cache clean --force && npm install --force --loglevel verbose FROM my-image-registry/node:18-alpine3.16 as app WORKDIR /app/probot/ COPY --from=build /app/probot/node_modules ./node_modules COPY . ./ RUN npm run build EXPOSE 3005 COPY .env ./ #CMD npm run start CMD [ "npm", "start" ]
Kubernetes部署配置
通过kubectl部署到Kubernetes后Pod已成功运行,配置如下:
--- kind: Deployment apiVersion: apps/v1 metadata: labels: app: probot-service name: my-app-pod namespace: my-namespace spec: replicas: 1 selector: matchLabels: app: probot-service template: metadata: labels: app: probot-service spec: containers: - name: probot-service image: myacrurl/my-app-docker-image:d1.0 imagePullPolicy: Always ports: - containerPort: 3005 nodeSelector: agentpool: apppool --- apiVersion: v1 kind: Service metadata: labels: app: probot-service name: probot-service namespace: my-namespace spec: ports: - name: http port: 80 targetPort: 3005 - name: https protocol: TCP port: 443 targetPort: 3005 selector: app: probot-service type: ClusterIP
Pod日志信息
执行kubectl logs <podname> -n <namespace>查看日志,显示:
INFO (server): Running Probot v13.0.2 (Node.js: v18.8.0) INFO (server): Listening on http://localhost:3005
Ingress路由配置
配置的Ingress用于将Webhook路由到容器,内容如下:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: probot-ingress annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/rewrite-target: /$2 nginx.ingress.kubernetes.io/use-regex: 'true' spec: rules: - host: probot.mydomain.com http: paths: - pathType: Prefix path: /probot(/|$)(.*) backend: service: name: probot-service port: number: 80
我尝试过硬编码应用ID、Webhook密钥、安装ID等必要参数,也尝试过通过环境变量配置,以及在构建镜像时复制.env文件,但都无法解决问题。请问我哪里操作有误?Probot应用是否可以部署在AKS上?
内容的提问来源于stack exchange,提问作者Mani Shankar
相关产品推荐
相关产品推荐

