Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control-plane: automatically create Dataplane resource on k8s and use to generate inbound Envoy listeners #104

Merged
merged 5 commits into from
Aug 15, 2019

Conversation

yskopets
Copy link
Contributor

@yskopets yskopets commented Aug 13, 2019

changes:

  • automatically generate Dataplane resource for every Pod with Konvoy sidecar injected
  • refactor discovery api
  • generate inbound listeners according to Dataplane resource

@yskopets yskopets added this to the 0.1 milestone Aug 13, 2019
@yskopets yskopets force-pushed the feature/generate-dataplane-out-of-pod branch 6 times, most recently from 9d64503 to 6176f99 Compare August 14, 2019 15:53
@yskopets yskopets changed the title control-plane: convert Pod into Dataplane control-plane: automatically create Dataplane resource on k8s and use to generate inbound Envoy listeners Aug 14, 2019
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall - good job on this PR! 🥇

},
Entry("dataplane IP address is missing", testCase{
input: ":80:8080",
expectedErr: `invalid format: expected ^(?P<workload_ip>(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)):(?P<service_port>[0-9]{1,5}):(?P<workload_port>[0-9]{1,5})$, got ":80:8080"`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in whole file: can we extract this regex to const or reuse one from production code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed (by relaxing error matcher)

Spec: kube_core.ServiceSpec{
Ports: []kube_core.ServicePort{
{
Port: 80,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the protocol implicit here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Spec: kube_core.ServiceSpec{
Ports: []kube_core.ServicePort{
{
Protocol: "UDP",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice to give comments why those are mismatching so:

Protocol: "UDP", // only TCP is supported
Protocol: "SCTP", // only TCP is supported
IntVal: 7071, // no container with such port
StrVal: "diagnostics", // no port with that name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

)
})

var _ = Describe("DataplaneFor(..)", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those cases for this are already fully covered in Describe("PodToDataplane(..)") do we need second tests for this?

When we will have to change of the DataplaneFor we would have to change tests for both cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed separate test for DataplaneFor(..)


func MatchServiceThatSelectsPod(pod *kube_core.Pod) ServicePredicate {
return func(svc *kube_core.Service) bool {
selector := kube_labels.SelectorFromSet(kube_labels.Set(svc.Spec.Selector))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that kube_labels.Set() is redundant conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed explicit type conversion

Name: pod.Name,
},
}
op, err := kube_controllerutil.CreateOrUpdate(ctx, r.Client, dataplane, func() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to go to editor to see what op is. Can we give it a bit more descriptive name like operationResult or operationRes. I would be also confused to see op in logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

)

var _ DiscoverySource = &DiscoverySink{}
var _ DiscoveryConsumer = &DiscoverySink{}

// DiscoverySink is both a source and a consumer of discovery information.
type DiscoverySink struct {
Consumer DiscoveryConsumer
ServiceConsumer ServiceDiscoveryConsumer
WorkloadConsumer WorkloadDiscoveryConsumer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about removing ServiceConsumer and WorkloadConsumer?
There is no usage of this - no source of those events and no consumer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@yskopets yskopets force-pushed the feature/generate-dataplane-out-of-pod branch from 8f38d45 to 6b71548 Compare August 15, 2019 11:37
@yskopets yskopets merged commit 5841635 into master Aug 15, 2019
@yskopets yskopets deleted the feature/generate-dataplane-out-of-pod branch August 22, 2019 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants