mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
Minion->Name rename: cluster/vagrant, docs and Vagrantfile
This commit is contained in:
parent
224aebd2be
commit
88e6cac544
32
Vagrantfile
vendored
32
Vagrantfile
vendored
@ -17,13 +17,13 @@ Calling 'vagrant up' directly is not supported. Instead, please run the followi
|
|||||||
END
|
END
|
||||||
end
|
end
|
||||||
|
|
||||||
# The number of minions to provision
|
# The number of nodes to provision
|
||||||
$num_minion = (ENV['NUM_NODES'] || 1).to_i
|
$num_node = (ENV['NUM_NODES'] || 1).to_i
|
||||||
|
|
||||||
# ip configuration
|
# ip configuration
|
||||||
$master_ip = ENV['MASTER_IP']
|
$master_ip = ENV['MASTER_IP']
|
||||||
$minion_ip_base = ENV['NODE_IP_BASE'] || ""
|
$node_ip_base = ENV['NODE_IP_BASE'] || ""
|
||||||
$minion_ips = $num_minion.times.collect { |n| $minion_ip_base + "#{n+3}" }
|
$node_ips = $num_node.times.collect { |n| $node_ip_base + "#{n+3}" }
|
||||||
|
|
||||||
# Determine the OS platform to use
|
# Determine the OS platform to use
|
||||||
$kube_os = ENV['KUBERNETES_OS'] || "fedora"
|
$kube_os = ENV['KUBERNETES_OS'] || "fedora"
|
||||||
@ -105,7 +105,7 @@ end
|
|||||||
# When doing Salt provisioning, we copy approximately 200MB of content in /tmp before anything else happens.
|
# When doing Salt provisioning, we copy approximately 200MB of content in /tmp before anything else happens.
|
||||||
# This causes problems if anything else was in /tmp or the other directories that are bound to tmpfs device (i.e /run, etc.)
|
# This causes problems if anything else was in /tmp or the other directories that are bound to tmpfs device (i.e /run, etc.)
|
||||||
$vm_master_mem = (ENV['KUBERNETES_MASTER_MEMORY'] || ENV['KUBERNETES_MEMORY'] || 1280).to_i
|
$vm_master_mem = (ENV['KUBERNETES_MASTER_MEMORY'] || ENV['KUBERNETES_MEMORY'] || 1280).to_i
|
||||||
$vm_minion_mem = (ENV['KUBERNETES_NODE_MEMORY'] || ENV['KUBERNETES_MEMORY'] || 1024).to_i
|
$vm_node_mem = (ENV['KUBERNETES_NODE_MEMORY'] || ENV['KUBERNETES_MEMORY'] || 1024).to_i
|
||||||
|
|
||||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
def setvmboxandurl(config, provider)
|
def setvmboxandurl(config, provider)
|
||||||
@ -221,21 +221,21 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|||||||
c.vm.network "private_network", ip: "#{$master_ip}"
|
c.vm.network "private_network", ip: "#{$master_ip}"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Kubernetes minion
|
# Kubernetes node
|
||||||
$num_minion.times do |n|
|
$num_node.times do |n|
|
||||||
minion_vm_name = "minion-#{n+1}"
|
node_vm_name = "node-#{n+1}"
|
||||||
minion_prefix = ENV['INSTANCE_PREFIX'] || 'kubernetes' # must mirror default in cluster/vagrant/config-default.sh
|
node_prefix = ENV['INSTANCE_PREFIX'] || 'kubernetes' # must mirror default in cluster/vagrant/config-default.sh
|
||||||
minion_hostname = "#{minion_prefix}-#{minion_vm_name}"
|
node_hostname = "#{node_prefix}-#{node_vm_name}"
|
||||||
|
|
||||||
config.vm.define minion_vm_name do |minion|
|
config.vm.define node_vm_name do |node|
|
||||||
customize_vm minion, $vm_minion_mem
|
customize_vm node, $vm_node_mem
|
||||||
|
|
||||||
minion_ip = $minion_ips[n]
|
node_ip = $node_ips[n]
|
||||||
if ENV['KUBE_TEMP'] then
|
if ENV['KUBE_TEMP'] then
|
||||||
script = "#{ENV['KUBE_TEMP']}/minion-start-#{n}.sh"
|
script = "#{ENV['KUBE_TEMP']}/node-start-#{n}.sh"
|
||||||
minion.vm.provision "shell", run: "always", path: script
|
node.vm.provision "shell", run: "always", path: script
|
||||||
end
|
end
|
||||||
minion.vm.network "private_network", ip: "#{minion_ip}"
|
node.vm.network "private_network", ip: "#{node_ip}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,6 +10,6 @@ This is a work-in-progress; not all options are documented yet!
|
|||||||
|
|
||||||
**NUM_NODES**
|
**NUM_NODES**
|
||||||
|
|
||||||
The number of minion instances to create. Most providers default this to 4.
|
The number of node instances to create. Most providers default this to 4.
|
||||||
|
|
||||||
[]()
|
[]()
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
## Contains configuration values for interacting with the Vagrant cluster
|
## Contains configuration values for interacting with the Vagrant cluster
|
||||||
|
|
||||||
# Number of minions in the cluster
|
# Number of nodes in the cluster
|
||||||
NUM_NODES=${NUM_NODES-"1"}
|
NUM_NODES=${NUM_NODES-"1"}
|
||||||
export NUM_NODES
|
export NUM_NODES
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ export MASTER_NAME="${INSTANCE_PREFIX}-master"
|
|||||||
# Should the master serve as a node
|
# Should the master serve as a node
|
||||||
REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-false}
|
REGISTER_MASTER_KUBELET=${REGISTER_MASTER:-false}
|
||||||
|
|
||||||
# Map out the IPs, names and container subnets of each minion
|
# Map out the IPs, names and container subnets of each node
|
||||||
export NODE_IP_BASE=${NODE_IP_BASE-"10.245.1."}
|
export NODE_IP_BASE=${NODE_IP_BASE-"10.245.1."}
|
||||||
NODE_CONTAINER_SUBNET_BASE="10.246"
|
NODE_CONTAINER_SUBNET_BASE="10.246"
|
||||||
MASTER_CONTAINER_NETMASK="255.255.255.0"
|
MASTER_CONTAINER_NETMASK="255.255.255.0"
|
||||||
@ -39,11 +39,11 @@ MASTER_CONTAINER_SUBNET="${NODE_CONTAINER_SUBNET_BASE}.0.1/24"
|
|||||||
CONTAINER_SUBNET="${NODE_CONTAINER_SUBNET_BASE}.0.0/16"
|
CONTAINER_SUBNET="${NODE_CONTAINER_SUBNET_BASE}.0.0/16"
|
||||||
for ((i=0; i < NUM_NODES; i++)) do
|
for ((i=0; i < NUM_NODES; i++)) do
|
||||||
NODE_IPS[$i]="${NODE_IP_BASE}$((i+3))"
|
NODE_IPS[$i]="${NODE_IP_BASE}$((i+3))"
|
||||||
NODE_NAMES[$i]="${INSTANCE_PREFIX}-minion-$((i+1))"
|
NODE_NAMES[$i]="${INSTANCE_PREFIX}-node-$((i+1))"
|
||||||
NODE_CONTAINER_SUBNETS[$i]="${NODE_CONTAINER_SUBNET_BASE}.$((i+1)).1/24"
|
NODE_CONTAINER_SUBNETS[$i]="${NODE_CONTAINER_SUBNET_BASE}.$((i+1)).1/24"
|
||||||
NODE_CONTAINER_ADDRS[$i]="${NODE_CONTAINER_SUBNET_BASE}.$((i+1)).1"
|
NODE_CONTAINER_ADDRS[$i]="${NODE_CONTAINER_SUBNET_BASE}.$((i+1)).1"
|
||||||
NODE_CONTAINER_NETMASKS[$i]="255.255.255.0"
|
NODE_CONTAINER_NETMASKS[$i]="255.255.255.0"
|
||||||
VAGRANT_NODE_NAMES[$i]="minion-$((i+1))"
|
VAGRANT_NODE_NAMES[$i]="node-$((i+1))"
|
||||||
done
|
done
|
||||||
|
|
||||||
SERVICE_CLUSTER_IP_RANGE=10.247.0.0/16 # formerly PORTAL_NET
|
SERVICE_CLUSTER_IP_RANGE=10.247.0.0/16 # formerly PORTAL_NET
|
||||||
|
@ -58,46 +58,46 @@ cd "${KUBE_ROOT}"
|
|||||||
|
|
||||||
echo All verbose output will be redirected to $logfile, use --logfile option to change.
|
echo All verbose output will be redirected to $logfile, use --logfile option to change.
|
||||||
|
|
||||||
printf "Start the cluster with 2 minions .. "
|
printf "Start the cluster with 2 nodes .. "
|
||||||
export NUM_NODES=2
|
export NUM_NODES=2
|
||||||
export KUBERNETES_PROVIDER=vagrant
|
export KUBERNETES_PROVIDER=vagrant
|
||||||
|
|
||||||
(cluster/kube-up.sh >>"$logfile" 2>&1) || true
|
(cluster/kube-up.sh >>"$logfile" 2>&1) || true
|
||||||
echoOK $?
|
echoOK $?
|
||||||
|
|
||||||
printf "Check if minion-1 can reach kubernetes master .. "
|
printf "Check if node-1 can reach kubernetes master .. "
|
||||||
vagrant ssh minion-1 -- ping -c 10 kubernetes-master >>"$logfile" 2>&1
|
vagrant ssh node-1 -- ping -c 10 kubernetes-master >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
printf "Check if minion-2 can reach kubernetes master .. "
|
printf "Check if node-2 can reach kubernetes master .. "
|
||||||
vagrant ssh minion-2 -- ping -c 10 kubernetes-master >>"$logfile" 2>&1
|
vagrant ssh node-2 -- ping -c 10 kubernetes-master >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
|
|
||||||
printf "Pull an image that runs a web server on minion-1 .. "
|
printf "Pull an image that runs a web server on node-1 .. "
|
||||||
vagrant ssh minion-1 -- 'sudo docker pull kubernetes/serve_hostname' >>"$logfile" 2>&1
|
vagrant ssh node-1 -- 'sudo docker pull kubernetes/serve_hostname' >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
printf "Pull an image that runs a web server on minion-2 .. "
|
printf "Pull an image that runs a web server on node-2 .. "
|
||||||
vagrant ssh minion-2 -- 'sudo docker pull kubernetes/serve_hostname' >>"$logfile" 2>&1
|
vagrant ssh node-2 -- 'sudo docker pull kubernetes/serve_hostname' >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
|
|
||||||
printf "Run the server on minion-1 .. "
|
printf "Run the server on node-1 .. "
|
||||||
vagrant ssh minion-1 -- sudo docker run -d kubernetes/serve_hostname >>"$logfile" 2>&1
|
vagrant ssh node-1 -- sudo docker run -d kubernetes/serve_hostname >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
printf "Run the server on minion-2 .. "
|
printf "Run the server on node-2 .. "
|
||||||
vagrant ssh minion-2 -- sudo docker run -d kubernetes/serve_hostname >>"$logfile" 2>&1
|
vagrant ssh node-2 -- sudo docker run -d kubernetes/serve_hostname >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
|
|
||||||
printf "Run ping from minion-1 to docker bridges and to the containers on both minions .. "
|
printf "Run ping from node-1 to docker bridges and to the containers on both nodes .. "
|
||||||
vagrant ssh minion-1 -- 'ping -c 20 10.246.0.1 && ping -c 20 10.246.1.1 && ping -c 20 10.246.0.2 && ping -c 20 10.246.1.2' >>"$logfile" 2>&1
|
vagrant ssh node-1 -- 'ping -c 20 10.246.0.1 && ping -c 20 10.246.1.1 && ping -c 20 10.246.0.2 && ping -c 20 10.246.1.2' >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
printf "Same pinch from minion-2 .. "
|
printf "Same pinch from node-2 .. "
|
||||||
vagrant ssh minion-2 -- 'ping -c 20 10.246.0.1 && ping -c 20 10.246.1.1 && ping -c 20 10.246.0.2 && ping -c 20 10.246.1.2' >>"$logfile" 2>&1
|
vagrant ssh node-2 -- 'ping -c 20 10.246.0.1 && ping -c 20 10.246.1.1 && ping -c 20 10.246.0.2 && ping -c 20 10.246.1.2' >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
|
|
||||||
printf "tcp check, curl to both the running webservers from minion-1 .. "
|
printf "tcp check, curl to both the running webservers from node-1 .. "
|
||||||
vagrant ssh minion-1 -- 'curl -sS 10.246.0.2:9376 && curl -sS 10.246.1.2:9376' >>"$logfile" 2>&1
|
vagrant ssh node-1 -- 'curl -sS 10.246.0.2:9376 && curl -sS 10.246.1.2:9376' >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
printf "tcp check, curl to both the running webservers from minion-2 .. "
|
printf "tcp check, curl to both the running webservers from node-2 .. "
|
||||||
vagrant ssh minion-2 -- 'curl -sS 10.246.0.2:9376 && curl -sS 10.246.1.2:9376' >>"$logfile" 2>&1
|
vagrant ssh node-2 -- 'curl -sS 10.246.0.2:9376 && curl -sS 10.246.1.2:9376' >>"$logfile" 2>&1
|
||||||
echoOK $?
|
echoOK $?
|
||||||
|
|
||||||
printf "All good, destroy the cluster .. "
|
printf "All good, destroy the cluster .. "
|
||||||
|
@ -48,13 +48,13 @@ function release_not_found() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Setup hosts file to support ping by hostname to each minion in the cluster from apiserver
|
# Setup hosts file to support ping by hostname to each node in the cluster from apiserver
|
||||||
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
||||||
minion=${NODE_NAMES[$i]}
|
node=${NODE_NAMES[$i]}
|
||||||
ip=${NODE_IPS[$i]}
|
ip=${NODE_IPS[$i]}
|
||||||
if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
|
if [ ! "$(cat /etc/hosts | grep $node)" ]; then
|
||||||
echo "Adding $minion to hosts file"
|
echo "Adding $node to hosts file"
|
||||||
echo "$ip $minion" >> /etc/hosts
|
echo "$ip $node" >> /etc/hosts
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "127.0.0.1 localhost" >> /etc/hosts # enables cmds like 'kubectl get pods' on master.
|
echo "127.0.0.1 localhost" >> /etc/hosts # enables cmds like 'kubectl get pods' on master.
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# provision-network-minion configures flannel on the minion
|
# provision-network-node configures flannel on the node
|
||||||
function provision-network-minion {
|
function provision-network-node {
|
||||||
|
|
||||||
echo "Provisioning network on minion"
|
echo "Provisioning network on node"
|
||||||
|
|
||||||
FLANNEL_ETCD_URL="http://${MASTER_IP}:4379"
|
FLANNEL_ETCD_URL="http://${MASTER_IP}:4379"
|
||||||
|
|
@ -46,18 +46,18 @@ if [ ! "$(cat /etc/hosts | grep $MASTER_NAME)" ]; then
|
|||||||
fi
|
fi
|
||||||
echo "$NODE_IP $NODE_NAME" >> /etc/hosts
|
echo "$NODE_IP $NODE_NAME" >> /etc/hosts
|
||||||
|
|
||||||
# Setup hosts file to support ping by hostname to each minion in the cluster
|
# Setup hosts file to support ping by hostname to each node in the cluster
|
||||||
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
||||||
minion=${NODE_NAMES[$i]}
|
node=${NODE_NAMES[$i]}
|
||||||
ip=${NODE_IPS[$i]}
|
ip=${NODE_IPS[$i]}
|
||||||
if [ ! "$(cat /etc/hosts | grep $minion)" ]; then
|
if [ ! "$(cat /etc/hosts | grep $node)" ]; then
|
||||||
echo "Adding $minion to hosts file"
|
echo "Adding $node to hosts file"
|
||||||
echo "$ip $minion" >> /etc/hosts
|
echo "$ip $node" >> /etc/hosts
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Configure network
|
# Configure network
|
||||||
provision-network-minion
|
provision-network-node
|
||||||
|
|
||||||
write-salt-config kubernetes-pool
|
write-salt-config kubernetes-pool
|
||||||
|
|
@ -25,7 +25,7 @@ function detect-master () {
|
|||||||
echo "KUBE_MASTER_IP: ${KUBE_MASTER_IP}" 1>&2
|
echo "KUBE_MASTER_IP: ${KUBE_MASTER_IP}" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get minion IP addresses and store in KUBE_NODE_IP_ADDRESSES[]
|
# Get node IP addresses and store in KUBE_NODE_IP_ADDRESSES[]
|
||||||
function detect-nodes {
|
function detect-nodes {
|
||||||
echo "Nodes already detected" 1>&2
|
echo "Nodes already detected" 1>&2
|
||||||
KUBE_NODE_IP_ADDRESSES=("${NODE_IPS[@]}")
|
KUBE_NODE_IP_ADDRESSES=("${NODE_IPS[@]}")
|
||||||
@ -114,7 +114,7 @@ function ensure-temp-dir {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a set of provision scripts for the master and each of the minions
|
# Create a set of provision scripts for the master and each of the nodes
|
||||||
function create-provision-scripts {
|
function create-provision-scripts {
|
||||||
ensure-temp-dir
|
ensure-temp-dir
|
||||||
|
|
||||||
@ -139,9 +139,9 @@ function create-provision-scripts {
|
|||||||
echo "CONTAINER_ADDR='${NODE_CONTAINER_ADDRS[$i]}'"
|
echo "CONTAINER_ADDR='${NODE_CONTAINER_ADDRS[$i]}'"
|
||||||
echo "CONTAINER_NETMASK='${NODE_CONTAINER_NETMASKS[$i]}'"
|
echo "CONTAINER_NETMASK='${NODE_CONTAINER_NETMASKS[$i]}'"
|
||||||
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-utils.sh"
|
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-utils.sh"
|
||||||
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-network-minion.sh"
|
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-network-node.sh"
|
||||||
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-minion.sh"
|
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-node.sh"
|
||||||
) > "${KUBE_TEMP}/minion-start-${i}.sh"
|
) > "${KUBE_TEMP}/node-start-${i}.sh"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ function verify-cluster {
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# verify each minion has all required daemons
|
# verify each node has all required daemons
|
||||||
local i
|
local i
|
||||||
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
||||||
echo "Validating ${VAGRANT_NODE_NAMES[$i]}"
|
echo "Validating ${VAGRANT_NODE_NAMES[$i]}"
|
||||||
@ -231,12 +231,12 @@ function verify-cluster {
|
|||||||
done
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Waiting for each minion to be registered with cloud provider"
|
echo "Waiting for each node to be registered with cloud provider"
|
||||||
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
for (( i=0; i<${#NODE_NAMES[@]}; i++)); do
|
||||||
local validated="0"
|
local validated="0"
|
||||||
until [[ "$validated" == "1" ]]; do
|
until [[ "$validated" == "1" ]]; do
|
||||||
local minions=$("${KUBE_ROOT}/cluster/kubectl.sh" get nodes -o name --api-version=v1)
|
local nodes=$("${KUBE_ROOT}/cluster/kubectl.sh" get nodes -o name --api-version=v1)
|
||||||
validated=$(echo $minions | grep -c "${NODE_NAMES[i]}") || {
|
validated=$(echo $nodes | grep -c "${NODE_NAMES[i]}") || {
|
||||||
printf "."
|
printf "."
|
||||||
sleep 2
|
sleep 2
|
||||||
validated="0"
|
validated="0"
|
||||||
@ -324,34 +324,34 @@ function test-teardown {
|
|||||||
kube-down
|
kube-down
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find the minion name based on the IP address
|
# Find the node name based on the IP address
|
||||||
function find-vagrant-name-by-ip {
|
function find-vagrant-name-by-ip {
|
||||||
local ip="$1"
|
local ip="$1"
|
||||||
local ip_pattern="${NODE_IP_BASE}(.*)"
|
local ip_pattern="${NODE_IP_BASE}(.*)"
|
||||||
|
|
||||||
# This is subtle. We map 10.245.2.2 -> minion-1. We do this by matching a
|
# This is subtle. We map 10.245.2.2 -> node-1. We do this by matching a
|
||||||
# regexp and using the capture to construct the name.
|
# regexp and using the capture to construct the name.
|
||||||
[[ $ip =~ $ip_pattern ]] || {
|
[[ $ip =~ $ip_pattern ]] || {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "minion-$((${BASH_REMATCH[1]} - 1))"
|
echo "node-$((${BASH_REMATCH[1]} - 1))"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find the vagrant machine name based on the host name of the minion
|
# Find the vagrant machine name based on the host name of the node
|
||||||
function find-vagrant-name-by-minion-name {
|
function find-vagrant-name-by-node-name {
|
||||||
local ip="$1"
|
local ip="$1"
|
||||||
if [[ "$ip" == "${INSTANCE_PREFIX}-master" ]]; then
|
if [[ "$ip" == "${INSTANCE_PREFIX}-master" ]]; then
|
||||||
echo "master"
|
echo "master"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
local ip_pattern="${INSTANCE_PREFIX}-minion-(.*)"
|
local ip_pattern="${INSTANCE_PREFIX}-node-(.*)"
|
||||||
|
|
||||||
[[ $ip =~ $ip_pattern ]] || {
|
[[ $ip =~ $ip_pattern ]] || {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "minion-${BASH_REMATCH[1]}"
|
echo "node-${BASH_REMATCH[1]}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ function ssh-to-node {
|
|||||||
local machine
|
local machine
|
||||||
|
|
||||||
machine=$(find-vagrant-name-by-ip $node) || true
|
machine=$(find-vagrant-name-by-ip $node) || true
|
||||||
[[ -n ${machine-} ]] || machine=$(find-vagrant-name-by-minion-name $node) || true
|
[[ -n ${machine-} ]] || machine=$(find-vagrant-name-by-node-name $node) || true
|
||||||
[[ -n ${machine-} ]] || {
|
[[ -n ${machine-} ]] || {
|
||||||
echo "Cannot find machine to ssh to: $1"
|
echo "Cannot find machine to ssh to: $1"
|
||||||
return 1
|
return 1
|
||||||
|
@ -47,7 +47,7 @@ Running kubernetes with Vagrant (and VirtualBox) is an easy way to run/test/deve
|
|||||||
|
|
||||||
### Setup
|
### Setup
|
||||||
|
|
||||||
By default, the Vagrant setup will create a single master VM (called kubernetes-master) and one node (called kubernetes-minion-1). Each VM will take 1 GB, so make sure you have at least 2GB to 4GB of free memory (plus appropriate free disk space). To start your local cluster, open a shell and run:
|
By default, the Vagrant setup will create a single master VM (called kubernetes-master) and one node (called kubernetes-node-1). Each VM will take 1 GB, so make sure you have at least 2GB to 4GB of free memory (plus appropriate free disk space). To start your local cluster, open a shell and run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd kubernetes
|
cd kubernetes
|
||||||
@ -74,14 +74,14 @@ To access the master or any node:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
vagrant ssh master
|
vagrant ssh master
|
||||||
vagrant ssh minion-1
|
vagrant ssh node-1
|
||||||
```
|
```
|
||||||
|
|
||||||
If you are running more than one nodes, you can access the others by:
|
If you are running more than one nodes, you can access the others by:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
vagrant ssh minion-2
|
vagrant ssh node-2
|
||||||
vagrant ssh minion-3
|
vagrant ssh node-3
|
||||||
```
|
```
|
||||||
|
|
||||||
To view the service status and/or logs on the kubernetes-master:
|
To view the service status and/or logs on the kubernetes-master:
|
||||||
@ -101,11 +101,11 @@ $ vagrant ssh master
|
|||||||
To view the services on any of the nodes:
|
To view the services on any of the nodes:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ vagrant ssh minion-1
|
$ vagrant ssh node-1
|
||||||
[vagrant@kubernetes-minion-1] $ sudo systemctl status docker
|
[vagrant@kubernetes-node-1] $ sudo systemctl status docker
|
||||||
[vagrant@kubernetes-minion-1] $ sudo journalctl -r -u docker
|
[vagrant@kubernetes-node-1] $ sudo journalctl -r -u docker
|
||||||
[vagrant@kubernetes-minion-1] $ sudo systemctl status kubelet
|
[vagrant@kubernetes-node-1] $ sudo systemctl status kubelet
|
||||||
[vagrant@kubernetes-minion-1] $ sudo journalctl -r -u kubelet
|
[vagrant@kubernetes-node-1] $ sudo journalctl -r -u kubelet
|
||||||
```
|
```
|
||||||
|
|
||||||
### Interacting with your Kubernetes cluster with Vagrant.
|
### Interacting with your Kubernetes cluster with Vagrant.
|
||||||
@ -139,9 +139,9 @@ You may need to build the binaries first, you can do this with `make`
|
|||||||
$ ./cluster/kubectl.sh get nodes
|
$ ./cluster/kubectl.sh get nodes
|
||||||
|
|
||||||
NAME LABELS STATUS
|
NAME LABELS STATUS
|
||||||
kubernetes-minion-0whl kubernetes.io/hostname=kubernetes-minion-0whl Ready
|
kubernetes-node-0whl kubernetes.io/hostname=kubernetes-node-0whl Ready
|
||||||
kubernetes-minion-4jdf kubernetes.io/hostname=kubernetes-minion-4jdf Ready
|
kubernetes-node-4jdf kubernetes.io/hostname=kubernetes-node-4jdf Ready
|
||||||
kubernetes-minion-epbe kubernetes.io/hostname=kubernetes-minion-epbe Ready
|
kubernetes-node-epbe kubernetes.io/hostname=kubernetes-node-epbe Ready
|
||||||
```
|
```
|
||||||
|
|
||||||
### Interacting with your Kubernetes cluster with the `kube-*` scripts.
|
### Interacting with your Kubernetes cluster with the `kube-*` scripts.
|
||||||
@ -206,9 +206,9 @@ Your cluster is running, you can list the nodes in your cluster:
|
|||||||
$ ./cluster/kubectl.sh get nodes
|
$ ./cluster/kubectl.sh get nodes
|
||||||
|
|
||||||
NAME LABELS STATUS
|
NAME LABELS STATUS
|
||||||
kubernetes-minion-0whl kubernetes.io/hostname=kubernetes-minion-0whl Ready
|
kubernetes-node-0whl kubernetes.io/hostname=kubernetes-node-0whl Ready
|
||||||
kubernetes-minion-4jdf kubernetes.io/hostname=kubernetes-minion-4jdf Ready
|
kubernetes-node-4jdf kubernetes.io/hostname=kubernetes-node-4jdf Ready
|
||||||
kubernetes-minion-epbe kubernetes.io/hostname=kubernetes-minion-epbe Ready
|
kubernetes-node-epbe kubernetes.io/hostname=kubernetes-node-epbe Ready
|
||||||
```
|
```
|
||||||
|
|
||||||
Now start running some containers!
|
Now start running some containers!
|
||||||
@ -245,11 +245,11 @@ my-nginx-kqdjk 1/1 Waiting 0 33s
|
|||||||
my-nginx-nyj3x 1/1 Waiting 0 33s
|
my-nginx-nyj3x 1/1 Waiting 0 33s
|
||||||
```
|
```
|
||||||
|
|
||||||
You need to wait for the provisioning to complete, you can monitor the minions by doing:
|
You need to wait for the provisioning to complete, you can monitor the nodes by doing:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ sudo salt '*minion-1' cmd.run 'docker images'
|
$ sudo salt '*node-1' cmd.run 'docker images'
|
||||||
kubernetes-minion-1:
|
kubernetes-node-1:
|
||||||
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
|
||||||
<none> <none> 96864a7d2df3 26 hours ago 204.4 MB
|
<none> <none> 96864a7d2df3 26 hours ago 204.4 MB
|
||||||
kubernetes/pause latest 6c4579af347b 8 weeks ago 239.8 kB
|
kubernetes/pause latest 6c4579af347b 8 weeks ago 239.8 kB
|
||||||
@ -258,8 +258,8 @@ kubernetes-minion-1:
|
|||||||
Once the docker image for nginx has been downloaded, the container will start and you can list it:
|
Once the docker image for nginx has been downloaded, the container will start and you can list it:
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ sudo salt '*minion-1' cmd.run 'docker ps'
|
$ sudo salt '*node-1' cmd.run 'docker ps'
|
||||||
kubernetes-minion-1:
|
kubernetes-node-1:
|
||||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||||
dbe79bf6e25b nginx:latest "nginx" 21 seconds ago Up 19 seconds k8s--mynginx.8c5b8a3a--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1.etcd--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1--fcfa837f
|
dbe79bf6e25b nginx:latest "nginx" 21 seconds ago Up 19 seconds k8s--mynginx.8c5b8a3a--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1.etcd--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1--fcfa837f
|
||||||
fa0e29c94501 kubernetes/pause:latest "/pause" 8 minutes ago Up 8 minutes 0.0.0.0:8080->80/tcp k8s--net.a90e7ce4--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1.etcd--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1--baf5b21b
|
fa0e29c94501 kubernetes/pause:latest "/pause" 8 minutes ago Up 8 minutes 0.0.0.0:8080->80/tcp k8s--net.a90e7ce4--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1.etcd--7813c8bd_-_3ffe_-_11e4_-_9036_-_0800279696e1--baf5b21b
|
||||||
@ -346,7 +346,7 @@ It's very likely you see a build error due to an error in your source files!
|
|||||||
|
|
||||||
#### I have brought Vagrant up but the nodes won't validate!
|
#### I have brought Vagrant up but the nodes won't validate!
|
||||||
|
|
||||||
Are you sure you built a release first? Did you install `net-tools`? For more clues, login to one of the nodes (`vagrant ssh minion-1`) and inspect the salt minion log (`sudo cat /var/log/salt/minion`).
|
Are you sure you built a release first? Did you install `net-tools`? For more clues, login to one of the nodes (`vagrant ssh node-1`) and inspect the salt minion log (`sudo cat /var/log/salt/minion`).
|
||||||
|
|
||||||
#### I want to change the number of nodes!
|
#### I want to change the number of nodes!
|
||||||
|
|
||||||
|
@ -322,9 +322,9 @@ export KUBERNETES_PROVIDER=vagrant
|
|||||||
During provision of the cluster, you may see the following message:
|
During provision of the cluster, you may see the following message:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
Validating minion-1
|
Validating node-1
|
||||||
.............
|
.............
|
||||||
Waiting for each minion to be registered with cloud provider
|
Waiting for each node to be registered with cloud provider
|
||||||
error: couldn't read version from server: Get https://10.245.1.2/api: dial tcp 10.245.1.2:443: i/o timeout
|
error: couldn't read version from server: Get https://10.245.1.2/api: dial tcp 10.245.1.2:443: i/o timeout
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user