参考官网https://kubernetes.github.io/ingress-nginx/ 部署pod:nginx-ingress-controller/nginx-default-backend
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
配置修改:
1. 取消转发body限制:
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-configuration
namespace: ingress-nginx
labels:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
data:
proxy-body-size: "0" k8s裸机部署bare-metal(nodeport方式):
部署service
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/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:
ports:
- name: http
port: 8083
targetPort: 80
protocol: TCP
- name: https
port: 8084
targetPort: 443
protocol: TCP
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/part-of: ingress-nginx
externalIPs:
- "{portal_host}" Note:保证镜像能正常下载 部署Ingress(前提:game2048-pod/service已经部署完毕)
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: game-ingress
namespace: default
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- http:
paths:
- path: /game
backend:
serviceName: game2048
servicePort: 7090 验证:
curl http://external_ip:port/game
response正常 参考资料:
官方部署文档
https://kubernetes.github.io/ingress-nginx/
部署流程示例
https://blog.csdn.net/aixiaoyang168/article/details/78485581
暴露服务的几种方式:
https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0