Ingress安装
https://kubernetes.github.io/ingress-nginx/

一、Ingress controller 安装

下载yaml配置清单
1
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/cloud/deploy.yaml
Copied!
创建:
1
kubectl apply -f ./deploy.yaml
2
namespace/ingress-nginx created
3
serviceaccount/ingress-nginx created
4
configmap/ingress-nginx-controller created
5
clusterrole.rbac.authorization.k8s.io/ingress-nginx created
6
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created
7
role.rbac.authorization.k8s.io/ingress-nginx created
8
rolebinding.rbac.authorization.k8s.io/ingress-nginx created
9
service/ingress-nginx-controller-admission created
10
service/ingress-nginx-controller created
11
deployment.apps/ingress-nginx-controller created
12
validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created
13
clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created
14
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
15
job.batch/ingress-nginx-admission-create created
16
job.batch/ingress-nginx-admission-patch created
17
role.rbac.authorization.k8s.io/ingress-nginx-admission created
18
rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
19
serviceaccount/ingress-nginx-admission created
Copied!
1
kubectl get svc -n ingress-nginx
2
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
3
ingress-nginx-controller LoadBalancer 10.96.158.117 <pending> 80:30773/TCP,443:32233/TCP 8m48s
4
ingress-nginx-controller-admission ClusterIP 10.97.62.60 <none> 443/TCP 8m48s
Copied!
创建过程中:
1
kubectl get pods -n ingress-nginx
2
NAME READY STATUS RESTARTS AGE
3
ingress-nginx-admission-create-8mhz8 0/1 Completed 0 2m38s
4
ingress-nginx-admission-patch-t568k 0/1 Completed 0 2m38s
5
ingress-nginx-controller-866488c6d4-85lph 0/1 ContainerCreating 0 2m48s
Copied!
修改port和type:
1
# Source: ingress-nginx/templates/controller-service.yaml
2
apiVersion: v1
3
kind: Service
4
metadata:
5
labels:
6
helm.sh/chart: ingress-nginx-2.0.3
7
app.kubernetes.io/name: ingress-nginx
8
app.kubernetes.io/instance: ingress-nginx
9
app.kubernetes.io/version: 0.32.0
10
app.kubernetes.io/managed-by: Helm
11
app.kubernetes.io/component: controller
12
name: ingress-nginx-controller
13
namespace: ingress-nginx
14
spec:
15
type: NodePort #从默认的LoadBalancer修改为NodePort
16
externalTrafficPolicy: Local
17
ports:
18
- name: http
19
port: 80
20
protocol: TCP
21
targetPort: http
22
nodePort: 30080 #增加端口指定
23
- name: https
24
port: 443
25
protocol: TCP
26
targetPort: https
27
nodePort: 30443 #增加端口指定
28
selector:
29
app.kubernetes.io/name: ingress-nginx
30
app.kubernetes.io/instance: ingress-nginx
31
app.kubernetes.io/component: controller
Copied!
1
kubectl get svc -n ingress-nginx
2
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
3
ingress-nginx-controller NodePort 10.96.158.117 <none> 80:30080/TCP,443:30443/TCP 7h22m
4
ingress-nginx-controller-admission ClusterIP 10.97.62.60 <none> 443/TCP 7h22m
Copied!
1
$ kubectl get pods -n ingress-nginx -o wide
2
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
3
ingress-nginx-admission-create-8mhz8 0/1 Completed 0 8h 10.244.3.19 37 <none> <none>
4
ingress-nginx-admission-patch-t568k 0/1 Completed 0 8h 10.244.1.18 35 <none> <none>
5
ingress-nginx-controller-866488c6d4-85lph 1/1 Running 0 8h 10.244.3.21 37 <none> <none>
Copied!
测试:
1
$ curl 10.96.158.117
2
<html>
3
<head><title>404 Not Found</title></head>
4
<body>
5
<center><h1>404 Not Found</h1></center>
6
<hr><center>nginx/1.17.10</center>
7
</body>
8
</html>
Copied!

二、Ingress 安装

Last modified 1yr ago