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

merge Ingress NEG annotation and Expose NEG annotation #350

Merged
merged 3 commits into from
Jun 22, 2018

Conversation

agau4779
Copy link
Contributor

@agau4779 agau4779 commented Jun 20, 2018

Follow-up to #284 .

  • Merges the Expose NEG and Ingress NEG annotations into a single key. Example: {"ingress": true,"exposed_ports":{"3000":{},"4000":{}}}
  • Use kubeClient to actually update the Kubernetes Service in addition to updating it in serviceLister.
  • Additional cleanup of documentation.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 20, 2018
@agau4779
Copy link
Contributor Author

/assign freehan

@freehan
Copy link
Contributor

freehan commented Jun 20, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 20, 2018
// ExposeNEGAnnotationKey key, and maps ServicePort to attributes of the NEG that should be
// NegAnnotation is the format of the annotation associated with the
// NEGAnnotationKey key.
// Ingress indicates whether or not the Service backs an Ingress. If yes, then
Copy link
Contributor

Choose a reason for hiding this comment

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

Move this to the "ingress" key

"ingress" indicates whether to enable NEG feature for Ingress referencing the service. Each NEG correspond to a service port. NEGs will be created and managed under the following conditions:
1. Service is referenced by ingress
2. "ingress" is set to "true". Default to "false"
When the above conditions are satisfied, Ingress will create load balancer and target corresponding NEGs as backends. Service Nodeport is no longer required. 

type ExposeNegAnnotation map[int32]NegAttributes
type NegAnnotation struct {
Ingress bool `json:"ingress,omitempty"`
ExposedPorts map[int32]NegAttributes `json:"exposed_ports,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

add comment:
ExposedPorts specifies the service ports to be exposed as stand-alone NEG. The exposed NEGs will be created and managed by NEG controller.

Copy link
Contributor

@freehan freehan left a comment

Choose a reason for hiding this comment

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

LGTM overall

// ExposeNEGAnnotationKey key, and maps ServicePort to attributes of the NEG that should be
// NegAnnotation is the format of the annotation associated with the
// NEGAnnotationKey key.
// WARNING: The feature will NOT be effective in the following circumstances:
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this WARNING

// WARNING: The feature will NOT be effective in the following circumstances:
// 1. Service is not referenced in any ingress.
// 2. Adding this annotation on ingress.
// ExposedPorts maps ServicePort to attributes of the NEG that should be
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to the top of ExposedPorts Attribute

@agau4779 agau4779 force-pushed the merge-neg-annotations branch 4 times, most recently from 74d28a0 to 9435da4 Compare June 22, 2018 19:01
service, err = svcClient.Update(service)
if err != nil {
return err
}
return c.serviceLister.Update(service)
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to Update serviceLister

service, err = svcClient.Update(service)
if err != nil {
return err
}
return c.serviceLister.Update(service)
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to Update serviceLister


// Remove NEG Status Annotation when no NEG is needed
if len(portMap) == 0 {
if _, ok := service.Annotations[annotations.NEGStatusKey]; ok {
// TODO: use PATCH to remove annotation
delete(service.Annotations, annotations.NEGStatusKey)
glog.V(2).Infof("Removing expose NEG annotation from service: %s/%s", namespace, name)
service, err = svcClient.Update(service)
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to track service, just return err

@freehan
Copy link
Contributor

freehan commented Jun 22, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 22, 2018
@freehan freehan merged commit c1a9af3 into kubernetes:master Jun 22, 2018
@agau4779 agau4779 deleted the merge-neg-annotations branch June 22, 2018 23:29
k8s-github-robot pushed a commit to kubernetes/kubernetes that referenced this pull request Jun 23, 2018
Automatic merge from submit-queue (batch tested with PRs 65338, 64535). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

[GCE] e2e test for expose neg on gce ingress

**What this PR does / why we need it**:
- Adds e2e test for the expose NEG annotation (which allows for standalone NEGs)

**Special notes for your reviewer**:
Note, kubernetes/ingress-gce#350 must be merged first before this is merged.

`[Unreleased]` tag is on this PR because it depends on code from kubernetes/ingress-gce#350 and kubernetes/ingress-gce#284 being in an Ingress release. Will update this test and test-infra once this is released in the next Ingress.

**Release note**:
```release-note
NONE
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants