Merge pull request #326 from chentao1596/daemonset
add nginx daemonset example
This commit is contained in:
commit
298925527d
2 changed files with 87 additions and 0 deletions
40
examples/daemonset/nginx/README.md
Normal file
40
examples/daemonset/nginx/README.md
Normal file
|
@ -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 <none> 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 <none> 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
|
||||||
|
```
|
47
examples/daemonset/nginx/nginx-ingress-daemonset.yaml
Normal file
47
examples/daemonset/nginx/nginx-ingress-daemonset.yaml
Normal file
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue