k8s ingress-nginx 0.25.1 最新版部署和例子
admin
2023-02-03 00:40:04
0

k8s ingress-nginx 0.25.1 最新版部署和例子

说明

https://github.com/kubernetes/ingress-nginx/blob/master/docs/deploy/index.md

增加了7层的识别能力,可以根据 http header, path 等进行路由转发

部署

wget  https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml

sed -i 's#quay.io/kubernetes-ingress-controller/nginx-ingress-controller#registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller#g' mandatory.yaml

cat service-nodeport.yaml
apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  type: NodePort
  ports:
    - name: http
      port: 80
      targetPort: 80
      protocol: TCP
      nodePort: 32080  #http
    - name: https
      port: 443
      targetPort: 443
      protocol: TCP
      nodePort: 32443  #https
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
kubectl create -f  mandatory.yaml
kubectl create -f  service-nodeport.yaml

检查

kubectl get pod -n ingress-nginx -o wide

kubectl scale --replicas=2  deploy/nginx-ingress-controller -n ingress-nginx

例子

vim  deploy-demo.yaml
apiVersion: v1
kind: Service
metadata:
  name: myapp
  namespace: default
spec:
  selector:
    app: myapp
    release: stable
  ports:
  - name: myapp
    port: 80
    targetPort: 80
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
  namespace: default
spec:
  selector:
    matchLabels:
      app: myapp
      release: stable
   replicas: 3
   template:
     metadata:
       labels:
         app: myapp
         release: stable
      spec:
        containers:
        - name: myapp
          image: nginx
          imagePullPolicy: IfNotPresent
        ports:
        - name: myapp
      containerPort: 80

vim  ingress-myapp.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-myapp
namespace: default
annotations:
   kubernetes.io/ingress.class: "nginx"
spec:
  rules:
  - host: httpd.hequan.com
    http:
     paths:
     - path:
       backend:
        serviceName: myapp
        servicePort: 80

kubectl create -f  deploy-demo.yaml
kubectl create -f  ingress-myapp.yaml

 
#修改hosts   node节点ip
192.168.100.112   httpd.hequan.com  

访问 httpd.hequan.com:32080

相关内容

热门资讯

共商汽车产业全球合作新路径 G... 当前,汽车产业正加速向绿色化、智能化、国际化、融合化发展,汽车供应链受到大国竞争与地缘政治冲突扰动。...
内蒙古耕种收综合机械化率达91... 7月22日,记者从2026年中国农机推广田间日活动上获悉,内蒙古农作物耕种收综合机械化率达到91%,...
华为黄健:在算力、存力和运力三... 7月17日至20日,以“智能伙伴,共创未来”为主题的2026世界人工智能大会(WAIC)暨人工智能全...
苹果、谷歌都没留住月之暗面创始... 英国《金融时报》7月23日刊发评论《为什么美国正在失去中国人工智能明星?》,文章谈到,月之暗面(Mo...
陪伴大家十几年的充电宝,大概要... 要说这两年最尴尬的数码配件,托尼觉得充电宝绝对算一个。 以前它的对手还都是同行 —— 大家一起卷容量...
女子举报遭公安局一副支队长猥亵... 记者 商泽阳近日,安徽的薛女士向潮新闻记者反映,称其于2025年4月遭到时任亳州市公安局经侦支队副支...
邹市明妻子冉莹颖回应“债还完了... 2026年7月22日,综艺《姐姐当家2》播出的内容中,张泉灵就冉莹颖的婚姻状况提出犀利问题,引发关注...
美方指控中国人工智能企业抄袭,... 据凤凰卫视报道,美国白宫科技政策办公室主任克拉齐奥斯7月22日指控中国人工智能企业月之暗面在开发最新...
广西一公园大树倾倒3人身亡 近日,广西一公园大树倾倒,造成人员伤亡,引发关注。7月23日,玉林市博白县人民政府办公室工作人员对中...
父母用特训机构“执行家法”后:... 周雅和教官一起,撬开21岁女儿住处的猫眼和门锁,然后她送到特训机构。她希望以此改变女儿“错误”的择偶...