查看“Kubernetes ingress基础”的源代码
←
Kubernetes ingress基础
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
Nginx ingress 使用ConfigMap来管理Nginx配置,nginx是大家熟知的代理和负载均衡软件,比起Traefik来说功能更加强大. ngress是Kubernetes集群对外暴露服务的一种推荐方法,Ingress封装了nginx,背后还是nginx在发挥作用,Ingress的作用是不断检测pod的IP变化,然后将变化更新到nginx的配置中。从而当集群中有pod重启时,可以做到不用重启nginx ==with Helm== <pre> #use helm 正常情况下如次 要FQ helm upgrade --install ingress-nginx ingress-nginx \ --repo https://kubernetes.github.io/ingress-nginx \ --namespace ingress-nginx --create-namespace Release "ingress-nginx" does not exist. Installing it now. Error: failed to download "https://github.com/kubernetes/ingress-nginx/releases/download/helm-chart-4.1.4/ingress-nginx-4.1.4.tgz" </pre> [https://www.cnblogs.com/syushin/p/15271304.html 使用Helm3.6 安装 Ingress-nginx ] ==install(现在用kuboard 2022)== ===部署Ingress 控制器=== https://kubernetes.github.io/ingress-nginx/deploy/ <pre> #2022 root@k8s-master:~# kubectl apply -f deploy.yaml namespace/ingress-nginx created serviceaccount/ingress-nginx created serviceaccount/ingress-nginx-admission created role.rbac.authorization.k8s.io/ingress-nginx created role.rbac.authorization.k8s.io/ingress-nginx-admission created clusterrole.rbac.authorization.k8s.io/ingress-nginx created clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created rolebinding.rbac.authorization.k8s.io/ingress-nginx created rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created configmap/ingress-nginx-controller created service/ingress-nginx-controller created service/ingress-nginx-controller-admission created deployment.apps/ingress-nginx-controller created job.batch/ingress-nginx-admission-create created job.batch/ingress-nginx-admission-patch created ingressclass.networking.k8s.io/nginx created validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created root@k8s-master:~# kubectl create deployment demo --image=httpd --port=80 deployment.apps/demo created root@k8s-master:~# kubectl expose deployment demo service/demo exposed root@k8s-master:~# kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx --watch NAMESPACE NAME READY STATUS RESTARTS AGE ingress-nginx ingress-nginx-admission-create-5jc9p 0/1 ImagePullBackOff 0 2m47s ingress-nginx ingress-nginx-admission-patch-2mb45 0/1 ImagePullBackOff 0 2m47s ingress-nginx ingress-nginx-controller-55dcf56b68-gpckf 0/1 ContainerCreating 0 2m47s ingress-nginx ingress-nginx-admission-create-5jc9p 0/1 ErrImagePull 0 2m47s ingress-nginx ingress-nginx-admission-create-5jc9p 0/1 ImagePullBackOff 0 3m #FQ吧 少年 以前的 2019年的 wget -c https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml kubectl apply -f mandatory.yaml namespace/ingress-nginx configured configmap/nginx-configuration unchanged configmap/tcp-services created configmap/udp-services created serviceaccount/nginx-ingress-serviceaccount unchanged clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole configured role.rbac.authorization.k8s.io/nginx-ingress-role unchanged rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding unchanged clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding unchanged deployment.apps/nginx-ingress-controller configured Verify installation To check if the ingress controller pods have started, kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx --watch NAMESPACE NAME READY STATUS RESTARTS AGE ingress-nginx nginx-ingress-controller-86449c74bb-rthhw 0/1 ImagePullBackOff 0 2m5s kubectl get pods -n ingress-nginx -o wide --watch #也是查看 Once the operator pods are running, you can cancel the above command by typing Ctrl+C. 可见上面还不是runing 过一阵才好 kubectl get pods -n ingress-nginx NAME READY STATUS RESTARTS AGE nginx-ingress-controller-86449c74bb-rthhw 1/1 Running 0 19h </pre> ===部署svc=== <pre> kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/cloud-generic.yaml service/ingress-nginx created [root@master ingress]# kubectl get svc -n ingress-nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE ingress-nginx LoadBalancer 10.99.141.156 <pending> 80:31279/TCP,443:30847/TCP 2m43s </pre> =trouble= <pre> kubectl get ing #ADDRESS 为空 NAME HOSTS ADDRESS PORTS AGE simple * 80 4s </pre> =usage= == 最简单的使用例子== <pre> </pre> === files=== <pre> cat /root/apple-deployment-and-service.yaml kind: Deployment apiVersion: apps/v1 metadata: name: apple spec: selector: matchLabels: app: apple replicas: 2 template: metadata: labels: app: apple spec: containers: - name: apple image: jxlwqq/http-echo args: - "--text=apple" ports: - containerPort: 8080 --- kind: Service apiVersion: v1 metadata: name: apple-svc spec: selector: app: apple ports: - port: 8080 targetPort: 8080 cat /root/banana-deployment-and-service.yaml kind: Deployment apiVersion: apps/v1 metadata: name: banana spec: selector: matchLabels: app: banana replicas: 2 template: metadata: labels: app: banana spec: containers: - name: banana image: jxlwqq/http-echo args: - "--text=banana" ports: - containerPort: 8080 --- kind: Service apiVersion: v1 metadata: name: banana-svc spec: selector: app: banana ports: - port: 8080 targetPort: 8080 cat /root/ingress.yml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: fruit-ing annotations: nginx.ingress.kubernetes.io/rewrite-target: / spec: rules: - host: aa.com http: paths: - path: /apple pathType: Prefix backend: service: name: apple-svc port: number: 8080 - path: /banana pathType: Prefix backend: service: name: banana-svc port: number: 8080 ingressClassName: nginx </pre> === test=== <pre> cat /etc/hosts | grep aa.com 192.168.10.82 aa.com ➜ ~ </pre> == 简单的使用例子 old== ===** 创建一个空间 === <pre> cat testing-namespace.yaml kind: Namespace apiVersion: v1 metadata: name: testing labels: env: testing </pre> ===** 创建 tomcat-deploy === <pre> cat tomcat-deploy.yaml apiVersion: apps/v1 kind: Deployment metadata: name: tomcat-deploy namespace: testing spec: replicas: 2 selector: matchLabels: app: tomcat template: metadata: labels: app: tomcat spec: containers: - name: tomcat image: tomcat:8.0.50-jre8-alpine ports: - containerPort: 8080 name: httpport - containerPort: 8009 name: ajpport </pre> ===** 创建 tomcat svc === <pre> cat tomcat-svc.yaml apiVersion: v1 kind: Service metadata: name: tomcat-svc namespace: testing labels: app: tomcat-svc spec: selector: app: tomcat ports: - name: httpport port: 80 targetPort: 8080 protocol: TCP </pre> === ** 创建 tomcat-ingress=== <pre> #前提 先在 kuboard 先创建个ingress 叫 tt cat tomcat-ingress.yaml apiVersion: extensions/v1beta1 kind: Ingress metadata: name: tomcat namespace: testing annotations: kubernetes.io/ingress.class: "tt" #kubernetes.io/ingress.class: "nginx" spec: rules: - host: tt.com #- host: tomcat.ikubernetes.io http: paths: - path: backend: serviceName: tomcat-svc servicePort: 80 </pre> ===** visa=== host master ip http://tt.com:32136/ =ingress https= =see also= [https://blog.csdn.net/Azj12345/article/details/118862247 k8s集群中部署tomcat,访问方式使用Ingress,高可用 和NodePort方式] [https://kubernetes.github.io/ingress-nginx/deploy/ 官方文档] [https://blog.csdn.net/java_zyq/article/details/82179107 从零开始搭建K8S--搭建K8S Ingress] [https://www.jianshu.com/p/1ef0bb822fcc Nginx Ingress TCP代理实现] [https://www.cnblogs.com/evescn/p/12484975.html k8s ingress及ingress controller] [https://help.aliyun.com/document_detail/86533.html?spm=5176.2020520165.119.d86533.2d357029XalTRt aliyun Ingress 支持] [https://help.aliyun.com/document_detail/86536.html?spm=5176.2020520165.119.d86536.2d357029XalTRt aliyun通过界面创建路由(Ingress)] [https://www.cnblogs.com/klvchen/p/9903480.html K8S 部署 ingress-nginx (一) 原理及搭建] [https://blog.csdn.net/java_zyq/article/details/82496842 k8s安装traefik作为ingress] [https://my.oschina.net/u/2306127/blog/1793287 通过helm Nginx ingress安装] [https://blog.csdn.net/cpongo1/article/details/89543014 解决kubernetes中ingress-nginx配置问题] [https://blog.csdn.net/qingyafan/article/details/82692509 Kubernetes - nginx-ingress 配置跳坑指南] [https://blog.csdn.net/liyingke112/article/details/77069593 为什么我不使用Kubernetes的Ingress] [https://blog.csdn.net/newcrane/article/details/79092577 kubernetes中服务的暴露访问方式kubernetes ingress使用] [https://blog.csdn.net/java_zyq/article/details/82179107 搭建K8S Ingress安装部分已老] [[category:k8s]]
返回至
Kubernetes ingress基础
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
我的导航
关于我
shell
python
ops
linuxchina.net
blog.linuxchina
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息