-
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 #360 from chentao1596/multi-deployment
add example of 'run multiple nginx ingress controllers as a deployment'
- Loading branch information
Showing
2 changed files
with
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Deploying multi Nginx Ingress Controllers | ||
|
||
This example aims to demonstrate the Deployment of multi nginx ingress controllers. | ||
|
||
## Default Backend | ||
|
||
The default backend is a service of handling all url paths and hosts the nginx controller doesn't understand. Deploy the default-http-backend as follow: | ||
|
||
```console | ||
$ kubectl apply -f ../../deployment/nginx/default-backend.yaml | ||
deployment "default-http-backend" configured | ||
service "default-http-backend" configured | ||
|
||
$ kubectl -n kube-system get svc | ||
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE | ||
default-http-backend 192.168.3.52 <none> 80/TCP 6m | ||
|
||
$ kubectl -n kube-system get po | ||
NAME READY STATUS RESTARTS AGE | ||
default-http-backend-2657704409-wz6o3 1/1 Running 0 6m | ||
``` | ||
|
||
## Ingress Deployment | ||
|
||
Deploy the Deployment of multi controllers as follows: | ||
|
||
```console | ||
$ kubectl apply -f nginx-ingress-deployment.yaml | ||
deployment "nginx-ingress-controller" created | ||
|
||
$ kubectl -n kube-system get deployment | ||
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE | ||
default-http-backend 1 1 1 1 16m | ||
nginx-ingress-controller 2 2 2 2 24s | ||
|
||
$ kubectl -n kube-system get po | ||
NAME READY STATUS RESTARTS AGE | ||
default-http-backend-2657704409-wz6o3 1/1 Running 0 16m | ||
nginx-ingress-controller-3752011415-0qbi6 1/1 Running 0 39s | ||
nginx-ingress-controller-3752011415-vi8fq 1/1 Running 0 39s | ||
``` |
47 changes: 47 additions & 0 deletions
47
examples/scaling-deployment/nginx/nginx-ingress-deployment.yaml
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,47 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-ingress-controller | ||
labels: | ||
k8s-app: nginx-ingress-controller | ||
namespace: kube-system | ||
spec: | ||
replicas: 2 | ||
template: | ||
metadata: | ||
labels: | ||
k8s-app: nginx-ingress-controller | ||
spec: | ||
terminationGracePeriodSeconds: 60 | ||
containers: | ||
- image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.2 | ||
name: nginx-ingress-controller | ||
readinessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 10254 | ||
scheme: HTTP | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 10254 | ||
scheme: HTTP | ||
initialDelaySeconds: 10 | ||
timeoutSeconds: 1 | ||
ports: | ||
- containerPort: 80 | ||
hostPort: 80 | ||
- containerPort: 443 | ||
hostPort: 443 | ||
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)/default-http-backend |