簡體   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