k8s配置Ingress访问,此处以prometheus为例
#直接安装必须执行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/kub...
·
#直接安装必须执行
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
更多推荐
所有评论(0)