首页 > 技术文章 > k8s基础概念之五 ingress

RRecal 2021-12-16 17:24 原文

 

有了NodePort为什么还要用Ingress呢?

因为在pod多的时候,NodePort性能会急剧下降,如果你的k8s集群有成百上千的服务那岂不是要管理成百上千个NodePort

 

 

Ingress概念

同时来说,Ingress和我们之前提到的Service、Deployment也是一个k8s的资源类型,Ingress是用于实现用域名的方式访问k8s集群的内部应用。ingress受命名空间隔离

 

ingress-nginx:k8s 官方开发维护的,我们使k8s官方开发维护的
nginx-ingress: nginx官方开发维护的

 

ingress安装

1.从官网下载ingress yaml文件

https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.49.3/deploy/static/provider/baremetal/deploy.yaml
#从ingress官网下载0.49.3yaml文件,要是抛出好像是什么Ipv4那三行的异常,说明当前版本不支持这个字段,更换更老版本即可



2.更换镜像仓库

https://blog.csdn.net/weixin_44896406/article/details/120793596?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2~aggregatepage~first_rank_ecpm_v1~rank_v31_ecpm-1-120793596.pc_agg_new_rank&utm_term=k8s%E5%90%8C%E6%AD%A5%E9%95%9C%E5%83%8F&spm=1000.2123.3001.4430 
#拉取国外镜像的方法



cat deploy.yaml | grep -n image
324:          image: k8s.gcr.io/ingress-nginx/controller:v0.49.3@sha256:35fe394c82164efa8f47f3ed0be981b3f23da77175bbb8268a9ae438851c8324
325:          imagePullPolicy: IfNotPresent
588:          image: docker.io/jettech/kube-webhook-certgen:v1.5.1
589:          imagePullPolicy: IfNotPresent
638:          image: docker.io/jettech/kube-webhook-certgen:v1.5.1
639:          imagePullPolicy: IfNotPresent


#替换
324:          image: k8s.gcr.io/ingress-nginx/controller:v0.49.3@sha256:35fe394c82164efa8f47f3ed0be981b3f23da77175bbb8268a9ae438851c8324
--------------
#可以看到第324行镜像仓库是国外的,我们没办法拉取,吧他替换成registry.cn-hangzhou.aliyuncs.com/zhangzhishiu/controller:v0.49.3

 324:          image: registry.cn-hangzhou.aliyuncs.com/zhangzhishiu/controller:v0.49.3




3.安装
kubectl apply -f deploy.yaml

 

 

 

推荐阅读