Skip to content

Configurable Service Port Names #5595

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

Merged
merged 1 commit into from
Jun 8, 2020
Merged

Configurable Service Port Names #5595

merged 1 commit into from
Jun 8, 2020

Conversation

afflom
Copy link
Contributor

@afflom afflom commented Jun 4, 2020

Description of your changes:
Trying to integrate rook-ceph with istio, but getting service port name errors as referenced here: https://kiali.io/documentation/validations/#_kia0601_port_name_must_follow_protocol_suffix_form

Understanding that istio isn't the only game in town, I think that it would be best to make the port name configurable at cluster creation.

Not sure what all needs to be changed in the source, but here are my starting edits. Assistance would be appreciated.

Which issue is resolved by this Pull Request:
Resolves #5587

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Skip Tests for Docs: Add the flag for skipping the build if this is only a documentation change. See here for the flag.
  • Skip Unrelated Tests: Add a flag to run tests for a specific storage provider. See test options.
  • Reviewed the developer guide on Submitting a Pull Request
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.
  • Pending release notes updated with breaking and/or notable changes, if necessary.
  • Upgrade from previous release is tested and upgrade user guide is updated, if necessary.
  • Code generation (make codegen) has been run to update object specifications, if necessary.

[test ceph]

Sorry, something went wrong.

Copy link
Member

@leseb leseb left a comment

Choose a reason for hiding this comment

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

As much as I'd like to support the new Istio version, adding new CRs setting to allow that and maintain backward compatibility seems overkill as it complexities the CR.

Is there a way we can detect Istio internally and change the service name accordingly maybe?

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

@leseb

Thank you for your review. I will make the specified changes to the variables.

Also, this is how I would get the istio version with kubectl.
kubectl get deployment istiod -o yaml -n istio-system | grep image:

But I am unclear on where this should be executed by the ceph operator. Can you please point me in the right direction?

Seems like an easy fix to conditionally set the variable if istio is detected. Is this what you had in mind?

@travisn
Copy link
Member

travisn commented Jun 5, 2020

As much as I'd like to support the new Istio version, adding new CRs setting to allow that and maintain backward compatibility seems overkill as it complexities the CR.

Is there a way we can detect Istio internally and change the service name accordingly maybe?

I would even go a step further and say there is no need for these names in the CR or to change them if istio is installed. It should be fine just to follow the istio convention. Nothing should really rely on these names.

Although it does seem like an odd requirement that the name has to be in a certain format since there is also a protocol field that serves the purpose of defining the protocol.

Besides adding the http- prefix to the one service, do we even need to change the msgr port names? If istio defaults to tcp it should be fine, right?

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

I don't really understand why istio/kiali rely on the port name prefix either, but they sure do complain/not work when they are not set "correctly". Can I trash all of this variable nonsense and just prefix each of these with their protocols and be done with it? Follow on question, if yes, is should they be http or tcp?

@travisn
Copy link
Member

travisn commented Jun 5, 2020

I don't really understand why istio/kiali rely on the port name prefix either, but they sure do complain/not work when they are not set "correctly". Can I trash all of this variable nonsense and just prefix each of these with their protocols and be done with it?

Sounds good to revert the variable changes.

Follow on question, if yes, is should they be http or tcp?

I understood from the istio doc that tcp will be the default protocol if they don't understand it. So the mon ports don't need to change and we just need the http port on the other one, right?

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

@travisn
https://github.com/kiali/kiali/blob/a5a1dcd7948796725eea5314b57af61ed002ab43/kubernetes/istio_details_service_test.go#L45 through L87 show their port name validations. From what I see, the name must either be the protocol or be prefixed by the protocol. "msgr1" would be invalid by itself, but tcp-msgr1 would be fine, unless it is a udp protocol, and udp-msgr1 would also work... From my understanding.

@travisn
Copy link
Member

travisn commented Jun 5, 2020

In this doc, I was interpreting that the tcp- prefix was optional. Are you seeing failures without the tcp prefix?

If the naming does not match this form (or is undefined), Istio treats all the traffic TCP instead of the defined protocol in the definition. 

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

Yes, without a prefix, kiali displays the service as unhealthy and communication between services becomes disrupted.

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

sounds like my next stop is going to be with the istio docs....

@travisn
Copy link
Member

travisn commented Jun 5, 2020

Yes, without a prefix, kiali displays the service as unhealthy and communication between services becomes disrupted.

Ok sounds good to add the tcp prefix in that case

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

image
This screenshot provides a little more info with what we are seeing.

@travisn
Copy link
Member

travisn commented Jun 5, 2020

LGTM, just please squash the commits before we merge.

@afflom
Copy link
Contributor Author

afflom commented Jun 5, 2020

I squashed but it's still showing 3 commits, did I do something wrong?

@afflom afflom changed the base branch from master to mergify/bp/release-1.3/pr-5603 June 7, 2020 00:57
@afflom afflom changed the base branch from mergify/bp/release-1.3/pr-5603 to master June 7, 2020 00:57
@mergify
Copy link

