1. 安装. 从ingress的官网下载yaml文件.
https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
注意里面的iamges 的版本:
quay.io/kuberneftes-ingress-controller/nginx-ingress-controller:0.26.1
测试了下 不翻墙能够下载下来就是有点点慢
[root@k8smaster ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
postgres latest ee227fd504c8 3 days ago 348MB
quay.io/kubernetes-ingress-controller/nginx-ingress-controller 0.26.1 29024c9c6e70 2 weeks ago 483MB
2. 安装的话比较简单
kubectl apply -f mandatory.yaml
即可
注意修改增加修改一个 hostNetwork: true的才可以用
位置是在一个deployment 里面 images 的前面.
宋健鑫老师提供的解决思路 3ks alot
3. 简单的验证办法.
3.1 写一个最简单的nginx的 deployment文件
nginx-deployment.yaml
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
ingress-app: nginx
replicas: 1
template:
metadata:
labels:
ingress-app: nginx
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
3.2 写一个svc文件
nginx-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: nginx-svc
labels:
app: nginx-svc
spec:
ports:
- port: 80
targetPort: 80
nodePort: 30080
protocol: TCP
name: http
selector:
ingress-app: nginx
sessionAffinity: ClientIP
type: NodePort
3.3 写一个ingress的配置文件
nginx-ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx-ingress
namespace: default
spec:
rules:
- host: nginx.gscloud.club
http:
paths:
- path: /
backend:
serviceName: nginx-svc
servicePort: 80
4. 可以修改自己的host文件增加对应解析关系 也可以修改设置解析.
10.24.20.226 nginx.gscloud.club