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

Configure service types #189

Merged
merged 1 commit into from
Oct 27, 2016
Merged

Configure service types #189

merged 1 commit into from
Oct 27, 2016

Conversation

procrypt
Copy link
Contributor

@procrypt procrypt commented Oct 7, 2016

delete(service.Annotations, "kompose.service.cloud")
}
}

Copy link
Contributor

@dustymabe dustymabe Oct 7, 2016

Choose a reason for hiding this comment

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

should we do any error checking for invalid values here? i.e. anything that is not True/true/ ? Is "False" or "false" acceptable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dustymabe it now accepts "False" or "false" .

@@ -263,6 +274,7 @@ func UpdateKubernetesObjects(name string, service kobject.ServiceConfig, objects
// Configure annotations
annotations := transformer.ConfigAnnotations(service)


Copy link
Contributor

Choose a reason for hiding this comment

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

random added line. I would delete

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted random line.

@procrypt procrypt force-pushed the labels branch 3 times, most recently from 712ca34 to 96e9996 Compare October 8, 2016 11:39
@kadel
Copy link
Member

kadel commented Oct 10, 2016

Thank you @procrypt for staring on this.

I have few notes regarding this:
Wouldn't be better to have something like kompose.service.type with different values representing k8s service types, rather than having bunch of true/false options and worrying about conflicts between them?

Another question is if labels should use k8s terminology like (LoadBalancer,NodePort,ClusterIP) or something different that is more general. Any thought on this @sebgoa ?

Examples:
k8s terminology

  • kompose.service.type: loadbalancer
  • kompose.service.type: nodeport
  • kompose.service.type: clusterip

generic:

  • kompose.service.type: public - (or kompose.service.type: external) maps to LoadBalancer
  • kompose.service.type: local - maps to ClusterIP
  • kompose.service.type: node - maps to NodePort

@sebgoa
Copy link
Contributor

sebgoa commented Oct 10, 2016

I'd rather stick to k8s terminology than create a kompose specific one.

if some providers don't use that terminology, the onus should be on them to make the mapping ;)

@procrypt
Copy link
Contributor Author

procrypt commented Oct 12, 2016

@kadel I agree with @sebgoa we should use the k8 terminology.
I'm updating the PR @dustymabe I'm also adding a check for invalid value.

@procrypt procrypt force-pushed the labels branch 3 times, most recently from 1be9fb1 to 50a517f Compare October 12, 2016 06:39
@procrypt procrypt changed the title [WIP] configure service types Configure service types Oct 12, 2016
@surajssd
Copy link
Member

@procrypt you will have to update the unit tests and also add new functional tests for this kinda behavior.

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

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

@procrypt I added few suggestions. Feel free to ping me on irc or slack for any help or clarification.

Can you please include some tests for this?
I would also consider creating kompose.service.type as constant, so we can easily change it in the future.

for key, value := range service.Annotations {
if key == "kompose.service.type" && (value == "NodePort" || value == "nodeport") {
svc.Spec.Type = "NodePort"
delete(service.Annotations, "kompose.service.type")
Copy link
Member

Choose a reason for hiding this comment

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

I would keep original Annotation. It might be useful to have this information in future for keeping track where this value came from.

@@ -242,6 +242,22 @@ func CreateService(name string, service kobject.ServiceConfig, objects []runtime
servicePorts := ConfigServicePorts(name, service)
svc.Spec.Ports = servicePorts

// Configure service types
for key, value := range service.Annotations {
if key == "kompose.service.type" && (value == "NodePort" || value == "nodeport") {
Copy link
Member

Choose a reason for hiding this comment

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

it would be better to have value test case insensitive.
you can convert it to lowercase strings.ToLower(value) and use it in if statement

svc.Spec.Type = "LoadBalancer"
delete(service.Annotations, "kompose.service.type")
} else {
logrus.Fatalf("Unknown Service Type %s", value)
Copy link
Member

Choose a reason for hiding this comment

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

If there is any other label than kompose.service.type it fails on this.

It would be better to break this into two nested ifs or switch in if.
In first level you check if there is kompose.service.type key, and inside that you do else if or switch on values.

@procrypt
Copy link
Contributor Author

procrypt commented Oct 20, 2016

@kadel I have updated the PR as per your suggestion please take a look at it.

@procrypt procrypt force-pushed the labels branch 3 times, most recently from 03c82d6 to 47d3db9 Compare October 20, 2016 22:29
@kadel
Copy link
Member

kadel commented Oct 21, 2016

Code looks good 👍
Thank you @procrypt

One last thing. Can you please add tests and docs?

@procrypt
Copy link
Contributor Author

@kadel I'll add the tests and docs :)

Copy link
Member

@kadel kadel left a comment

Choose a reason for hiding this comment

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

I've created separate issue for docs and tests for this PR.
I'm going to merge this so we can include it in the next release.

@kadel kadel merged commit 1280b9a into kubernetes:master Oct 27, 2016
@procrypt
Copy link
Contributor Author

procrypt commented Oct 27, 2016

@kadel Thanks :)

@procrypt procrypt deleted the labels branch November 3, 2016 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants