-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #503 from aledbf/aws-example
Add example for nginx in aws
- Loading branch information
Showing
3 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# NGINX Ingress running in AWS | ||
|
||
This example shows how is possible to use the nginx ingress controller in AWS behind an ELB configured with Proxy Protocol. | ||
|
||
```console | ||
kubectl create -f ./nginx-ingress-controller.yaml | ||
``` | ||
|
||
This command creates: | ||
- a default backend deployment and service. | ||
- a service with `type: LoadBalancer` configuring Proxy Protocol in the ELB (`service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*'`). | ||
- a configmap for the ingress controller enabling proxy protocol in NGINX (`use-proxy-protocol: "true"`) | ||
- a deployment for the ingress controller | ||
|
||
Is the proxy protocol necessary? | ||
|
||
No but only enabling the procotol is possible to keep the real source IP address requesting the connection. | ||
|
||
### References | ||
|
||
- http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/enable-proxy-protocol.html | ||
- https://www.nginx.com/resources/admin-guide/proxy-protocol/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: nginx-default-backend | ||
labels: | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
spec: | ||
ports: | ||
- port: 80 | ||
targetPort: http | ||
selector: | ||
app: nginx-default-backend | ||
|
||
--- | ||
|
||
kind: Deployment | ||
apiVersion: extensions/v1beta1 | ||
metadata: | ||
name: nginx-default-backend | ||
labels: | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
app: nginx-default-backend | ||
spec: | ||
terminationGracePeriodSeconds: 60 | ||
containers: | ||
- name: default-http-backend | ||
image: gcr.io/google_containers/defaultbackend:1.0 | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 30 | ||
timeoutSeconds: 5 | ||
resources: | ||
limits: | ||
cpu: 10m | ||
memory: 20Mi | ||
requests: | ||
cpu: 10m | ||
memory: 20Mi | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
protocol: TCP | ||
|
||
--- | ||
|
||
kind: ConfigMap | ||
apiVersion: v1 | ||
metadata: | ||
name: ingress-nginx | ||
labels: | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
data: | ||
use-proxy-protocol: "true" | ||
|
||
--- | ||
|
||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: ingress-nginx | ||
labels: | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
annotations: | ||
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*' | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: ingress-nginx | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: http | ||
- name: https | ||
port: 443 | ||
targetPort: https | ||
|
||
--- | ||
|
||
kind: Deployment | ||
apiVersion: extensions/v1beta1 | ||
metadata: | ||
name: ingress-nginx | ||
labels: | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: ingress-nginx | ||
k8s-addon: ingress-nginx.addons.k8s.io | ||
spec: | ||
terminationGracePeriodSeconds: 60 | ||
containers: | ||
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.3 | ||
name: ingress-nginx | ||
imagePullPolicy: Always | ||
ports: | ||
- name: http | ||
containerPort: 80 | ||
protocol: TCP | ||
- name: https | ||
containerPort: 443 | ||
protocol: TCP | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 10254 | ||
scheme: HTTP | ||
initialDelaySeconds: 30 | ||
timeoutSeconds: 5 | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: POD_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
args: | ||
- /nginx-ingress-controller | ||
- --default-backend-service=$(POD_NAMESPACE)/nginx-default-backend | ||
- --configmap=$(POD_NAMESPACE)/ingress-nginx | ||
- --publish-service=$(POD_NAMESPACE)/ingress-nginx |