mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
libvirt-coreos: move all IP definitions in config-default.sh
This commit is contained in:
parent
93c0052263
commit
9077c23277
@ -19,3 +19,31 @@
|
||||
# Number of minions in the cluster
|
||||
NUM_MINIONS=${NUM_MINIONS:-3}
|
||||
export NUM_MINIONS
|
||||
|
||||
# The IP of the master
|
||||
export MASTER_IP="192.168.10.1"
|
||||
|
||||
export INSTANCE_PREFIX=kubernetes
|
||||
export MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||
|
||||
# Map out the IPs, names and container subnets of each minion
|
||||
export MINION_IP_BASE="192.168.10."
|
||||
MINION_CONTAINER_SUBNET_BASE="10.10"
|
||||
MASTER_CONTAINER_NETMASK="255.255.255.0"
|
||||
MASTER_CONTAINER_ADDR="${MINION_CONTAINER_SUBNET_BASE}.0.1"
|
||||
MASTER_CONTAINER_SUBNET="${MINION_CONTAINER_SUBNET_BASE}.0.1/24"
|
||||
CONTAINER_SUBNET="${MINION_CONTAINER_SUBNET_BASE}.0.0/16"
|
||||
if [[ "$NUM_MINIONS" -gt 253 ]]; then
|
||||
echo "ERROR: Because of how IPs are allocated in ${BASH_SOURCE}, you cannot create more than 253 minions"
|
||||
exit 1
|
||||
fi
|
||||
for ((i=0; i < NUM_MINIONS; i++)) do
|
||||
MINION_IPS[$i]="${MINION_IP_BASE}$((i+2))"
|
||||
MINION_NAMES[$i]="${INSTANCE_PREFIX}-minion-$((i+1))"
|
||||
MINION_CONTAINER_SUBNETS[$i]="${MINION_CONTAINER_SUBNET_BASE}.$((i+1)).1/24"
|
||||
MINION_CONTAINER_ADDRS[$i]="${MINION_CONTAINER_SUBNET_BASE}.$((i+1)).1"
|
||||
MINION_CONTAINER_NETMASKS[$i]="255.255.255.0"
|
||||
done
|
||||
MINION_CONTAINER_SUBNETS[$NUM_MINIONS]=$MASTER_CONTAINER_SUBNET
|
||||
|
||||
PORTAL_NET=10.11.0.0/16
|
||||
|
@ -16,9 +16,9 @@ write_files:
|
||||
coreos:
|
||||
etcd:
|
||||
name: ${name}
|
||||
addr: 192.168.10.$(($i+1)):4001
|
||||
addr: ${public_ip}:4001
|
||||
bind-addr: 0.0.0.0
|
||||
peer-addr: 192.168.10.$(($i+1)):7001
|
||||
peer-addr: ${public_ip}:7001
|
||||
# peers: {etcd_peers}
|
||||
discovery: ${discovery}
|
||||
units:
|
||||
@ -30,7 +30,7 @@ coreos:
|
||||
MACAddress=52:54:00:00:00:${i}
|
||||
|
||||
[Network]
|
||||
Address=192.168.10.$(($i+1))/24
|
||||
Address=${public_ip}/24
|
||||
DNS=192.168.10.254
|
||||
Gateway=192.168.10.254
|
||||
- name: cbr0.netdev
|
||||
@ -46,10 +46,10 @@ coreos:
|
||||
Name=cbr0
|
||||
|
||||
[Network]
|
||||
Address=10.10.$(($i+1)).1/24
|
||||
Address=${MINION_CONTAINER_SUBNETS[$i]}
|
||||
|
||||
[Route]
|
||||
Destination=10.10.0.0/16
|
||||
Destination=${CONTAINER_SUBNET}
|
||||
- name: cbr0-interface.network
|
||||
command: start
|
||||
content: |
|
||||
@ -66,7 +66,7 @@ coreos:
|
||||
Description=NAT non container traffic
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/sbin/iptables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE ! -d 10.10.0.0/16
|
||||
ExecStart=/usr/sbin/iptables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE ! -d ${CONTAINER_SUBNET}
|
||||
RemainAfterExit=yes
|
||||
Type=oneshot
|
||||
- name: etcd.service
|
||||
|
@ -18,7 +18,7 @@ coreos:
|
||||
--port=8080 \
|
||||
--etcd_servers=http://127.0.0.1:4001 \
|
||||
--kubelet_port=10250 \
|
||||
--portal_net=10.10.254.0/24
|
||||
--portal_net=${PORTAL_NET}
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
|
@ -15,7 +15,7 @@ coreos:
|
||||
[Service]
|
||||
ExecStart=/opt/kubernetes/bin/kubelet \
|
||||
--address=0.0.0.0 \
|
||||
--hostname_override=192.168.10.$(($i+1)) \
|
||||
--hostname_override=${MINION_IPS[$i]} \
|
||||
--etcd_servers=http://127.0.0.1:4001
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
@ -35,7 +35,7 @@ coreos:
|
||||
[Service]
|
||||
ExecStart=/opt/kubernetes/bin/kube-proxy \
|
||||
--etcd_servers=http://127.0.0.1:4001 \
|
||||
--master=http://192.168.10.1:7080
|
||||
--master=http://${MASTER_IP}:7080
|
||||
Restart=always
|
||||
RestartSec=2
|
||||
|
||||
|
@ -38,8 +38,8 @@ function join {
|
||||
|
||||
# Must ensure that the following ENV vars are set
|
||||
function detect-master {
|
||||
KUBE_MASTER_IP=192.168.10.1
|
||||
KUBE_MASTER=kubernetes-master
|
||||
KUBE_MASTER_IP=$MASTER_IP
|
||||
KUBE_MASTER=$MASTER_NAME
|
||||
export KUBERNETES_MASTER=http://$KUBE_MASTER_IP:8080
|
||||
echo "KUBE_MASTER_IP: $KUBE_MASTER_IP"
|
||||
echo "KUBE_MASTER: $KUBE_MASTER"
|
||||
@ -47,10 +47,7 @@ function detect-master {
|
||||
|
||||
# Get minion IP addresses and store in KUBE_MINION_IP_ADDRESSES[]
|
||||
function detect-minions {
|
||||
for (( i = 0 ; i < $NUM_MINIONS ; i++ )); do
|
||||
KUBE_MINION_IP_ADDRESSES[$i]=192.168.10.$(($i+2))
|
||||
done
|
||||
echo "KUBE_MINION_IP_ADDRESSES=[${KUBE_MINION_IP_ADDRESSES[@]}]"
|
||||
KUBE_MINION_IP_ADDRESSES=("${MINION_IPS[@]}")
|
||||
}
|
||||
|
||||
# Verify prereqs on host machine
|
||||
@ -161,12 +158,15 @@ function kube-up {
|
||||
|
||||
local i
|
||||
for (( i = 0 ; i <= $NUM_MINIONS ; i++ )); do
|
||||
if [[ $i -eq 0 ]]; then
|
||||
if [[ $i -eq $NUM_MINIONS ]]; then
|
||||
type=master
|
||||
name=$MASTER_NAME
|
||||
public_ip=$MASTER_IP
|
||||
else
|
||||
type=minion-$(printf "%02d" $i)
|
||||
name=${MINION_NAMES[$i]}
|
||||
public_ip=${MINION_IPS[$i]}
|
||||
fi
|
||||
name=kubernetes_$type
|
||||
image=$name.img
|
||||
config=kubernetes_config_$type
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user