按照這個 pulumi 演練,我需要公開 2 個服務:kuard并rstudiogp通過一個 nginx 入口控制器。kuard 應用程式只是用來證明 kubernetes 已啟動,而 rstudio 應用程式是我想添加到集群中的東西。
我想訪問 kuard 服務apps.example.com和 rstudio 服務apps.example.com/rstudio。但是,我只能通過將其中一臺主機更改為 example 才能同時在線apps.example.rstudio.com,所以我有 2 臺主機而不是 1 臺。
是否可以使用入口路徑來使用相同的入口規則公開兩個服務?如何使用相同的主機名來訪問具有不同路徑的兩個服務,例如apps.example.com/kuard和apps.example.com/rstudio?
curl -Lv -H 'Host: apps.example.com' <PUBLIC-IP>.
當前的 Kuard 入口:
// Create the kuard Ingress
const ingress = new k8s.extensions.v1beta1.Ingress(namekuard,
{
metadata: {
labels: labels,
namespace: namespaceName,
annotations: {"kubernetes.io/ingress.class": "nginx"},
},
spec: {
rules: [
{
host: "apps.example.com",
http: {
paths: [
{
path: "/",
backend: {
serviceName: serviceName,
servicePort: "http",
}
},
],
},
}
]
}
},
{provider: clusterProvider}
);
當前的 RStudio 入口(請參閱我嘗試但未成功的注釋行):
const ingress_rs = new k8s.extensions.v1beta1.Ingress(rsname,
{
metadata: {
labels: labels_rs,
namespace: namespaceName,
annotations: {"kubernetes.io/ingress.class": "nginx"},
},
spec: {
rules: [
{
host: "apps.example.rstudio.com",
http: {
paths: [
{
path: "/",
backend: {
serviceName: serviceName_rs,
servicePort: "http",
}
},
// {
// path: "/rstudio",
// pathType: "Prefix",
// backend: {
// serviceName: serviceName_rs,
// servicePort: "http",
// }
// },
],
},
}
]
}
},
{provider: clusterProvider}
);
uj5u.com熱心網友回復:
發現問題出在我的應用程式期望從根 url 提供服務。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/415692.html
標籤:
