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

EdgeFS: Allow control over K8s service type via CRD #3516

Merged
merged 1 commit into from
Jul 26, 2019

Conversation

NullOranje
Copy link
Contributor

@NullOranje NullOranje commented Jul 24, 2019

Description of your changes:
Allow users to define Kubernetes users to define ServiceType and NodePort via the CRD spec. This changes the current behavior, which deploys all services into the K8s cluster as NodePort services on auto-selected ports. The intent is to provide users more control over services and make accessing services via other methods simpler (e.g., LaodBalancer, ingress controller). It also reduces the number of ports exposed outside of the Kubernetes cluster.

Which issue is resolved by this Pull Request:
N/A

Checklist:

  • 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.
  • Comments have been added or updated based on the standards set in CONTRIBUTING.md
  • Add the flag for skipping the CI if this PR does not require a build. See here for more details.

[test edgefs]

@@ -139,7 +139,7 @@ func (c *ISGWController) makeISGWService(name, svcname, namespace string, isgwSp
},
Spec: v1.ServiceSpec{
Selector: labels,
Type: v1.ServiceTypeNodePort,
Type: v1.ServiceType(isgwSpec.ServiceType),
Copy link
Member

Choose a reason for hiding this comment

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

I think better to add method to resolve string of isgwSpec.ServiceType to correct v1.ServiceType, due to typo in service.ServiceType

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is already code to handle the error in the event the operator tries to create a bad service, although it is a bit lacking (for example, if a service fails to start, the pod will be left dangling).

2019-07-25 13:21:02.926979 E | edgefs-op-s3: failed to create s3 s3-cola. failed to create s3 service. Service "rook-edgefs-s3-s3-cola" is invalid: spec.type: Unsupported value: "NidePort": supported values: "ClusterIP", "ExternalName", "LoadBalancer", "NodePort"

I had assumed that this would be sufficient, since it is the exact error a user would receive if they tried to create an off-spec Service in K8s. I can certainly add checks to validateService() if you think that would be a better way of handling the input.

Copy link
Member

Choose a reason for hiding this comment

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

I think, better solution is to create method like this:

func ParseServiceType(serviceType string) ServiceType {

	if strings.EqualFold(serviceType, string(ServiceTypeNodePort)) {
		return ServiceTypeNodePort
	} 
	
	return ServiceTypeClusterIP
}

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

And add current service type to log plz

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that looks very similar to something I was doing before. I'll bring it back.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added ServiceType check to the validateService() function

httpPort := v1.ServicePort{Name: "port", Port: int32(s3Spec.Port), Protocol: v1.ProtocolTCP}
httpsPort := v1.ServicePort{Name: "secure-port", Port: int32(s3Spec.SecurePort), Protocol: v1.ProtocolTCP}

if s3Spec.ExternalPort != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

In case of ClusterIP service type, should be possible to add NodePorts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, by specification NodePort cannot be used for a ServiceType of 'ClusterIP'. The K8s apiserver will reject this if it is invalid

2019-07-25 13:33:28.254349 E | edgefs-op-s3: failed to create s3 s3-cola. failed to create s3 service. Service "rook-edgefs-s3-s3-cola" is invalid: [spec.ports[1].nodePort: Forbidden: may not be used when `type` is 'ClusterIP', spec.ports[2].nodePort: Forbidden: may not be used when `type` is 'ClusterIP']

Same comments as above. If this should be validated by the operator instead of the K8s API, I can add those checks.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, i think you shoud add check to operator. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added port check to the validateService() function

@NullOranje NullOranje force-pushed the edgefs-configurable-servicetypes branch 2 times, most recently from d66677d to d0cdb5c Compare July 25, 2019 19:43
Signed-off-by: Nick McKinney <nmckinney@breakpoint-labs.com>
@NullOranje NullOranje force-pushed the edgefs-configurable-servicetypes branch from d0cdb5c to d9aec6b Compare July 25, 2019 19:50
@dyusupov dyusupov merged commit dde1b91 into rook:master Jul 26, 2019
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.

3 participants