简体   繁体   English

Dockerize vue js前端和spring boot后端并部署在kubernetes集群上

[英]Dockerize vue js front end and spring boot backend and deploy on kubernetes cluster

I have developed spring boot backend and vue js front end I could successfully deploy the spring boot app and create cluster ip service for spring boot app but I have never work with NPM project on docker and kubernetes .我开发了 spring boot 后端和vue js前端我可以成功部署 spring boot 应用程序并为 spring boot 应用程序创建集群ip服务,但我从未在kuberneteskubernetes上使用 NPM 项目。 I also have problem in Axios when I locally testing backend and frontend I give (localhost:backendport/endpoint) for axios and how can I adapt it to kubernetes .我也有问题, Axios ,当我在本地测试后端和前端,我给(localhost:backendport/endpoint)axios ,我怎么能适应kubernetes should I give cluster ip service name instead of localhost:port/endpoint -> clusteripservice/endpoint if so how can I externalize the configurations and how can I deploy both app.我应该给集群ip服务名称而不是localhost:port/endpoint -> clusteripservice/endpoint如果是这样,我如何将配置外部化以及如何部署这两个应用程序。

here is Axios call这是Axios电话

import axios from 'axios'


const API_URL = 'http://localhost:8084'
//const API_URL = '/'


class UserDataService {


    retrieveAllUsers() {

        return axios.get(`${API_URL}/user/getall`);
    }


}

export default new UserDataService()  

Idea is to use nginx as your app container and proxy pass to proxy to back-end.想法是使用 nginx 作为您的应用程序容器和代理传递到代理到后端。 So you need to define location for your api, ie /api and proxy that.所以你需要为你的 api 定义位置,即 /api 和代理。

Then if you are using axios, you would call all back-end endpoints on relative path, ie然后如果你使用 axios,你会在相对路径上调用所有后端端点,即

axios.get('/api/v1/myApiPath')

So you do not need to worry about hostname in calls to back-end.因此,您无需担心后端调用中的主机名。

Also, for development you similarly use vue.js development settings to also proxy back-end via npm.此外,对于开发,您同样使用 vue.js 开发设置也通过 npm 代理后端。

See my toy project here for details how it's done: Deployment piece - https://github.com/taleodor/mafia-deployment UI piece - https://github.com/taleodor/mafia-vue在这里查看我的玩具项目的详细信息:部署部分 - https://github.com/taleodor/mafia-deployment UI 部分 - https://github.com/taleodor/mafia-vue

Specifically nginx settings with proxy configuration - https://github.com/taleodor/mafia-vue/blob/master/nginx/default.conf (note that it's using websockets which you may remove if you're not using them).特别是带有代理配置的 nginx 设置 - https://github.com/taleodor/mafia-vue/blob/master/nginx/default.conf (请注意,它使用的是 websockets,如果您不使用它们,您可以将其删除)。 Specifically vue development server configuration -https://github.com/taleodor/mafia-vue/blob/master/vue.config.js .特别是 vue 开发服务器配置 -https://github.com/taleodor/mafia-vue/blob/master/vue.config.js

Write up on CI / CD workings (unrelated to your question but maybe useful) - https://itnext.io/building-kubernetes-cicd-pipeline-with-github-actions-argocd-and-reliza-hub-e7120b9be870写上 CI / CD 工作(与您的问题无关,但可能有用)- https://itnext.io/building-kubernetes-cicd-pipeline-with-github-actions-argocd-and-reliza-hub-e7120b9be870

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Spring Boot后端部署Angular 7 Front - How to deploy Angular 7 front with Spring Boot backend Node.js / AngularJS前端调用Spring Boot API后端 - Node.js/AngularJS front end calling Spring Boot API backend 使用Kubernetes部署Spring Boot - Deploy the Spring boot with Kubernetes 如何将标题和图像文件从前端 (React.js) 传递到后端 API (Spring Boot)? - How can I pass both the title and an image file from my front end (React.js) to my backend API (Spring Boot)? 将前端与后端分开。 Spring-boot 和 Angular2 - Separating the front end from the backend. Spring-boot and Angular2 如何使用React前端和Spring Boot安全后端进行客户端身份验证? - How do I do client side authentication check with React front end and Spring Boot security backend? 使用Axios将Vue前端的pdf文件上传/下载到Spring Backend - Upload/Download pdf file from Vue front-end to Spring Backend using Axios 如何从 IntelliJ 运行/部署 Spring 引导微服务到本地 Kubernetes 集群? - How to run/deploy Spring Boot Microservice from IntelliJ into local Kubernetes cluster? 您可以将 jsp 用于您的前端,而您的后端路由在 Spring 引导中是安静的吗? - Can you use jsp for your front end while your backend routes are restful in Spring Boot? 如何使用Cloud Foundry通过Vue前端和H2数据库为Spring Boot Web应用提供服务? - How to use Cloud Foundry to serve Spring Boot web app with Vue front end and H2 database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM