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

Improve Project Layout and Refactor Controller Package #357

Merged
merged 10 commits into from
Sep 6, 2018

Conversation

peterkellydev
Copy link

Proposed changes

After the project restructure PR (this branch is branches from that one), this PR then pulls apart some of the complexity in the load balancer controller. Extracts handlers and builds them separately.

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto master
  • I will ensure my PR is targeting the master branch and pulling from my branch from my own fork

@isserrano
Copy link
Contributor

isserrano commented Sep 5, 2018

If go test ./... fixed, everything else LGTM

Copy link
Contributor

@isserrano isserrano left a comment

Choose a reason for hiding this comment

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

Waiting to fix CI stages

@isserrano
Copy link
Contributor

CI fixed, build is fine

Copy link
Contributor

@isaachawley isaachawley left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@pleshakov pleshakov left a comment

Choose a reason for hiding this comment

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

Please see my comments. Additionally,

Also, please update links to nginx-controller folder in the following files:

  • examples/customization/README.md in log-format and stream-log-format cm keys
  • build.README.md. , ... in of your license are located in the nginx-controller folder: The keys must be placed in kubernetes-ingress now.

The helm-chart related files must be updated according with the new project layout:

  • Chart.yaml: Update https://github.com/nginxinc/kubernetes-ingress/tree/master/helm-chart

The install folder is not completely removed.

The code refactoring brought a lot of public uncommented method, so we now get linter warnings.

.gitignore Outdated
osx-nginx-plus-ingress
nginx-plus-ingress
nginx-controller/nginx-controller
cmd/nginx-ic/nginx-ic
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is not needed

Copy link
Author

Choose a reason for hiding this comment

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

it is needed as it is the binary produced from go build, but it should be nginx-ingress

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 the following lines cover that:

nginx-ingress
!nginx-ingress/

CONTRIBUTING.md Outdated
* The main code resides under `/nginx-controller`
* The project dependencies reside in the `/vendor`. We use [dep](https://github.com/golang/dep) for managing dependencies.
* The project follows a standard Go project layout
* The main code is found at `cmd/nginx-ic/`
Copy link
Contributor

Choose a reason for hiding this comment

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

the actual folder is cmd/nginx-ingress/

Makefile Outdated
@@ -46,3 +49,4 @@ endif

clean:
rm -f nginx-ingress
rm $(DOCKERFILE)
Copy link
Contributor

Choose a reason for hiding this comment

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

When make is called with DOCKERFILE=DockerfileForPlus, DockerfileForPlus is copied to /. As a result, make clean must also be called with DOCKERFILE=DockerfileForPlus. Perhaps we can copy DockerfileForPlus or any other as Dockerfile?

@@ -71,7 +71,7 @@ NGINX Plus provides you with [advanced statistics](https://www.nginx.com/product
* **JWTs** NGINX Plus can validate JSON Web Tokens (JWTs), providing a flexible authentication mechanism.
* **Support** Support from NGINX Inc is available for NGINX Plus Ingress controller.

**Note**: Deployment of the Ingress controller for NGINX Plus requires you to do one extra step: build your own [Docker image](nginx-controller) using the certificate and key for your subscription.
**Note**: Deployment of the Ingress controller for NGINX Plus requires you to do one extra step: build your own [Docker image](build) using the certificate and key for your subscription.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also update 2 links for the edge version for build your own image in the NGINX Ingress Controller Releases section

Copy link
Contributor

Choose a reason for hiding this comment

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

links to the Helm chart as well in the same section

Copy link
Contributor

Choose a reason for hiding this comment

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

and a link to manifests in the same section

@@ -6,7 +6,7 @@ RUN ln -sf /proc/1/fd/1 /var/log/nginx/access.log \
&& ln -sf /proc/1/fd/1 /var/log/nginx/stream-access.log \
&& ln -sf /proc/1/fd/2 /var/log/nginx/error.log

COPY nginx-ingress nginx/templates/nginx.ingress.tmpl nginx/templates/nginx.tmpl /
COPY nginx-ingress internal/nginx/templates/nginx.ingress.tmpl internal/nginx/templates/nginx.tmpl /
Copy link
Contributor

Choose a reason for hiding this comment

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

DockerfileForAlpine and DockerfileForPlus require a similar update

build/README.md Outdated
```
$ git clone https://github.com/nginxinc/kubernetes-ingress/
$ cd kubernetes-ingress/nginx-controller
```

1. If you're using a stable release, check out the corresponding tag. For release 1.3.0, run:
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest removing this paragraph completely, cause it will check out the old structure

Makefile Outdated
@@ -4,22 +4,24 @@ VERSION = edge
TAG = $(VERSION)
PREFIX = nginx/nginx-ingress

DOCKER_RUN = docker run --rm -v $(shell pwd)/../:/go/src/github.com/nginxinc/kubernetes-ingress -w /go/src/github.com/nginxinc/kubernetes-ingress/nginx-controller/
DOCKER_RUN = docker run --rm -v $(shell pwd):/go/src/github.com/nginxinc/kubernetes-ingress
Copy link
Contributor

Choose a reason for hiding this comment

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

will DOCKER_TEST_RUN make more sense as a name?

Copy link
Author

Choose a reason for hiding this comment

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

I am not going to change this in this PR

@@ -10,7 +10,7 @@ This chart deploys the NGINX Ingress controller in your Kubernetes cluster.
- Helm 2.8.x+.
- Git.
- If you’d like to use NGINX Plus:
- Build an Ingress controller image with NGINX Plus and push it to your private registry by following the instructions from [here](../nginx-controller/README.md).
- Build an Ingress controller image with NGINX Plus and push it to your private registry by following the instructions from [here](../../build/README.md).
- Update the `controller.image.repository` field of the `values-plus.yaml` accordingly.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also remove If you're using a stable release, check out the corresponding tag. For release 1.3.0 paragraph.

Also, update Change your working directory to /helm-chart, cd kubernetes-ingress/helm-chart x2

@@ -5,7 +5,7 @@
Make sure you have access to the Ingress controller image:

* For NGINX Ingress controller, use the image `nginx/nginx-ingress` from [DockerHub](https://hub.docker.com/r/nginx/nginx-ingress/).
* For NGINX Plus Ingress controller, build your own image and push it to your private Docker registry by following the instructions from [here](../nginx-controller).
* For NGINX Plus Ingress controller, build your own image and push it to your private Docker registry by following the instructions from [here](../build/README.md).

The installation manifests are located in the [install](../install) folder. In the steps below we assume that you will be running the commands from that folder.
Copy link
Contributor

Choose a reason for hiding this comment

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

please rename install to deployments

- Addresses all `golint` warnings including ones not caused by this PR
- Moves install files to correct place
- Updates docs with old references before structure
- Fixes broken links (not caused by this PR)
- Updates COPY command in other Dockerfiles
@pleshakov pleshakov changed the title Controller refactor Improve Project Layout and Refactor Controller Package Sep 6, 2018
@pleshakov pleshakov added enhancement Pull requests for new features/feature enhancements change Pull requests that introduce a change labels Sep 6, 2018
@peterkellydev peterkellydev merged commit cca1389 into master Sep 6, 2018
@peterkellydev peterkellydev deleted the controller-refactor branch September 6, 2018 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change Pull requests that introduce a change enhancement Pull requests for new features/feature enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants