Interested in setting up K8s cluster on EC2 instance with Minikube & domain name

戏子无情 提交于 2020-07-10 10:28:16

问题


I have an EC2 instance that I use for personal work & projects with very small amounts of traffic (portfolio, etc).

I thought it'd be really cool (although obviously overkill) to set up a dev cluster running my various projects using Minikube and to connect a domain name to this instance.

Setup

I have an Ingress controller that points to my service, with an IP address that is different than the host machine. I think it's somehow the IP address of the VM, but only accessible from the host machine.

I'd really like to use Ingress because I have a number of projects running with different domain names in use. Seems like the simple & correct solution based on my limited knowledge.

Problem

Not knowing much about k8s/networking, I don't know how to get external traffic visiting the elastic IP assigned to my instance to be directed to the Ingress controller

What I've tried

I was thinking that, since this is really only going to be used for dev purposes, that I could try using kubect port-forward ... somehow to point to my Ingress controller. But this port-forward reference from the official website says nothing about Ingress controllers.

Question

What is the most correct way to get external traffic into my cluster via an Ingress controller?


回答1:


Assuming this is not for real production workload I would suggest below approach

  1. Instead of using minikube use kubeadm to install a single node kubernetes cluster on the EC2 instance.

  2. Make sure to remove the master node taint so that workload pods can be scheduled on the master node meaning the same EC2 instance will host control plane pods as well as workload pods. Command for that is

    kubectl taint nodes nodename node-role.kubernetes.io/master:NoSchedule-

  3. Install nginx ingress controller and use hostNetwork: true in the deployment yaml. So nginx will listen to the EC2 instance's network on port 80 and 443. Here is the doc on this.

  4. Create ingress resource and you can access any service via EC2 instances public IP address.

  5. When you have budget for more EC2 instance you can add those as worker nodes to the cluster using kubeadm join.

Note: You can use free t2.micro which is tier EC2 instance as worker nodes.



来源:https://stackoverflow.com/questions/62642774/interested-in-setting-up-k8s-cluster-on-ec2-instance-with-minikube-domain-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!