From e5f6a31a9118465c423821f558beefa7c4d8bac2 Mon Sep 17 00:00:00 2001 From: chentao1596 Date: Thu, 23 Feb 2017 09:17:03 +0800 Subject: [PATCH] add nginx daemonst example --- examples/daemonset/nginx/README.md | 40 ++++++++++++++++ .../nginx/nginx-ingress-daemonset.yaml | 47 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 examples/daemonset/nginx/README.md create mode 100644 examples/daemonset/nginx/nginx-ingress-daemonset.yaml diff --git a/examples/daemonset/nginx/README.md b/examples/daemonset/nginx/README.md new file mode 100644 index 000000000..04ee2a443 --- /dev/null +++ b/examples/daemonset/nginx/README.md @@ -0,0 +1,40 @@ +# Nginx Ingress DaemonSet + +In some cases, the Ingress controller will be required to be run at all the nodes in cluster. Using [DaemonSet](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/daemon.md) can achieve this requirement. + +## 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.6 80/TCP 1h + +$ kubectl -n kube-system get po +NAME READY STATUS RESTARTS AGE +default-http-backend-2657704409-6b47n 1/1 Running 0 1h +``` + +## Ingress DaemonSet + +Deploy the daemonset as follows: + +```console +$ kubectl apply -f nginx-ingress-daemonset.yaml +daemonset "nginx-ingress-lb" created + +$ kubectl -n kube-system get ds +NAME DESIRED CURRENT READY NODE-SELECTOR AGE +nginx-ingress-lb 2 2 2 21s + +$ kubectl -n kube-system get po +NAME READY STATUS RESTARTS AGE +default-http-backend-2657704409-6b47n 1/1 Running 0 2h +nginx-ingress-lb-8381i 1/1 Running 0 56s +nginx-ingress-lb-h54gf 1/1 Running 0 56s +``` diff --git a/examples/daemonset/nginx/nginx-ingress-daemonset.yaml b/examples/daemonset/nginx/nginx-ingress-daemonset.yaml new file mode 100644 index 000000000..1b476d670 --- /dev/null +++ b/examples/daemonset/nginx/nginx-ingress-daemonset.yaml @@ -0,0 +1,47 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: nginx-ingress-lb + labels: + name: nginx-ingress-lb + namespace: kube-system +spec: + template: + metadata: + labels: + name: nginx-ingress-lb + spec: + terminationGracePeriodSeconds: 60 + containers: + - image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.2 + name: nginx-ingress-lb + 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 +