-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathingress配置
122 lines (103 loc) · 2.21 KB
/
ingress配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
案例1
cat << EOF > http.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: httpd-test
spec:
rules:
- host: foo.bar.com
http:
paths:
- backend:
serviceName: httpd
servicePort: 80
- host: bar.baz.com
http:
paths:
- backend:
serviceName: nginx
servicePort: 80
EOF
案例2
cat << EOF> https.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: https-test
spec:
tls:
- hosts:
- www.aliangedu.com
secretName: aliangedu-https
rules:
- host: www.aliangedu.com
http:
paths:
- backend:
serviceName: nginx
servicePort: 80
EOF
实战案例3:
cat << EOF > nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: hpanginx-deployment
labels:
app: hpanginx
spec:
replicas: 4
revisionHistoryLimit: 10
selector:
matchLabels:
app: hpanginx
template:
metadata:
labels:
app: hpanginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
resources:
requests:
memory: "64Mi"
cpu: "25m"
limits:
memory: "128Mi"
cpu: "50m"
---
kind: Service
apiVersion: v1
metadata:
labels:
app: hpanginx
name: nginx-deployment-service
spec:
ports:
- port: 80
targetPort: 80
name: http
selector:
app: hpanginx
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-deployment-service-ingress
spec:
rules:
- host: nginx-deployment.chenlei.com
http:
paths:
- backend:
serviceName: nginx-deployment-service
servicePort: 80
EOF
注意:每一个节点都要有nginx-ingress-controller,例如有三个节点,
但kubectl get po -o wide -n ingress-nginx | grep controller 查看只有两个nginx-ingress-controller,则用下面命令扩充
kubectl scale --replicas=3 deploy/nginx-ingress-controller -n ingress-nginx
详细配置请参阅: https://github.com/hx6007/Kubernetes-my-study/blob/master/Course-Lizhenliang/%E7%AC%AC09%E8%8A%82%202%20Ingress%20http%E5%92%8Chttps%E7%BD%91%E7%AB%99%E6%B5%8B%E8%AF%95