Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
if --domain is specified, let's use it
Browse files Browse the repository at this point in the history
  • Loading branch information
ngtuna committed Jul 31, 2017
1 parent 4525e3d commit 46193ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions cmd/kubeless/ingressList_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -32,7 +31,7 @@ func TestIngressList(t *testing.T) {
Spec: xv1beta1.IngressSpec{
Rules: []xv1beta1.IngressRule{
{
Host: fmt.Sprintf("%s.%s", "foo", "example.com"),
Host: "foobar.192.168.99.100.nip.io",
IngressRuleValue: xv1beta1.IngressRuleValue{
HTTP: &xv1beta1.HTTPIngressRuleValue{
Paths: []xv1beta1.HTTPIngressPath{
Expand All @@ -59,7 +58,7 @@ func TestIngressList(t *testing.T) {
Spec: xv1beta1.IngressSpec{
Rules: []xv1beta1.IngressRule{
{
Host: fmt.Sprintf("%s.%s", "bar", "example.com"),
Host: "example.com",
IngressRuleValue: xv1beta1.IngressRuleValue{
HTTP: &xv1beta1.HTTPIngressRuleValue{
Paths: []xv1beta1.HTTPIngressPath{
Expand Down
12 changes: 6 additions & 6 deletions pkg/utils/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,10 @@ func addInitContainerAnnotation(dpm *v1beta1.Deployment) error {
}

// CreateIngress creates ingress rule for a specific function
func CreateIngress(client kubernetes.Interface, ingressName, function, domain, ns string) error {
func CreateIngress(client kubernetes.Interface, ingressName, funcName, domain, ns string) error {
if domain == "" {
var err error
domain, err = getLocalDomain()
domain, err = getLocalDomain(funcName)
if err != nil {
return err
}
Expand All @@ -837,14 +837,14 @@ func CreateIngress(client kubernetes.Interface, ingressName, function, domain, n
Spec: v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{
{
Host: fmt.Sprintf("%s.%s", ingressName, domain),
Host: domain,
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{
{
Path: "/",
Backend: v1beta1.IngressBackend{
ServiceName: function,
ServiceName: funcName,
ServicePort: intstr.FromInt(8080),
},
},
Expand All @@ -864,7 +864,7 @@ func CreateIngress(client kubernetes.Interface, ingressName, function, domain, n
}

// getLocalDomain returns hostname
func getLocalDomain() (string, error) {
func getLocalDomain(funcName string) (string, error) {
config, err := buildOutOfClusterConfig()
if err != nil {
return "", err
Expand All @@ -876,7 +876,7 @@ func getLocalDomain() (string, error) {

host, _, _ := net.SplitHostPort(url.Host)

return fmt.Sprintf("%s.nip.io", host), nil
return fmt.Sprintf("%s.%s.nip.io", funcName, host), nil
}

// DeleteIngress deletes an ingress rule
Expand Down

0 comments on commit 46193ff

Please sign in to comment.