mirror of https://github.com/k3s-io/k3s
Switch from `gcloud compute` to `gcutil`.
We'll switch back to the future once the interface has settled down.pull/6/head
parent
77cbfab1cd
commit
110a390c97
|
@ -17,8 +17,8 @@ ZONE=us-central1-b
|
|||
MASTER_SIZE=g1-small
|
||||
MINION_SIZE=g1-small
|
||||
NUM_MINIONS=4
|
||||
# gcloud will expand this to the latest supported image.
|
||||
IMAGE=debian-7-backports
|
||||
# gcloud/gcutil will expand this to the latest supported image.
|
||||
IMAGE=backports-debian-7-wheezy
|
||||
NETWORK=default
|
||||
INSTANCE_PREFIX=kubernetes
|
||||
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||
|
|
|
@ -17,8 +17,8 @@ ZONE=us-central1-b
|
|||
MASTER_SIZE=g1-small
|
||||
MINION_SIZE=g1-small
|
||||
NUM_MINIONS=2
|
||||
# gcloud will expand this to the latest supported image.
|
||||
IMAGE=debian-7-backports
|
||||
# gcloud/gcutil will expand this to the latest supported image.
|
||||
IMAGE=backports-debian-7-wheezy
|
||||
NETWORK=default
|
||||
INSTANCE_PREFIX="e2e-test-${USER}"
|
||||
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||
|
|
|
@ -25,17 +25,31 @@ source $(dirname $0)/util.sh
|
|||
detect-project
|
||||
|
||||
echo "Bringing down cluster"
|
||||
gcloud compute firewalls delete --quiet ${MASTER_NAME}-https \
|
||||
--project ${PROJECT} &
|
||||
|
||||
gcloud compute instances delete --quiet ${MASTER_NAME} \
|
||||
gcutil deletefirewall \
|
||||
--project ${PROJECT} \
|
||||
--zone ${ZONE} &
|
||||
--norespect_terminal_width \
|
||||
--force \
|
||||
${MASTER_NAME}-https &
|
||||
|
||||
gcloud compute instances delete --quiet ${MINION_NAMES[*]} \
|
||||
gcutil deleteinstance \
|
||||
--project ${PROJECT} \
|
||||
--zone ${ZONE} &
|
||||
--norespect_terminal_width \
|
||||
--force \
|
||||
--delete_boot_pd \
|
||||
--zone ${ZONE} \
|
||||
${MASTER_NAME} &
|
||||
|
||||
gcutil deleteinstance \
|
||||
--project ${PROJECT} \
|
||||
--norespect_terminal_width \
|
||||
--force \
|
||||
--delete_boot_pd \
|
||||
--zone ${ZONE} \
|
||||
${MINION_NAMES[*]} &
|
||||
|
||||
gcutil deleteroute \
|
||||
--project ${PROJECT} \
|
||||
--force \
|
||||
${MINION_NAMES[*]} &
|
||||
|
||||
gcloud compute routes delete --quiet ${MINION_NAMES[*]} \
|
||||
--project ${PROJECT} &
|
||||
wait
|
||||
|
|
|
@ -25,7 +25,7 @@ set -e
|
|||
source $(dirname $0)/util.sh
|
||||
|
||||
# Make sure that prerequisites are installed.
|
||||
for x in gcloud gsutil; do
|
||||
for x in gcloud gcutil gsutil; do
|
||||
if [ "$(which $x)" == "" ]; then
|
||||
echo "Can't find $x in PATH, please fix and retry."
|
||||
exit 1
|
||||
|
@ -46,12 +46,11 @@ detect-master
|
|||
echo "echo Executing configuration"
|
||||
echo "sudo salt '*' mine.update"
|
||||
echo "sudo salt --force-color '*' state.highstate"
|
||||
) | gcloud compute ssh $KUBE_MASTER \
|
||||
--project ${PROJECT} --zone ${ZONE} --command="bash"
|
||||
) | gcutil ssh --project ${PROJECT} --zone ${ZONE} $KUBE_MASTER bash
|
||||
|
||||
get-password
|
||||
|
||||
echo "Kubernetes cluster is running. Access the master at:"
|
||||
echo "Kubernetes cluster is updated. Access the master at:"
|
||||
echo
|
||||
echo " https://${user}:${passwd}@${KUBE_MASTER_IP}"
|
||||
echo
|
||||
|
|
|
@ -26,7 +26,7 @@ set -e
|
|||
source $(dirname $0)/util.sh
|
||||
|
||||
# Make sure that prerequisites are installed.
|
||||
for x in gcloud gsutil; do
|
||||
for x in gcloud gcutil gsutil; do
|
||||
if [ "$(which $x)" == "" ]; then
|
||||
echo "Can't find $x in PATH, please fix and retry."
|
||||
exit 1
|
||||
|
@ -60,24 +60,24 @@ HTPASSWD=$(cat ${KUBE_TEMP}/htpasswd)
|
|||
) > ${KUBE_TEMP}/master-start.sh
|
||||
|
||||
echo "Starting VMs and configuring firewalls"
|
||||
gcloud compute firewalls create --quiet ${MASTER_NAME}-https \
|
||||
gcutil addfirewall ${MASTER_NAME}-https \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--target-tags ${MASTER_TAG} \
|
||||
--allow tcp:443 \
|
||||
--network ${NETWORK} &
|
||||
--network ${NETWORK} \
|
||||
--target_tags ${MASTER_TAG} \
|
||||
--allowed tcp:443 &
|
||||
|
||||
gcloud compute instances create ${MASTER_NAME}\
|
||||
gcutil addinstance ${MASTER_NAME}\
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--zone ${ZONE} \
|
||||
--machine-type ${MASTER_SIZE} \
|
||||
--machine_type ${MASTER_SIZE} \
|
||||
--image ${IMAGE} \
|
||||
--tags ${MASTER_TAG} \
|
||||
--no-scopes \
|
||||
--restart-on-failure \
|
||||
--metadata-from-file startup-script=${KUBE_TEMP}/master-start.sh \
|
||||
--network ${NETWORK} &
|
||||
|
||||
GCLOUD_VERSION=$(gcloud version | grep compute | cut -f 2 -d ' ')
|
||||
--network ${NETWORK} \
|
||||
--service_account_scopes="storage-ro" \
|
||||
--automatic_restart \
|
||||
--metadata_from_file startup-script:${KUBE_TEMP}/master-start.sh &
|
||||
|
||||
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
||||
(
|
||||
|
@ -87,34 +87,24 @@ for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
|||
grep -v "^#" $(dirname $0)/templates/salt-minion.sh
|
||||
) > ${KUBE_TEMP}/minion-start-${i}.sh
|
||||
|
||||
gcloud compute instances create ${MINION_NAMES[$i]} \
|
||||
gcutil addinstance ${MINION_NAMES[$i]} \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--zone ${ZONE} \
|
||||
--machine-type ${MINION_SIZE} \
|
||||
--machine_type ${MINION_SIZE} \
|
||||
--image ${IMAGE} \
|
||||
--tags ${MINION_TAG} \
|
||||
--no-scopes \
|
||||
--restart-on-failure \
|
||||
--can-ip-forward \
|
||||
--metadata-from-file startup-script=${KUBE_TEMP}/minion-start-${i}.sh \
|
||||
--network ${NETWORK} &
|
||||
--network ${NETWORK} \
|
||||
--service_account_scopes="" \
|
||||
--automatic_restart \
|
||||
--can_ip_forward \
|
||||
--metadata_from_file startup-script:${KUBE_TEMP}/minion-start-${i}.sh &
|
||||
|
||||
# 'gcloud compute' past 2014.06.11 breaks the way we are specifying
|
||||
# --next-hop-instance and there is no way to be compatible with both versions.
|
||||
if [[ $GCLOUD_VERSION < "2014.06.11" ]]; then
|
||||
gcloud compute routes create ${MINION_NAMES[$i]} \
|
||||
--project ${PROJECT} \
|
||||
--destination-range ${MINION_IP_RANGES[$i]} \
|
||||
--next-hop-instance ${ZONE}/instances/${MINION_NAMES[$i]} \
|
||||
--network ${NETWORK} &
|
||||
else
|
||||
gcloud compute routes create ${MINION_NAMES[$i]} \
|
||||
--project ${PROJECT} \
|
||||
--destination-range ${MINION_IP_RANGES[$i]} \
|
||||
--next-hop-instance ${MINION_NAMES[$i]} \
|
||||
--next-hop-instance-zone ${ZONE} \
|
||||
--network ${NETWORK} &
|
||||
fi
|
||||
gcutil addroute ${MINION_NAMES[$i]} ${MINION_IP_RANGES[$i]} \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--network ${NETWORK} \
|
||||
--next_hop_instance ${ZONE}/instances/${MINION_NAMES[$i]} &
|
||||
done
|
||||
|
||||
FAIL=0
|
||||
|
@ -150,5 +140,3 @@ echo " https://${user}:${passwd}@${KUBE_MASTER_IP}"
|
|||
echo
|
||||
echo "Security note: The server above uses a self signed certificate. This is"
|
||||
echo " subject to \"Man in the middle\" type attacks."
|
||||
|
||||
|
||||
|
|
|
@ -56,9 +56,9 @@ function detect-project () {
|
|||
function detect-minions () {
|
||||
KUBE_MINION_IP_ADDRESSES=()
|
||||
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
||||
local minion_ip=$(gcloud compute instances get ${MINION_NAMES[$i]} \
|
||||
--fields networkInterfaces[].accessConfigs[].natIP --format=text \
|
||||
| tail -n 1 | cut -f 2 -d ' ')
|
||||
local minion_ip=$(gcutil listinstances --format=csv --sort=external-ip \
|
||||
--columns=external-ip --filter="name eq ${MINION_NAMES[$i]}" \
|
||||
| tail -n 1)
|
||||
echo "Found ${MINION_NAMES[$i]} at ${minion_ip}"
|
||||
KUBE_MINION_IP_ADDRESSES+=("${minion_ip}")
|
||||
done
|
||||
|
@ -71,9 +71,9 @@ function detect-minions () {
|
|||
function detect-master () {
|
||||
KUBE_MASTER=${MASTER_NAME}
|
||||
if [ -z "$KUBE_MASTER_IP" ]; then
|
||||
KUBE_MASTER_IP=$(gcloud compute instances get ${MASTER_NAME} \
|
||||
--fields networkInterfaces[].accessConfigs[].natIP --format=text \
|
||||
| tail -n 1 | cut -f 2 -d ' ')
|
||||
KUBE_MASTER_IP=$(gcutil listinstances --format=csv --sort=external-ip \
|
||||
--columns=external-ip --filter="name eq ${MASTER_NAME}" \
|
||||
| tail -n 1)
|
||||
fi
|
||||
if [ -z "$KUBE_MASTER_IP" ]; then
|
||||
echo "Could not detect Kubernetes master node. Make sure you've launched a cluster with 'kube-up.sh'"
|
||||
|
@ -84,7 +84,7 @@ function detect-master () {
|
|||
|
||||
function get-password {
|
||||
file=${HOME}/.kubernetes_auth
|
||||
if [ -e ${file} ]; then
|
||||
if [ -e ${file} ]; then
|
||||
user=$(cat $file | python -c 'import json,sys;print json.load(sys.stdin)["User"]')
|
||||
passwd=$(cat $file | python -c 'import json,sys;print json.load(sys.stdin)["Password"]')
|
||||
return
|
||||
|
@ -101,4 +101,3 @@ function get-password {
|
|||
EOF
|
||||
chmod 0600 ~/.kubernetes_auth
|
||||
}
|
||||
|
||||
|
|
|
@ -94,12 +94,12 @@ Using master: kubernetes-master (external IP: 1.2.3.4)
|
|||
If you ssh to that machine, you can run `docker ps` to see the actual pod:
|
||||
|
||||
```shell
|
||||
$ gcloud compute ssh kubernetes-minion-3 --zone us-central1-b
|
||||
$ gcutil ssh kubernetes-minion-3 --zone us-central1-b
|
||||
$ sudo docker ps
|
||||
|
||||
me@kubernetes-minion-3:~$ sudo docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
417ab993cdf8 dockerfile/redis:latest redis-server /etc/re 8 minutes ago Up 8 minutes 0.0.0.0:6379->6379/tcp master--redis_-_master_-_2--6b944b49
|
||||
417ab993cdf8 dockerfile/redis:latest redis-server /etc/re 8 minutes ago Up 8 minutes 0.0.0.0:6379->6379/tcp master--redis_-_master_-_2--6b944b49
|
||||
```
|
||||
|
||||
(Note that initial `docker pull` may take a few minutes, depending on network conditions.)
|
||||
|
@ -357,7 +357,7 @@ Using master: kubernetes-master (external IP: 1.2.3.4)
|
|||
|
||||
### Step Five: Create the frontend pod.
|
||||
|
||||
This is a simple PHP server that is configured to talk to either the slave or master services depending on whether the request is a read or a write. It exposes a simple AJAX interface, and serves an angular-based UX. Like the redis read slaves it is a replicated service instantiated by a replication controller.
|
||||
This is a simple PHP server that is configured to talk to either the slave or master services depending on whether the request is a read or a write. It exposes a simple AJAX interface, and serves an angular-based UX. Like the redis read slaves it is a replicated service instantiated by a replication controller.
|
||||
|
||||
Create a file named `frontend-controller.json`:
|
||||
|
||||
|
@ -675,6 +675,6 @@ if (isset($_GET['cmd']) === true) {
|
|||
} ?>
|
||||
```
|
||||
|
||||
To play with the service itself, find the name of a frontend, grab the external IP of that host from the [Google Cloud Console][cloud-console], and visit `http://<host-ip>:8080`. You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcloud` tool.
|
||||
To play with the service itself, find the name of a frontend, grab the external IP of that host from the [Google Cloud Console][cloud-console], and visit `http://<host-ip>:8080`. You may need to open the firewall for port 8080 using the [console][cloud-console] or the `gcutil` tool.
|
||||
|
||||
[cloud-console]: https://console.developer.google.com
|
||||
|
|
|
@ -33,8 +33,11 @@ $(dirname $0)/../cluster/kube-up.sh
|
|||
# Auto shutdown cluster when we exit
|
||||
function shutdown-test-cluster () {
|
||||
echo "Shutting down test cluster in background."
|
||||
gcloud compute firewalls delete --quiet ${MINION_TAG}-http-alt \
|
||||
--project ${PROJECT} &
|
||||
gcutil deletefirewall \
|
||||
--project ${PROJECT} \
|
||||
--norespect_terminal_width \
|
||||
--force \
|
||||
${MINION_TAG}-http-alt &
|
||||
$(dirname $0)/../cluster/kube-down.sh > /dev/null &
|
||||
}
|
||||
trap shutdown-test-cluster EXIT
|
||||
|
@ -43,10 +46,13 @@ trap shutdown-test-cluster EXIT
|
|||
detect-project
|
||||
|
||||
# Open up port 8080 so nginx containers on minions can be reached
|
||||
gcloud compute firewalls create --quiet ${MINION_TAG}-http-alt \
|
||||
gcutil addfirewall \
|
||||
--norespect_terminal_width \
|
||||
--project ${PROJECT} \
|
||||
--target-tags ${MINION_TAG} \
|
||||
--allow tcp:8080 &
|
||||
--target_tags ${MINION_TAG} \
|
||||
--allowed tcp:8080 \
|
||||
--network ${NETWORK} \
|
||||
${MINION_TAG}-http-alt &
|
||||
|
||||
# Launch a container
|
||||
$(dirname $0)/../cluster/cloudcfg.sh -p 8080:80 run dockerfile/nginx 2 myNginx
|
||||
|
|
|
@ -22,7 +22,7 @@ echo "Auto installer for launching Kubernetes"
|
|||
echo "Release: $RELEASE_PREFIX$RELEASE_NAME"
|
||||
|
||||
# Make sure that prerequisites are installed.
|
||||
for x in gcloud gsutil; do
|
||||
for x in gcloud gcutil gsutil; do
|
||||
if [ "$(which $x)" == "" ]; then
|
||||
echo "Can't find $x in PATH, please fix and retry."
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue