Skip to content

Commit 33f7d02

Browse files
committed
first version of external ingress controller
0 parents  commit 33f7d02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+64802
-0
lines changed

Diff for: .dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
core
2+

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootfs/nginx-ingress-controller
2+
*/**/.coverprofile

Diff for: Changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Changelog
2+
3+
### 0.1
4+
First version of ext_nginx backend. Working as a standalone service to manage nginx configuration file.

Diff for: Ingress.png

24.6 KB
Loading

Diff for: Makefile

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Use the 0.0 tag for testing, it shouldn't clobber any release builds
2+
TAG?=0.1
3+
GOOS?=linux
4+
#SED_I?=sed -i
5+
#GOHOSTOS ?= $(shell go env GOHOSTOS)
6+
7+
REPO_INFO=$(shell git config --get remote.origin.url)
8+
9+
ifndef COMMIT
10+
COMMIT := git-$(shell git rev-parse --short HEAD)
11+
endif
12+
13+
PKG=k8s.io/ingress/controllers/ext_nginx
14+
15+
ARCH ?= $(shell go env GOARCH)
16+
GOARCH = ${ARCH}
17+
DUMB_ARCH = ${ARCH}
18+
19+
ALL_ARCH = amd64 arm ppc64le
20+
21+
TEMP_DIR := $(shell mktemp -d)
22+
23+
24+
clean:
25+
rm -f rootfs/nginx-ingress-controller
26+
# $(DOCKER) rmi -f $(MULTI_ARCH_IMG):$(TAG) || true
27+
28+
build: clean
29+
CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -a -installsuffix cgo \
30+
-ldflags "-s -w -X ${PKG}/pkg/version.RELEASE=${TAG} -X ${PKG}/pkg/version.COMMIT=${COMMIT} -X ${PKG}/pkg/version.REPO=${REPO_INFO}" \
31+
-o rootfs/nginx-ingress-controller ${PKG}/pkg/cmd/controller
32+
33+
fmt:
34+
@echo "+ $@"
35+
@go list -f '{{if len .TestGoFiles}}"gofmt -s -l {{.Dir}}"{{end}}' $(shell go list ${PKG}/... | grep -v vendor) | xargs -L 1 sh -c
36+
37+
lint:
38+
@echo "+ $@"
39+
@go list -f '{{if len .TestGoFiles}}"golint {{.Dir}}/..."{{end}}' $(shell go list ${PKG}/... | grep -v vendor) | xargs -L 1 sh -c
40+
41+
test: fmt lint vet
42+
@echo "+ $@"
43+
@go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PKG}/... | grep -v vendor)
44+
45+
cover:
46+
@echo "+ $@"
47+
@go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' $(shell go list ${PKG}/... | grep -v vendor) | xargs -L 1 sh -c
48+
gover
49+
goveralls -coverprofile=gover.coverprofile -service travis-ci -repotoken ${COVERALLS_TOKEN}
50+
51+
vet:
52+
@echo "+ $@"
53+
@go vet $(shell go list ${PKG}/... | grep -v vendor)

Diff for: README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# External Nginx Ingress Controller
2+
3+
The external nginx ingress controller is a fork of the orginal nginx ingress controller with the goal to be usable outside of kubernetes.
4+
Instead of running in a pod, this will run as a system service along side nginx.
5+
6+
The goal of the external ingress controller is to be usable where nginx cannot be run in a container, such as when nginx is fronting customers on Internet in such a way that container restarts are not a option.
7+
8+
Example when you host your kubernetes cluster on-premise and don't want to have multiple layers of "load balancing" in front of your pods. You also really like nginx.
9+
Using this ingress controller on your edge load balacing cluster, the configuration is kept up too date and you can still use nginx build-in functions for zero down time deployments of config and binaries that the normal "in-cluster" ingress controller don't support.
10+
11+
## Design
12+
13+
### Overview
14+
![Alt text](Ingress.png)
15+
16+
The following shows how nginx and the ingress controller sits outside the cluster to serve traffic. The ingress controller updates nginx configuration file with the ip addresses to the cluster pods directly. Simple and understandable.
17+
18+
#### Requirements
19+
- Nginx should be installed and managed already. :)
20+
21+
- The nginx nodes that live outside the cluster needs to be able to have network connectivity to both the api servers of kubernetes and the pods themselves.
22+
23+
24+
Note:
25+
26+
Clustering and making nginx highly availble is outside the scope of this project.
27+
This could be done many ways. We at [Unibet](https://www.unibet.com) use ECMP in our routers to load balance traffic at the edge over all our instances in a stateless manner, while also making sure the nodes always are in HA pairs for failover. This is just one setup of a edge cluster and there is many different ways you could accomplish the same.
28+
29+
Networking is outside the scope of this project, briefly we use bgp with [Project Calico](https://www.projectcalico.org/) to enable the pods to have visible ip addresses outside the cluster on our network that can be accessed like normal.
30+
31+
## Installation
32+
33+
34+
TODO: Write here nice instructions, basically
35+
- git clone
36+
- make build
37+
- copy rootfs ( binary and config ) from rootfs/nginx-ingress-controller to your server
38+
- make sure you have k8s config file
39+
- create a init file to launch as a service
40+
- run with correct arguments
41+
42+
example:
43+
`export POD_NAME=default`
44+
`export POD_NAMESPACE=default`
45+
`./nginx-ingress-controller --default-backend-service=default/$K8_DEFAULTBACKEND --apiserver-host=https://$K8_API --kubeconfig ~/.kube/config`
46+
47+
48+
- profit
49+
50+
## Usage
51+
52+
It works very much like the original ingress controller, and supports mostly the same features. For full understanding, please read: https://github.com/kubernetes/ingress/tree/master/controllers/nginx
53+
54+

0 commit comments

Comments
 (0)