Following this pulumi walkthrough, I need to expose 2 services: kuard
and rstudiogp
through an nginx ingress controller. The kuard app is just there to demonstrate that kubernetes is up , the rstudio app is something I'd like to add to the cluster.
I would like to access the kuard service at apps.example.com
, and the rstudio service at apps.example.com/rstudio
. However, I was only able to have both online at the same time by changing one of the hosts to for example apps.example.rstudio.com
, so I have 2 hosts rather than one.
Isn't it possible to use ingress paths to expose two services using the same ingress rule? How to use the same hostname to access both services with different paths, e.g. apps.example.com/kuard
and apps.example.com/rstudio
?
curl -Lv -H 'Host: apps.example.com' <PUBLIC-IP>
.
Current Kuard ingress:
// 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}
);
Current RStudio ingress (see the annotated lines that I tried without success):
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}
);
Found out that the problem was with my application expecting to be served from the root url.