mergify bot commented Jun 7, 2020

This pull request has merge conflicts that must be resolved before it can be merged. @afflom please rebase it. https://rook.io/docs/rook/master/development-flow.html#updating-your-fork

When integrating rook with istio, service port names need to be prefixed by their protocol.
Trying to fix this by removing static port names in favor of configurable names.

Closes: #5587

add protocol prefix to service port names, hardcoded as discussed. renamed container ports

Signed-off-by: Alex Flom <alexander.flom@gmail.com>
Copy link
Member

@travisn travisn left a comment

Choose a reason for hiding this comment

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

The squashed commit and message look good!

@afflom
Copy link
Contributor Author

afflom commented Jun 7, 2020

Thank you! Do I owe anymore work on this?

Copy link
Member

@leseb leseb left a comment

Choose a reason for hiding this comment

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

Wait I think we forgot the CephObjectStore service too. Please update it

@afflom
Copy link
Contributor Author

afflom commented Jun 8, 2020

@leseb Great catch!

Looking at https://github.com/afflom/rook/blob/9a4d535f09c08a39470bdcc3b3bb37ee2e053d65/pkg/operator/ceph/object/spec.go#L213 The port names set in generateService are compatible with istio naming conventions (as per https://github.com/kiali/kiali/blob/a5a1dcd7948796725eea5314b57af61ed002ab43/kubernetes/istio_details_service_test.go#L45).

Do I need to change the port name anywhere else?

func (c *clusterConfig) generateService(cephObjectStore *cephv1.CephObjectStore) *v1.Service {
	labels := getLabels(cephObjectStore.Name, cephObjectStore.Namespace)
	svc := &v1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      instanceName(cephObjectStore.Name),
			Namespace: cephObjectStore.Namespace,
			Labels:    labels,
		},
		Spec: v1.ServiceSpec{
			Selector: labels,
		},
	}

	if c.clusterSpec.Network.IsHost() {
		svc.Spec.ClusterIP = v1.ClusterIPNone
	}

	destPort := c.generateLiveProbePort()
	addPort(svc, "http", cephObjectStore.Spec.Gateway.Port, destPort.IntVal)
	addPort(svc, "https", cephObjectStore.Spec.Gateway.SecurePort, cephObjectStore.Spec.Gateway.SecurePort)

	return svc
}

...<truncated>...

func addPort(service *v1.Service, name string, port, destPort int32) {
	if port == 0 || destPort == 0 {
		return
	}
	service.Spec.Ports = append(service.Spec.Ports, v1.ServicePort{
		Name:       name,
		Port:       port,
		TargetPort: intstr.FromInt(int(destPort)),
		Protocol:   v1.ProtocolTCP,
	})
}

@leseb
Copy link
Member

leseb commented Jun 8, 2020

@leseb Great catch!

Looking at https://github.com/afflom/rook/blob/9a4d535f09c08a39470bdcc3b3bb37ee2e053d65/pkg/operator/ceph/object/spec.go#L213 The port names set in generateService are compatible with istio naming conventions (as per https://github.com/kiali/kiali/blob/a5a1dcd7948796725eea5314b57af61ed002ab43/kubernetes/istio_details_service_test.go#L45).

Do I need to change the port name anywhere else?

func (c *clusterConfig) generateService(cephObjectStore *cephv1.CephObjectStore) *v1.Service {
	labels := getLabels(cephObjectStore.Name, cephObjectStore.Namespace)
	svc := &v1.Service{
		ObjectMeta: metav1.ObjectMeta{
			Name:      instanceName(cephObjectStore.Name),
			Namespace: cephObjectStore.Namespace,
			Labels:    labels,
		},
		Spec: v1.ServiceSpec{
			Selector: labels,
		},
	}

	if c.clusterSpec.Network.IsHost() {
		svc.Spec.ClusterIP = v1.ClusterIPNone
	}

	destPort := c.generateLiveProbePort()
	addPort(svc, "http", cephObjectStore.Spec.Gateway.Port, destPort.IntVal)
	addPort(svc, "https", cephObjectStore.Spec.Gateway.SecurePort, cephObjectStore.Spec.Gateway.SecurePort)

	return svc
}

...<truncated>...

func addPort(service *v1.Service, name string, port, destPort int32) {
	if port == 0 || destPort == 0 {
		return
	}
	service.Spec.Ports = append(service.Spec.Ports, v1.ServicePort{
		Name:       name,
		Port:       port,
		TargetPort: intstr.FromInt(int(destPort)),
		Protocol:   v1.ProtocolTCP,
	})
}

Thanks for checking, no it's fine keep them as is.

@leseb leseb merged commit 8878365 into rook:master Jun 8, 2020
@afflom
Copy link
Contributor Author

afflom commented Jun 8, 2020

Thank you so much!

mergify bot added a commit that referenced this pull request Jun 8, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Configurable Service Port Names (bp #5595)
@afflom afflom deleted the port-naming-work branch June 8, 2020 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ceph main ceph tag
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rook Services Integration with Istio
3 participants