1. 创建集群 (跳过不介绍)
2. 创建Ingress-Nginx服务
部署项目地址【点我跳转】
推荐自定义部署
可绑定acm证书什么的自己属性
对应集群版本推荐阵列
https://github.com/kubernetes/ingress-nginx
修改下面的下载文件版本
- Download the deploy.yaml template
wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.0/deploy/static/provider/aws/nlb-with-tls-termination/deploy.yaml
- Edit the file and change the VPC CIDR in use for the Kubernetes cluster:
proxy-real-ip-cidr: XXX.XXX.XXX/XX ##对应的eks vpc的地址池
- Change the AWS Certificate Manager (ACM) ID as well:
arn:aws:acm:us-west-2:XXXXXXXX:certificate/XXXXXX-XXXXXXX-XXXXXXX-XXXXXXXX ##对应的acm arn
Deploy the manifest:
- 部署
kubectl apply -f deploy.yaml
对应的acm资源,提前创建好 方便我们一会直接使用
等待资源拉起
控制台 查看对应的资源
3. 部署测试应用暴露服务
app.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: nginx-demoname: nginx-demo
spec:replicas: 1selector:matchLabels:app: nginx-demotemplate:metadata:labels:app: nginx-demospec:containers:- image: nginxname: nginx
---
apiVersion: v1
kind: Service
metadata:labels:app: nginx-demoname: nginx-demo
spec:selector:app: nginx-demoports:- port: 8000protocol: TCPtargetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:annotations:#nginx.ingress.kubernetes.io/rewrite-target: /$2name: ingress-host-bar
spec:ingressClassName: nginxrules:- http:paths:- pathType: Prefixpath: "/"backend:service:name: nginx-demoport:number: 8000
kubectl apply -f app.yaml
kubectl get ing
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress-host-bar nginx * aaec1a50e5cbd457c8430f541a93cb32-dfcb5f2162042976.elb.ap-northeast-1.amazonaws.com 80 3m30s
访问正常 说明部署ingress-nginx成功