-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Changes from 7 commits
bc78a8b
ee6bf87
3a8b9fd
5e66437
961e591
39b1338
bc7eebd
f12960e
82a75da
2f39310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,8 +30,12 @@ Read the [documentation](https://github.com/nginxinc/kubernetes-ingress/tree/mas | |
### Project Structure | ||
|
||
* This Ingress Controller is written in Go and supports both the open source NGINX software and NGINX Plus. | ||
* 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/` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the actual folder is |
||
* The internal code is found at `internal/` | ||
* Build files for Docker and CI are found under `build/` | ||
* Deployment yaml files, and Helm files are found at `deployments/` | ||
* The project dependencies are found at `vendor/`. We use [dep](https://github.com/golang/dep) for managing dependencies. | ||
|
||
## Contributing | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not going to change this in this PR |
||
DOCKER_BUILD_RUN = docker run --rm -v $(shell pwd):/go/src/github.com/nginxinc/kubernetes-ingress -w /go/src/github.com/nginxinc/kubernetes-ingress/cmd/nginx-ingress/ | ||
GOLANG_CONTAINER = golang:1.10 | ||
DOCKERFILEPATH = build | ||
DOCKERFILE = Dockerfile | ||
|
||
BUILD_IN_CONTAINER = 1 | ||
PUSH_TO_GCR = | ||
GENERATE_DEFAULT_CERT_AND_KEY = | ||
GENERATE_DEFAULT_CERT_AND_KEY = | ||
DOCKER_BUILD_OPTIONS = | ||
|
||
GIT_COMMIT=$(shell git rev-parse --short HEAD) | ||
|
||
nginx-ingress: | ||
ifeq ($(BUILD_IN_CONTAINER),1) | ||
$(DOCKER_RUN) -e CGO_ENABLED=0 $(GOLANG_CONTAINER) go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o nginx-ingress *.go | ||
$(DOCKER_BUILD_RUN) -e CGO_ENABLED=0 $(GOLANG_CONTAINER) go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o /go/src/github.com/nginxinc/kubernetes-ingress/nginx-ingress | ||
else | ||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o nginx-ingress *.go | ||
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-w -X main.version=${VERSION} -X main.gitCommit=${GIT_COMMIT}" -o nginx-ingress github.com/nginxinc/kubernetes-ingress/cmd/nginx-ingress | ||
endif | ||
|
||
test: | ||
|
@@ -29,12 +31,13 @@ else | |
go test ./... | ||
endif | ||
|
||
certificate-and-key: | ||
certificate-and-key: | ||
ifeq ($(GENERATE_DEFAULT_CERT_AND_KEY),1) | ||
./generate_default_cert_and_key.sh | ||
./build/generate_default_cert_and_key.sh | ||
endif | ||
|
||
container: test nginx-ingress certificate-and-key | ||
cp $(DOCKERFILEPATH)/$(DOCKERFILE) . | ||
docker build $(DOCKER_BUILD_OPTIONS) -f $(DOCKERFILE) -t $(PREFIX):$(TAG) . | ||
|
||
push: container | ||
|
@@ -46,3 +49,4 @@ endif | |
|
||
clean: | ||
rm -f nginx-ingress | ||
rm $(DOCKERFILE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When make is called with |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. links to the Helm chart as well in the same section There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and a link to manifests in the same section |
||
The Docker image of the Ingress controller for NGINX is [available on Docker Hub](https://hub.docker.com/r/nginx/nginx-ingress/). | ||
|
||
## Using Multiple Ingress Controllers | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 / | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DockerfileForAlpine and DockerfileForPlus require a similar update |
||
|
||
RUN rm /etc/nginx/conf.d/* | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,13 @@ Although the Ingress controller is written in golang, golang is not required, as | |
|
||
### Building the Image and Pushing It to the Private Registry | ||
|
||
We build the image using the make utility and the provided `Makefile`. Let’s create the controller binary, build an image and push the image to the private registry. | ||
We build the image using the make utility and the provided `Makefile`. Let’s create the controller binary, build an image and push the image to the private registry. | ||
|
||
1. Make sure to run the `docker login` command first to login to the registry. If you’re using Google Container Registry, you don’t need to use the docker command to login -- make sure you’re logged into the gcloud tool (using the `gcloud auth login` command) and set the variable `PUSH_TO_GCR=1` when running the make command. | ||
|
||
1. Clone the Ingress controller repo and change your folder to `nginx-controller`: | ||
1. Clone the Ingress controller repo: | ||
``` | ||
$ 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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
@@ -84,10 +83,8 @@ The **Makefile** contains the following main variables for you to customize (eit | |
1. `Dockerfile`, for building a debian-based image with NGINX. It's used by default. | ||
1. `DockerfileForAlpine`, for building an alpine-based image with NGINX. | ||
1. `DockerfileForPlus`, for building an debian-based image with NGINX Plus. | ||
* **GENERATE_DEFAULT_CERT_AND_KEY** - The Ingress controller requires a certificate and a key for the default HTTP/HTTPS server. You can reference them in a TLS Secret in a command-line argument to the Ingress controller. As an alternative, you can add a file in the PEM format with your certificate and key to the image as `/etc/nginx/secrets/default`. Optionally, you can generate a self-signed certificate and a key during the build process. Set `GENERATE_DEFAULT_CERT_AND_KEY` to `1` to generate a certificate and a key in the `default.pem` file. Note that you must add the `ADD` instruction in the Dockerfile to copy the cert and the key to the image. The default value of `GENERATE_DEFAULT_CERT_AND_KEY` is `0`. | ||
* **GENERATE_DEFAULT_CERT_AND_KEY** - The Ingress controller requires a certificate and a key for the default HTTP/HTTPS server. You can reference them in a TLS Secret in a command-line argument to the Ingress controller. As an alternative, you can add a file in the PEM format with your certificate and key to the image as `/etc/nginx/secrets/default`. Optionally, you can generate a self-signed certificate and a key during the build process. Set `GENERATE_DEFAULT_CERT_AND_KEY` to `1` to generate a certificate and a key in the `default.pem` file. Note that you must add the `ADD` instruction in the Dockerfile to copy the cert and the key to the image. The default value of `GENERATE_DEFAULT_CERT_AND_KEY` is `0`. | ||
* **DOCKER_BUILD_OPTIONS** -- the [options](https://docs.docker.com/engine/reference/commandline/build/#options) for the `docker build` command. For example, `--pull`. | ||
* **BUILD_IN_CONTAINER** -- By default, to compile the controller we use the [golang](https://hub.docker.com/_/golang/) container that we run as part of the building process. If you want to compile the controller using your local golang environment: | ||
1. Make sure that the Ingress controller repo is in your `$GOPATH`. | ||
1. Specify `BUILD_IN_CONTAINER=0` when you run the make command. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also remove Also, update |
||
|
||
## Installing the Chart | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please rename install to deployments |
||
|
||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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-ingressThere was a problem hiding this comment.
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: