-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow kubernetes discoverer to use gRPC destinations (#829)
* Allow kubernetes discoverer to use gRPC destinations Summary I updated the kubnetes discoverer to look for veneur global containers with a grpc port name. This will allow us to specify that we are using gRPC. Additionally, I removed the http:// prefix in the saved podIp because it hits a "too many colons in address" error with gRPC. This will still work with forwarding with http because in proxy.go, the doPost method will check and append it if its missing. This PR is related to issue #762 as it removes the http hard coding. Motivation In Kubernetes we want to proxy metrics to veneur global with gRPC. This edit in our fork fixed the issues we were hitting. Test plan Ran this in our veneur-proxy pods that utilize this Kubernetes discoverer code with gRPC to verify everything works. Rollout/monitoring/revert plan This change should be backwards compatible as the doPost function for http communication prepends the necessary prefix. This only affects gRPC destinations used by proxysrv which shouldn't have been available with kubernetes. * Update CHANGELOG for new release * Pulled the logic that generates pod IPs from pod info into it's own function to make it more testable and added some tests on generating these ips Co-authored-by: Chris Solidum <[email protected]> Co-authored-by: csolidum <[email protected]>
- Loading branch information
1 parent
ed29417
commit cf35312
Showing
3 changed files
with
147 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package veneur | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"k8s.io/api/core/v1" | ||
) | ||
|
||
func TestGetDestinationFromHttpPod(t *testing.T) { | ||
httpPod := v1.Pod{ | ||
Status: v1.PodStatus{ | ||
Phase: v1.PodRunning, | ||
PodIP: "127.0.0.1", | ||
}, | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
v1.Container{ | ||
Ports: []v1.ContainerPort{ | ||
v1.ContainerPort{ | ||
Name: "http", | ||
ContainerPort: 8080, | ||
Protocol: v1.ProtocolTCP, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
podID := getDestinationFromPod(0, httpPod) | ||
assert.Equal(t, "http://127.0.0.1:8080", podID) | ||
} | ||
|
||
func TestGetDestinationFromTcpPod(t *testing.T) { | ||
tcpPod := v1.Pod{ | ||
Status: v1.PodStatus{ | ||
Phase: v1.PodRunning, | ||
PodIP: "127.0.0.1", | ||
}, | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
v1.Container{ | ||
Ports: []v1.ContainerPort{ | ||
v1.ContainerPort{ | ||
Name: "tcp", | ||
ContainerPort: 8080, | ||
Protocol: v1.ProtocolTCP, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
podID := getDestinationFromPod(0, tcpPod) | ||
assert.Equal(t, "http://127.0.0.1:8080", podID) | ||
} | ||
|
||
func TestGetDestinationFromGrpcPod(t *testing.T) { | ||
grpcPod := v1.Pod{ | ||
Status: v1.PodStatus{ | ||
Phase: v1.PodRunning, | ||
PodIP: "127.0.0.1", | ||
}, | ||
Spec: v1.PodSpec{ | ||
Containers: []v1.Container{ | ||
v1.Container{ | ||
Ports: []v1.ContainerPort{ | ||
v1.ContainerPort{ | ||
Name: "grpc", | ||
ContainerPort: 8080, | ||
Protocol: v1.ProtocolTCP, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
podID := getDestinationFromPod(0, grpcPod) | ||
assert.Equal(t, "127.0.0.1:8080", podID) | ||
} |