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

Change service port name to use prefix http to support Istio #560

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ For example:
```console
$ kubectl proxy -p 8080 &

$ curl -L --data '{"Another": "Echo"}' localhost:8080/api/v1/proxy/namespaces/default/services/get-python:function-port/ --header "Content-Type:application/json"
$ curl -L --data '{"Another": "Echo"}' localhost:8080/api/v1/proxy/namespaces/default/services/get-python:http-function-port/ --header "Content-Type:application/json"
{"Another": "Echo"}
```

Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeless/function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func getFunctionDescription(cli kubernetes.Interface, funcName, ns, handler, fil
svcSpec := v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
NodePort: 0,
Protocol: v1.ProtocolTCP,
},
Expand Down
7 changes: 4 additions & 3 deletions cmd/kubeless/function/function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"archive/zip"
"io"
"io/ioutil"
"k8s.io/api/core/v1"
"os"
"reflect"
"testing"

"k8s.io/api/core/v1"

kubelessApi "github.com/kubeless/kubeless/pkg/apis/kubeless/v1beta1"
"k8s.io/api/autoscaling/v2beta1"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -132,7 +133,7 @@ func TestGetFunctionDescription(t *testing.T) {
ServiceSpec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
Port: int32(80),
TargetPort: intstr.FromInt(80),
NodePort: 0,
Expand Down Expand Up @@ -226,7 +227,7 @@ func TestGetFunctionDescription(t *testing.T) {
ServiceSpec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
Port: int32(8080),
TargetPort: intstr.FromInt(8080),
NodePort: 0,
Expand Down
5 changes: 3 additions & 2 deletions pkg/utils/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ func serviceSpec(funcObj *kubelessApi.Function) v1.ServiceSpec {
return v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
// Note: Prefix: "http-" is added to adapt to Istio so that it can discover the function services
Name: "http-function-port",
Protocol: v1.ProtocolTCP,
Port: 8080,
TargetPort: intstr.FromInt(8080),
Expand Down Expand Up @@ -902,7 +903,7 @@ func CreateServiceMonitor(smclient monitoringv1alpha1.MonitoringV1alpha1Client,
},
Endpoints: []monitoringv1alpha1.Endpoint{
{
Port: "function-port",
Port: "http-function-port",
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/k8sutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestEnsureService(t *testing.T) {
ServiceSpec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
Port: 8080,
TargetPort: intstr.FromInt(8080),
NodePort: 0,
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestEnsureService(t *testing.T) {
Spec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
Port: 8080,
TargetPort: intstr.FromInt(8080),
NodePort: 0,
Expand Down Expand Up @@ -279,7 +279,7 @@ func TestEnsureDeployment(t *testing.T) {
ServiceSpec: v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
Port: f1Port,
TargetPort: intstr.FromInt(int(f1Port)),
NodePort: 0,
Expand Down Expand Up @@ -944,7 +944,7 @@ func TestServiceSpec(t *testing.T) {
eSvc := v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Name: "function-port",
Name: "http-function-port",
Protocol: v1.ProtocolTCP,
Port: 8080,
TargetPort: intstr.FromInt(8080),
Expand Down