mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Add support for vpshere cloud provider in kubeup
When deploying on vSphere using kube up add configuration for vSphere cloud provider.
This commit is contained in:
parent
c958d3d4fd
commit
9691b82071
@ -14,7 +14,7 @@
|
|||||||
{% set srv_sshproxy_path = "/srv/sshproxy" -%}
|
{% set srv_sshproxy_path = "/srv/sshproxy" -%}
|
||||||
|
|
||||||
{% if grains.cloud is defined -%}
|
{% if grains.cloud is defined -%}
|
||||||
{% if grains.cloud not in ['vagrant', 'vsphere', 'photon-controller', 'azure-legacy'] -%}
|
{% if grains.cloud not in ['vagrant', 'photon-controller', 'azure-legacy'] -%}
|
||||||
{% set cloud_provider = "--cloud-provider=" + grains.cloud -%}
|
{% set cloud_provider = "--cloud-provider=" + grains.cloud -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
{% if grains.cloud in [ 'aws', 'gce' ] and grains.cloud_config is defined -%}
|
{% if grains.cloud in [ 'vsphere', 'aws', 'gce' ] and grains.cloud_config is defined -%}
|
||||||
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
||||||
{% set cloud_config_mount = "{\"name\": \"cloudconfigmount\",\"mountPath\": \"" + grains.cloud_config + "\", \"readOnly\": true}," -%}
|
{% set cloud_config_mount = "{\"name\": \"cloudconfigmount\",\"mountPath\": \"" + grains.cloud_config + "\", \"readOnly\": true}," -%}
|
||||||
{% set cloud_config_volume = "{\"name\": \"cloudconfigmount\",\"hostPath\": {\"path\": \"" + grains.cloud_config + "\"}}," -%}
|
{% set cloud_config_volume = "{\"name\": \"cloudconfigmount\",\"hostPath\": {\"path\": \"" + grains.cloud_config + "\"}}," -%}
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
{% set srv_kube_path = "/srv/kubernetes" -%}
|
{% set srv_kube_path = "/srv/kubernetes" -%}
|
||||||
|
|
||||||
{% if grains.cloud is defined -%}
|
{% if grains.cloud is defined -%}
|
||||||
{% if grains.cloud not in ['vagrant', 'vsphere', 'photon-controller', 'azure-legacy'] -%}
|
{% if grains.cloud not in ['vagrant', 'photon-controller', 'azure-legacy'] -%}
|
||||||
{% set cloud_provider = "--cloud-provider=" + grains.cloud -%}
|
{% set cloud_provider = "--cloud-provider=" + grains.cloud -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% set service_account_key = "--service-account-private-key-file=/srv/kubernetes/server.key" -%}
|
{% set service_account_key = "--service-account-private-key-file=/srv/kubernetes/server.key" -%}
|
||||||
@ -50,7 +50,7 @@
|
|||||||
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
{% if grains.cloud in [ 'aws', 'gce' ] and grains.cloud_config is defined -%}
|
{% if grains.cloud in [ 'vsphere', 'aws', 'gce' ] and grains.cloud_config is defined -%}
|
||||||
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
||||||
{% set cloud_config_mount = "{\"name\": \"cloudconfigmount\",\"mountPath\": \"" + grains.cloud_config + "\", \"readOnly\": true}," -%}
|
{% set cloud_config_mount = "{\"name\": \"cloudconfigmount\",\"mountPath\": \"" + grains.cloud_config + "\", \"readOnly\": true}," -%}
|
||||||
{% set cloud_config_volume = "{\"name\": \"cloudconfigmount\",\"hostPath\": {\"path\": \"" + grains.cloud_config + "\"}}," -%}
|
{% set cloud_config_volume = "{\"name\": \"cloudconfigmount\",\"hostPath\": {\"path\": \"" + grains.cloud_config + "\"}}," -%}
|
||||||
|
@ -48,12 +48,12 @@
|
|||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
{% set cloud_provider = "" -%}
|
{% set cloud_provider = "" -%}
|
||||||
{% if grains.cloud is defined and grains.cloud not in ['vagrant', 'vsphere', 'photon-controller', 'azure-legacy'] -%}
|
{% if grains.cloud is defined and grains.cloud not in ['vagrant', 'photon-controller', 'azure-legacy'] -%}
|
||||||
{% set cloud_provider = "--cloud-provider=" + grains.cloud -%}
|
{% set cloud_provider = "--cloud-provider=" + grains.cloud -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
{% set cloud_config = "" -%}
|
{% set cloud_config = "" -%}
|
||||||
{% if grains.cloud in [ 'openstack' ] and grains.cloud_config is defined -%}
|
{% if grains.cloud in [ 'openstack', 'vsphere' ] and grains.cloud_config is defined -%}
|
||||||
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
{% set cloud_config = "--cloud-config=" + grains.cloud_config -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
@ -17,12 +17,19 @@
|
|||||||
SSH_OPTS="-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=ERROR -C"
|
SSH_OPTS="-oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oLogLevel=ERROR -C"
|
||||||
|
|
||||||
# These need to be set
|
# These need to be set
|
||||||
#export GOVC_URL=
|
# export GOVC_URL='hostname' # hostname of the vc
|
||||||
#export GOVC_DATACENTER=
|
# export GOVC_USERNAME='username' # username for logging into the vsphere.
|
||||||
#export GOVC_DATASTORE=
|
# export GOVC_PASSWORD='password' # password for the above username
|
||||||
#export GOVC_NETWORK=
|
# export GOVC_NETWORK='Network Name' # Name of the network the vms should join. Many times it could be "VM Network"
|
||||||
#export GOVC_GUEST_LOGIN=
|
# export GOVC_DATASTORE='target datastore'
|
||||||
|
# To get resource pool via govc: govc ls -l 'host/*' | grep ResourcePool | awk '{print $1}' | xargs -n1 -t govc pool.info
|
||||||
|
# export GOVC_RESOURCE_POOL='resource pool or cluster with access to datastore'
|
||||||
|
# export GOVC_GUEST_LOGIN='kube:kube' # Used for logging into kube.vmdk during deployment.
|
||||||
|
# export GOVC_PORT=443 # The port to be used by vSphere cloud provider plugin
|
||||||
|
# To get datacente via govc: govc datacenter.info
|
||||||
|
# export GOVC_DATACENTER='ha-datacenter' # The datacenter to be used by vSphere cloud provider plugin
|
||||||
|
# export GOVC_GUEST_LOGIN='kube:kube' # Used for logging into kube.vmdk during deployment.
|
||||||
|
|
||||||
# Set GOVC_INSECURE if the host in GOVC_URL is using a certificate that cannot
|
# Set GOVC_INSECURE if the host in GOVC_URL is using a certificate that cannot
|
||||||
# be verified (i.e. a self-signed certificate), but IS trusted.
|
# be verified (i.e. a self-signed certificate), but IS trusted.
|
||||||
#export GOVC_INSECURE=1
|
# export GOVC_INSECURE=1
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
NUM_NODES=4
|
NUM_NODES=4
|
||||||
DISK=./kube/kube.vmdk
|
DISK=./kube/kube.vmdk
|
||||||
GUEST_ID=debian7_64Guest
|
GUEST_ID=debian7_64Guest
|
||||||
|
ENABLE_UUID=TRUE
|
||||||
|
|
||||||
INSTANCE_PREFIX=kubernetes
|
INSTANCE_PREFIX=kubernetes
|
||||||
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
MASTER_TAG="${INSTANCE_PREFIX}-master"
|
||||||
|
@ -20,6 +20,22 @@ sed -i -e "s/http.us.debian.org/mirrors.kernel.org/" /etc/apt/sources.list
|
|||||||
# Prepopulate the name of the Master
|
# Prepopulate the name of the Master
|
||||||
mkdir -p /etc/salt/minion.d
|
mkdir -p /etc/salt/minion.d
|
||||||
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf
|
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf
|
||||||
|
CLOUD_CONFIG=/etc/vsphere_cloud.config
|
||||||
|
|
||||||
|
# Configuration to initialize vsphere cloud provider
|
||||||
|
cat <<EOF > $CLOUD_CONFIG
|
||||||
|
[Global]
|
||||||
|
user = $GOVC_USERNAME
|
||||||
|
password = $GOVC_PASSWORD
|
||||||
|
server = $GOVC_URL
|
||||||
|
port = $GOVC_PORT
|
||||||
|
insecure-flag = $GOVC_INSECURE
|
||||||
|
datacenter = $GOVC_DATACENTER
|
||||||
|
datastore = $GOVC_DATASTORE
|
||||||
|
|
||||||
|
[Disk]
|
||||||
|
scsicontrollertype = pvscsi
|
||||||
|
EOF
|
||||||
|
|
||||||
cat <<EOF >/etc/salt/minion.d/grains.conf
|
cat <<EOF >/etc/salt/minion.d/grains.conf
|
||||||
grains:
|
grains:
|
||||||
@ -29,6 +45,7 @@ grains:
|
|||||||
cloud: vsphere
|
cloud: vsphere
|
||||||
master_extra_sans: $MASTER_EXTRA_SANS
|
master_extra_sans: $MASTER_EXTRA_SANS
|
||||||
kube_user: $KUBE_USER
|
kube_user: $KUBE_USER
|
||||||
|
cloud_config: $CLOUD_CONFIG
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Auto accept all keys from minions that try to join
|
# Auto accept all keys from minions that try to join
|
||||||
|
@ -30,6 +30,23 @@ echo "master: $KUBE_MASTER" > /etc/salt/minion.d/master.conf
|
|||||||
# Turn on debugging for salt-minion
|
# Turn on debugging for salt-minion
|
||||||
# echo "DAEMON_ARGS=\"\$DAEMON_ARGS --log-file-level=debug\"" > /etc/default/salt-minion
|
# echo "DAEMON_ARGS=\"\$DAEMON_ARGS --log-file-level=debug\"" > /etc/default/salt-minion
|
||||||
|
|
||||||
|
# Configuration to initialize vsphere cloud provider
|
||||||
|
CLOUD_CONFIG=/etc/vsphere_cloud.config
|
||||||
|
|
||||||
|
cat <<EOF > $CLOUD_CONFIG
|
||||||
|
[Global]
|
||||||
|
user = $GOVC_USERNAME
|
||||||
|
password = $GOVC_PASSWORD
|
||||||
|
server = $GOVC_URL
|
||||||
|
port = $GOVC_PORT
|
||||||
|
insecure-flag = $GOVC_INSECURE
|
||||||
|
datacenter = $GOVC_DATACENTER
|
||||||
|
datastore = $GOVC_DATASTORE
|
||||||
|
|
||||||
|
[Disk]
|
||||||
|
scsicontrollertype = pvscsi
|
||||||
|
EOF
|
||||||
|
|
||||||
# Our minions will have a pool role to distinguish them from the master.
|
# Our minions will have a pool role to distinguish them from the master.
|
||||||
#
|
#
|
||||||
# Setting the "minion_ip" here causes the kubelet to use its IP for
|
# Setting the "minion_ip" here causes the kubelet to use its IP for
|
||||||
@ -37,11 +54,11 @@ echo "master: $KUBE_MASTER" > /etc/salt/minion.d/master.conf
|
|||||||
#
|
#
|
||||||
cat <<EOF >/etc/salt/minion.d/grains.conf
|
cat <<EOF >/etc/salt/minion.d/grains.conf
|
||||||
grains:
|
grains:
|
||||||
hostname_override: $(ip route get 1.1.1.1 | awk '{print $7}')
|
|
||||||
roles:
|
roles:
|
||||||
- kubernetes-pool
|
- kubernetes-pool
|
||||||
- kubernetes-pool-vsphere
|
- kubernetes-pool-vsphere
|
||||||
cloud: vsphere
|
cloud: vsphere
|
||||||
|
cloud_config: $CLOUD_CONFIG
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Install Salt
|
# Install Salt
|
||||||
|
@ -180,12 +180,17 @@ function kube-up-vm {
|
|||||||
-debug \
|
-debug \
|
||||||
-disk="${DISK}" \
|
-disk="${DISK}" \
|
||||||
-g="${GUEST_ID}" \
|
-g="${GUEST_ID}" \
|
||||||
|
-on=false \
|
||||||
-link=true \
|
-link=true \
|
||||||
"$@" \
|
"$@" \
|
||||||
"${vm_name}"
|
"${vm_name}"
|
||||||
|
|
||||||
|
govc vm.change -e="disk.enableUUID=${ENABLE_UUID}" -vm="${vm_name}"
|
||||||
|
|
||||||
|
govc vm.power -on=true "${vm_name}"
|
||||||
|
|
||||||
# Retrieve IP first, to confirm the guest operations agent is running.
|
# Retrieve IP first, to confirm the guest operations agent is running.
|
||||||
govc vm.ip "${vm_name}" > /dev/null
|
CURRENT_NODE_IP=$(govc vm.ip "${vm_name}")
|
||||||
|
|
||||||
govc guest.mkdir \
|
govc guest.mkdir \
|
||||||
-l "kube:kube" \
|
-l "kube:kube" \
|
||||||
@ -395,6 +400,13 @@ function kube-up {
|
|||||||
echo "readonly MASTER_HTPASSWD='${htpasswd}'"
|
echo "readonly MASTER_HTPASSWD='${htpasswd}'"
|
||||||
echo "readonly E2E_STORAGE_TEST_ENVIRONMENT='${E2E_STORAGE_TEST_ENVIRONMENT:-}'"
|
echo "readonly E2E_STORAGE_TEST_ENVIRONMENT='${E2E_STORAGE_TEST_ENVIRONMENT:-}'"
|
||||||
echo "readonly MASTER_EXTRA_SANS='${MASTER_EXTRA_SANS:-}'"
|
echo "readonly MASTER_EXTRA_SANS='${MASTER_EXTRA_SANS:-}'"
|
||||||
|
echo "readonly GOVC_USERNAME='${GOVC_USERNAME}'"
|
||||||
|
echo "readonly GOVC_PASSWORD='${GOVC_PASSWORD}'"
|
||||||
|
echo "readonly GOVC_URL='${GOVC_URL}'"
|
||||||
|
echo "readonly GOVC_PORT='${GOVC_PORT}'"
|
||||||
|
echo "readonly GOVC_INSECURE='${GOVC_INSECURE}'"
|
||||||
|
echo "readonly GOVC_DATACENTER='${GOVC_DATACENTER}'"
|
||||||
|
echo "readonly GOVC_DATASTORE='${GOVC_DATASTORE}'"
|
||||||
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/create-dynamic-salt-files.sh"
|
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/create-dynamic-salt-files.sh"
|
||||||
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/install-release.sh"
|
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/install-release.sh"
|
||||||
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/salt-master.sh"
|
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/salt-master.sh"
|
||||||
@ -416,11 +428,23 @@ function kube-up {
|
|||||||
echo "KUBE_MASTER=${KUBE_MASTER}"
|
echo "KUBE_MASTER=${KUBE_MASTER}"
|
||||||
echo "KUBE_MASTER_IP=${KUBE_MASTER_IP}"
|
echo "KUBE_MASTER_IP=${KUBE_MASTER_IP}"
|
||||||
echo "NODE_IP_RANGE=$NODE_IP_RANGES"
|
echo "NODE_IP_RANGE=$NODE_IP_RANGES"
|
||||||
|
echo "readonly GOVC_USERNAME='${GOVC_USERNAME}'"
|
||||||
|
echo "readonly GOVC_PASSWORD='${GOVC_PASSWORD}'"
|
||||||
|
echo "readonly GOVC_URL='${GOVC_URL}'"
|
||||||
|
echo "readonly GOVC_PORT='${GOVC_PORT}'"
|
||||||
|
echo "readonly GOVC_INSECURE='${GOVC_INSECURE}'"
|
||||||
|
echo "readonly GOVC_DATACENTER='${GOVC_DATACENTER}'"
|
||||||
|
echo "readonly GOVC_DATASTORE='${GOVC_DATASTORE}'"
|
||||||
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/salt-minion.sh"
|
grep -v "^#" "${KUBE_ROOT}/cluster/vsphere/templates/salt-minion.sh"
|
||||||
) > "${KUBE_TEMP}/node-start-${i}.sh"
|
) > "${KUBE_TEMP}/node-start-${i}.sh"
|
||||||
|
|
||||||
(
|
(
|
||||||
kube-up-vm "${NODE_NAMES[$i]}" -c ${NODE_CPU-1} -m ${NODE_MEMORY_MB-1024}
|
kube-up-vm "${NODE_NAMES[$i]}" -c ${NODE_CPU-1} -m ${NODE_MEMORY_MB-1024}
|
||||||
|
add_to_hosts="${NODE_NAMES[$i]} ${CURRENT_NODE_IP}"
|
||||||
|
node_ip_file=${NODE_NAMES[$i]}-ip
|
||||||
|
echo "sudo bash -c \"echo $add_to_hosts >> /etc/hosts\"" > ${KUBE_TEMP}/${node_ip_file}
|
||||||
|
kube-scp ${KUBE_MASTER_IP} ${KUBE_TEMP}/${node_ip_file} /tmp/
|
||||||
|
kube-ssh ${KUBE_MASTER_IP} "bash /tmp/${node_ip_file}"
|
||||||
kube-run "${NODE_NAMES[$i]}" "${KUBE_TEMP}/node-start-${i}.sh"
|
kube-run "${NODE_NAMES[$i]}" "${KUBE_TEMP}/node-start-${i}.sh"
|
||||||
) &
|
) &
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user