繁体   English   中英

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

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

我开发了 spring boot 后端和vue js前端我可以成功部署 spring boot 应用程序并为 spring boot 应用程序创建集群ip服务,但我从未在kuberneteskubernetes上使用 NPM 项目。 我也有问题, Axios ,当我在本地测试后端和前端,我给(localhost:backendport/endpoint)axios ,我怎么能适应kubernetes 我应该给集群ip服务名称而不是localhost:port/endpoint -> clusteripservice/endpoint如果是这样,我如何将配置外部化以及如何部署这两个应用程序。

这是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()  

想法是使用 nginx 作为您的应用程序容器和代理传递到代理到后端。 所以你需要为你的 api 定义位置,即 /api 和代理。

然后如果你使用 axios,你会在相对路径上调用所有后端端点,即

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

因此,您无需担心后端调用中的主机名。

此外,对于开发,您同样使用 vue.js 开发设置也通过 npm 代理后端。

在这里查看我的玩具项目的详细信息:部署部分 - https://github.com/taleodor/mafia-deployment UI 部分 - https://github.com/taleodor/mafia-vue

特别是带有代理配置的 nginx 设置 - https://github.com/taleodor/mafia-vue/blob/master/nginx/default.conf (请注意,它使用的是 websockets,如果您不使用它们,您可以将其删除)。 特别是 vue 开发服务器配置 -https://github.com/taleodor/mafia-vue/blob/master/vue.config.js

写上 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM