如何在kops中为AWS单可用区配置单主节点?多AZ集群主节点配置问题
Hey there! I’ve helped lots of folks work through kops master node configuration issues, so let’s get yours sorted out. First, we’ll fix the extra master in us-east-1c, then cover how to deploy a single master in one AZ.
Looking at your instance group details, the master-us-east-1c group is stuck at 2 nodes—let’s adjust that to 1 to match your other AZs. Here’s how:
Step 1: Inspect the current instance group config
First, pull the full configuration for the problematic group to confirm its settings:
kops get ig master-us-east-1c -o yaml
You’ll see fields like minSize, maxSize, and subnets—we only need to tweak the size values here.
Step 2: Edit the instance group configuration
Export the config to a file so you can modify it easily:
kops get ig master-us-east-1c -o yaml > master-us-east-1c.yaml
Open the file in your editor, then update both minSize and maxSize from 2 to 1. Double-check that the subnets field still only lists us-east-1c (which it does in your current setup).
Step 3: Apply the changes to your cluster
Replace the existing instance group with your edited config:
kops replace -f master-us-east-1c.yaml
Then push the update to your cluster:
kops update cluster --yes
Step 4: Roll out the change gracefully
To ensure the cluster scales down without disruption, run a rolling update:
kops rolling-update cluster --yes
This will terminate the extra master node in us-east-1c and set the group to 1 node, matching your other AZs.
Why this works:
Kops requires the total number of master nodes to be an odd number (to prevent split-brain scenarios in high-availability setups). Your desired setup (1 master per AZ, total 3 nodes) is an odd count, which is valid—this is why kops will allow the adjustment from 2 to 1.
If you want to create a new cluster with just one master in a single AZ (ideal for testing or non-production environments), follow these steps:
Create the cluster with single master and AZ
Use the --zones flag to specify only one AZ, and --master-count 1 to set the master node count:
kops create cluster \ --name your-cluster-name.example.com \ --zones us-east-1a \ --master-count 1 \ --master-size m3.medium \ --node-size m4.xlarge \ --node-count 3
Verify the setup
After creating the cluster, check the instance groups to confirm everything is configured correctly:
kops get ig
You’ll see a single master instance group with MIN and MAX set to 1, tied exclusively to your chosen AZ.
Important Note:
A single master cluster lacks high availability—if that master node goes down, your cluster control plane will be unavailable. This setup is not recommended for production workloads.
内容的提问来源于stack exchange,提问作者Xiang Zhang

