Fix Istio-proxy cannot collect HTTP-level information (#1209)

This commit is contained in:
Ta-Ching Chen
2019-07-02 00:08:29 +08:00
committed by GitHub
parent 36e544b537
commit 2ba66afb9f
3 changed files with 27 additions and 17 deletions
+8 -6
View File
@@ -217,6 +217,13 @@ func (deploy *NewDeploy) getDeploymentSpec(fn *fv1.Function, env *fv1.Environmen
},
},
},
// https://istio.io/docs/setup/kubernetes/additional-setup/requirements/
Ports: []apiv1.ContainerPort{
{
Name: "http-env",
ContainerPort: int32(8888),
},
},
Resources: resources,
}, env.Spec.Runtime.Container),
},
@@ -362,15 +369,10 @@ func (deploy *NewDeploy) createOrGetSvc(deployLabels map[string]string, svcName
Spec: apiv1.ServiceSpec{
Ports: []apiv1.ServicePort{
{
Name: "runtime-env-port",
Name: "http-env",
Port: int32(80),
TargetPort: intstr.FromInt(8888),
},
{
Name: "fetcher-port",
Port: int32(8000),
TargetPort: intstr.FromInt(8000),
},
},
Selector: deployLabels,
Type: apiv1.ServiceTypeClusterIP,
+3 -8
View File
@@ -106,20 +106,15 @@ func (gpm *GenericPoolManager) makeFuncController(fissionClient *crd.FissionClie
Type: apiv1.ServiceTypeClusterIP,
Ports: []apiv1.ServicePort{
// Service port name should begin with a recognized prefix, or the traffic will be
// treated as TCP traffic. (https://istio.io/docs/setup/kubernetes/sidecar-injection.html)
// Originally the ports' name are similar to "http-fetch" and "http-specialize".
// But for istio 0.5.1, istio-proxy return unexpected 431 error with such naming.
// https://github.com/istio/istio/issues/928
// Workaround: remove prefix
// TODO: prepend prefix once the bug fixed
// treated as TCP traffic. (https://istio.io/docs/setup/kubernetes/additional-setup/requirements/)
{
Name: "fetch",
Name: "http-fetcher",
Protocol: apiv1.ProtocolTCP,
Port: 8000,
TargetPort: intstr.FromInt(8000),
},
{
Name: "specialize",
Name: "http-env",
Protocol: apiv1.ProtocolTCP,
Port: 8888,
TargetPort: intstr.FromInt(8888),
+16 -3
View File
@@ -276,8 +276,8 @@ func IsIPv6(podIP string) bool {
return ip != nil && strings.Contains(podIP, ":")
}
func (gp *GenericPool) getSpecializeUrl(podIP string) string {
testUrl := os.Getenv("TEST_SPECIALIZE_URL")
func (gp *GenericPool) getFetcherUrl(podIP string) string {
testUrl := os.Getenv("TEST_FETCHER_URL")
if len(testUrl) != 0 {
// it takes a second or so for the test service to
// become routable once a pod is relabeled. This is
@@ -312,7 +312,7 @@ func (gp *GenericPool) specializePod(ctx context.Context, pod *apiv1.Pod, metada
}
// tell fetcher to get the function.
fetcherUrl := gp.getSpecializeUrl(podIP)
fetcherUrl := gp.getFetcherUrl(podIP)
gp.logger.Info("calling fetcher to copy function", zap.String("function", metadata.Name), zap.String("url", fetcherUrl))
fn, err := gp.fissionClient.
@@ -326,6 +326,8 @@ func (gp *GenericPool) specializePod(ctx context.Context, pod *apiv1.Pod, metada
gp.logger.Info("specializing pod", zap.String("function", metadata.Name))
// Fetcher will download user function to share volume of pod, and
// invoke environment specialize api for pod specialization.
err = fetcherClient.MakeClient(gp.logger, fetcherUrl).Specialize(ctx, &specializeReq)
if err != nil {
return err
@@ -396,6 +398,17 @@ func (gp *GenericPool) createPool() error {
},
},
},
// https://istio.io/docs/setup/kubernetes/additional-setup/requirements/
Ports: []apiv1.ContainerPort{
{
Name: "http-fetcher",
ContainerPort: int32(8000),
},
{
Name: "http-env",
ContainerPort: int32(8888),
},
},
}, gp.env.Spec.Runtime.Container),
},
ServiceAccountName: "fission-fetcher",