#直接安装必须执行
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml
#下面这个是nodeip类型的()
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml
#或者下载好存留
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/provider/baremetal/service-nodeport.yaml

在安装ingress之前,需要先编辑mandatory.yaml文件,把里面的kind类型更改为demoset,然后在吧replicas注释掉,如图:以保证每个node节点运行ingress
在这里插入图片描述

查看ingress-nginx 的POD运行 动情况在这里插入图片描述

kubectl apply -f mandatory.yaml
kubectl apply -f service-nodeport.yaml

查看svc状态
在这里插入图片描述
创建ingress

cat << EOF | tee ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: monitoring
  name: prometheus-ingress
spec:
  rules:
  - host: k8s.grafana.com
    http:
      paths:
      - backend:
          serviceName: grafana
          servicePort: 3000
  - host: k8s.prometheus.com
    http:
      paths:
      - backend:
          serviceName: prometheus-k8s
          servicePort: 9090
  - host: k8s.alertmanager.com
    http:
      paths:
      - backend:
          serviceName: alertmanager-main
          servicePort: 9093
EOF
kubectl apply -f ingress.yaml

查看ingress

kubectl get ingress -n monitoring

在这里插入图片描述
访问主机添加host

在这里插入图片描述

Logo

开源、云原生的融合云平台

更多推荐