You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

单AWS EC2 Ubuntu16.04实例部署K8s:主从节点同机可行性问询

Can I run Kubernetes master and worker nodes on a single AWS EC2 Ubuntu 16.04 instance?

Absolutely possible! Running both the Kubernetes control plane (master node) and worker node on a single EC2 instance is totally feasible, especially for development, testing, or small-scale proof-of-concept deployments like your Spring Boot microservices. Here's what you need to know:

Key Setup Steps

  • Prepare the instance:
    • First, disable swap (Kubernetes requires this to operate correctly):
      sudo swapoff -a
      sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
      
    • Ensure your Ubuntu 16.04 instance meets minimum resource requirements: at least 2 vCPUs and 2GB RAM (opt for more if you plan to run multiple Spring Boot pods alongside K8s components).
  • Install a container runtime:
    Pick a compatible runtime like Docker (stick to Docker 19.03.x or newer for Ubuntu 16.04 to avoid Kubernetes compatibility gaps) or containerd.
  • Set up Kubernetes components:
    Install kubeadm, kubelet, and kubectl following Kubernetes' official Ubuntu 16.04 installation guidelines.
  • Initialize the control plane:
    Run the initialization command (using Flannel's recommended CIDR as an example):
    kubeadm init --pod-network-cidr=10.244.0.0/16
    
    Follow the post-init instructions to configure kubectl for your user account.
  • Allow the master node to host workloads:
    Master nodes are tainted by default to prevent pod scheduling. Remove this restriction with:
    kubectl taint nodes --all node-role.kubernetes.io/master-
    
  • Deploy a pod network plugin:
    Install a plugin like Flannel or Calico to enable pod-to-pod communication. For Flannel:
    kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
    
    (You can also download this manifest locally and apply it if you prefer to avoid direct external links.)

Critical Considerations

  • Not suitable for production: A single-node cluster has no high availability. If your EC2 instance fails, your entire Kubernetes cluster (and Spring Boot services) will go offline. This setup is only recommended for non-production use cases.
  • Resource constraints: Kubernetes control plane components (apiserver, etcd, scheduler, controller-manager) will consume CPU and memory alongside your Spring Boot pods. Monitor resource usage closely to avoid performance bottlenecks.
  • Ubuntu 16.04 end-of-life: Ubuntu 16.04 reached end-of-support in April 2021. Newer Kubernetes versions may not support it, and you won't receive security updates. If possible, upgrade to Ubuntu 18.04 or later for a more stable environment.
  • Security best practices: Since the control plane and worker run on the same instance, configure your EC2 security group to only expose necessary ports (e.g., 6443 for kube-apiserver, 22 for SSH) and restrict access to trusted IPs.

For your use case—deploying a Spring Boot microservice on a single EC2 instance for learning or testing—this setup works perfectly. Just keep the above limitations in mind as you proceed.

内容的提问来源于stack exchange,提问作者Mr.DevEng

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 11:35:37