If we only have one service, we can easily add an A record in the domain in AWS Route 53.
But it will be a pain when we have a lot more of them, because we would have to create a lot of A records to route traffix to each of the services.
A better solution in this case will be to use Ingress, which will allow us setup A record only once but can define multiple rules in the configuration file to route traffic to different services.
To use Ingress, first change the service type from LoadBalancer to ClusterIP, or delete the type:
apiVersion: v1 kind: Service metadata: name: zimple-bank-api-service spec: selector: app: zimple-bank-api ports: - protocol: TCP port: 80 # on which the server will listen to incoming request targetPort: 8080 # port of the container where the request will be sent to type: ClusterIP
Next, install the Ingress controller: https://kubernetes.github.io/ingress-nginx/deploy/#aws
Next, create ingress.yaml and apply it:
apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: zimple-bank-ingress spec: ingressClassName: nginx rules: - host: "api.zimple-bank.com" http: paths: - pathType: Prefix path: "/" backend: service: name: zimple-bank-api-service port: number: 80
Next, copy the address and paste it in the A record for the host domain:
Finally, add IngressClass in the ingress.yaml:
apiVersion: networking.k8s.io/v1 kind: IngressClass metadata: name: nginx spec: controller: k8s.io/ingress-nginx --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: zimple-bank-ingress spec: ingressClassName: nginx rules: - host: "api.zimple-bank.com" http: paths: - pathType: Prefix path: "/" backend: service: name: zimple-bank-api-service port: number: 80
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律