Support ingress path for kubernetes (#1245)
* Support ingress path for kubernetes
This commit is contained in:
@@ -462,11 +462,13 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
|
||||
}
|
||||
|
||||
for i, host := range hosts {
|
||||
host, p := transformer.ParseIngressPath(host)
|
||||
ingress.Spec.Rules[i] = extensions.IngressRule{
|
||||
IngressRuleValue: extensions.IngressRuleValue{
|
||||
HTTP: &extensions.HTTPIngressRuleValue{
|
||||
Paths: []extensions.HTTPIngressPath{
|
||||
{
|
||||
Path: p,
|
||||
Backend: extensions.IngressBackend{
|
||||
ServiceName: name,
|
||||
ServicePort: intstr.IntOrString{
|
||||
|
||||
@@ -103,6 +103,16 @@ func ParseVolume(volume string) (name, host, container, mode string, err error)
|
||||
return
|
||||
}
|
||||
|
||||
// ParseIngressPath parse path for ingress.
|
||||
// eg. example.com/org -> example.com org
|
||||
func ParseIngressPath(url string) (string, string) {
|
||||
if strings.Contains(url, "/") {
|
||||
splits := strings.Split(url, "/")
|
||||
return splits[0], "/" + splits[1]
|
||||
}
|
||||
return url, ""
|
||||
}
|
||||
|
||||
func isPath(substring string) bool {
|
||||
return strings.Contains(substring, "/") || substring == "."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user