Kubernetes - 使用Ingress、Ingress控制器(Ingress Controller)转发请求

 

 

 

 

# 安装Kubernetes ingress-nginx

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml

 

apiVersion: v1
kind: Service
metadata:
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  name: ingress-nginx
  namespace: ingress-nginx
spec:
  externalTrafficPolicy: Cluster
  ports:
  - port: 30001
    protocol: TCP
    targetPort: 30001
    name: http
    nodePort: 30001
#  - port: 443
#    protocol: TCP
#    targetPort: 443
#    name: https
#    nodePort: 30003
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
  type: LoadBalancer

  

vim service-loadbalancer.yaml

kubectl create -f service-loadbalancer.yaml

kubectl get svc -n ingress-nginx

 

 

 

posted @ 2021-10-05 14:25  year12  阅读(86)  评论(0编辑  收藏  举报