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
|
MASTER_SIZE=g1-small
|
||||||
MINION_SIZE=g1-small
|
MINION_SIZE=g1-small
|
||||||
NUM_MINIONS=4
|
NUM_MINIONS=4
|
||||||
# gcloud will expand this to the latest supported image.
|
# gcloud/gcutil will expand this to the latest supported image.
|
||||||
IMAGE=debian-7-backports
|
IMAGE=backports-debian-7-wheezy
|
||||||
NETWORK=default
|
NETWORK=default
|
||||||
INSTANCE_PREFIX=kubernetes
|
INSTANCE_PREFIX=kubernetes
|
||||||
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||||
|
|
|
@ -17,8 +17,8 @@ ZONE=us-central1-b
|
||||||
MASTER_SIZE=g1-small
|
MASTER_SIZE=g1-small
|
||||||
MINION_SIZE=g1-small
|
MINION_SIZE=g1-small
|
||||||
NUM_MINIONS=2
|
NUM_MINIONS=2
|
||||||
# gcloud will expand this to the latest supported image.
|
# gcloud/gcutil will expand this to the latest supported image.
|
||||||
IMAGE=debian-7-backports
|
IMAGE=backports-debian-7-wheezy
|
||||||
NETWORK=default
|
NETWORK=default
|
||||||
INSTANCE_PREFIX="e2e-test-${USER}"
|
INSTANCE_PREFIX="e2e-test-${USER}"
|
||||||
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
MASTER_NAME="${INSTANCE_PREFIX}-master"
|
||||||
|
|
|
@ -25,17 +25,31 @@ source $(dirname $0)/util.sh
|
||||||
detect-project
|
detect-project
|
||||||
|
|
||||||
echo "Bringing down cluster"
|
echo "Bringing down cluster"
|
||||||
gcloud compute firewalls delete --quiet ${MASTER_NAME}-https \
|
gcutil deletefirewall \
|
||||||
--project ${PROJECT} &
|
|
||||||
|
|
||||||
gcloud compute instances delete --quiet ${MASTER_NAME} \
|
|
||||||
--project ${PROJECT} \
|
--project ${PROJECT} \
|
||||||
--zone ${ZONE} &
|
--norespect_terminal_width \
|
||||||
|
--force \
|
||||||
|
${MASTER_NAME}-https &
|
||||||
|
|
||||||
gcloud compute instances delete --quiet ${MINION_NAMES[*]} \
|
gcutil deleteinstance \
|
||||||
--project ${PROJECT} \
|
--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
|
wait
|
||||||
|
|
|
@ -25,7 +25,7 @@ set -e
|
||||||
source $(dirname $0)/util.sh
|
source $(dirname $0)/util.sh
|
||||||
|
|
||||||
# Make sure that prerequisites are installed.
|
# Make sure that prerequisites are installed.
|
||||||
for x in gcloud gsutil; do
|
for x in gcloud gcutil gsutil; do
|
||||||
if [ "$(which $x)" == "" ]; then
|
if [ "$(which $x)" == "" ]; then
|
||||||
echo "Can't find $x in PATH, please fix and retry."
|
echo "Can't find $x in PATH, please fix and retry."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -46,12 +46,11 @@ detect-master
|
||||||
echo "echo Executing configuration"
|
echo "echo Executing configuration"
|
||||||
echo "sudo salt '*' mine.update"
|
echo "sudo salt '*' mine.update"
|
||||||
echo "sudo salt --force-color '*' state.highstate"
|
echo "sudo salt --force-color '*' state.highstate"
|
||||||
) | gcloud compute ssh $KUBE_MASTER \
|
) | gcutil ssh --project ${PROJECT} --zone ${ZONE} $KUBE_MASTER bash
|
||||||
--project ${PROJECT} --zone ${ZONE} --command="bash"
|
|
||||||
|
|
||||||
get-password
|
get-password
|
||||||
|
|
||||||
echo "Kubernetes cluster is running. Access the master at:"
|
echo "Kubernetes cluster is updated. Access the master at:"
|
||||||
echo
|
echo
|
||||||
echo " https://${user}:${passwd}@${KUBE_MASTER_IP}"
|
echo " https://${user}:${passwd}@${KUBE_MASTER_IP}"
|
||||||
echo
|
echo
|
||||||
|
|
|
@ -26,7 +26,7 @@ set -e
|
||||||
source $(dirname $0)/util.sh
|
source $(dirname $0)/util.sh
|
||||||
|
|
||||||
# Make sure that prerequisites are installed.
|
# Make sure that prerequisites are installed.
|
||||||
for x in gcloud gsutil; do
|
for x in gcloud gcutil gsutil; do
|
||||||
if [ "$(which $x)" == "" ]; then
|
if [ "$(which $x)" == "" ]; then
|
||||||
echo "Can't find $x in PATH, please fix and retry."
|
echo "Can't find $x in PATH, please fix and retry."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -60,24 +60,24 @@ HTPASSWD=$(cat ${KUBE_TEMP}/htpasswd)
|
||||||
) > ${KUBE_TEMP}/master-start.sh
|
) > ${KUBE_TEMP}/master-start.sh
|
||||||
|
|
||||||
echo "Starting VMs and configuring firewalls"
|
echo "Starting VMs and configuring firewalls"
|
||||||
gcloud compute firewalls create --quiet ${MASTER_NAME}-https \
|
gcutil addfirewall ${MASTER_NAME}-https \
|
||||||
|
--norespect_terminal_width \
|
||||||
--project ${PROJECT} \
|
--project ${PROJECT} \
|
||||||
--target-tags ${MASTER_TAG} \
|
--network ${NETWORK} \
|
||||||
--allow tcp:443 \
|
--target_tags ${MASTER_TAG} \
|
||||||
--network ${NETWORK} &
|
--allowed tcp:443 &
|
||||||
|
|
||||||
gcloud compute instances create ${MASTER_NAME}\
|
gcutil addinstance ${MASTER_NAME}\
|
||||||
|
--norespect_terminal_width \
|
||||||
--project ${PROJECT} \
|
--project ${PROJECT} \
|
||||||
--zone ${ZONE} \
|
--zone ${ZONE} \
|
||||||
--machine-type ${MASTER_SIZE} \
|
--machine_type ${MASTER_SIZE} \
|
||||||
--image ${IMAGE} \
|
--image ${IMAGE} \
|
||||||
--tags ${MASTER_TAG} \
|
--tags ${MASTER_TAG} \
|
||||||
--no-scopes \
|
--network ${NETWORK} \
|
||||||
--restart-on-failure \
|
--service_account_scopes="storage-ro" \
|
||||||
--metadata-from-file startup-script=${KUBE_TEMP}/master-start.sh \
|
--automatic_restart \
|
||||||
--network ${NETWORK} &
|
--metadata_from_file startup-script:${KUBE_TEMP}/master-start.sh &
|
||||||
|
|
||||||
GCLOUD_VERSION=$(gcloud version | grep compute | cut -f 2 -d ' ')
|
|
||||||
|
|
||||||
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
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
|
grep -v "^#" $(dirname $0)/templates/salt-minion.sh
|
||||||
) > ${KUBE_TEMP}/minion-start-${i}.sh
|
) > ${KUBE_TEMP}/minion-start-${i}.sh
|
||||||
|
|
||||||
gcloud compute instances create ${MINION_NAMES[$i]} \
|
gcutil addinstance ${MINION_NAMES[$i]} \
|
||||||
|
--norespect_terminal_width \
|
||||||
--project ${PROJECT} \
|
--project ${PROJECT} \
|
||||||
--zone ${ZONE} \
|
--zone ${ZONE} \
|
||||||
--machine-type ${MINION_SIZE} \
|
--machine_type ${MINION_SIZE} \
|
||||||
--image ${IMAGE} \
|
--image ${IMAGE} \
|
||||||
--tags ${MINION_TAG} \
|
--tags ${MINION_TAG} \
|
||||||
--no-scopes \
|
--network ${NETWORK} \
|
||||||
--restart-on-failure \
|
--service_account_scopes="" \
|
||||||
--can-ip-forward \
|
--automatic_restart \
|
||||||
--metadata-from-file startup-script=${KUBE_TEMP}/minion-start-${i}.sh \
|
--can_ip_forward \
|
||||||
--network ${NETWORK} &
|
--metadata_from_file startup-script:${KUBE_TEMP}/minion-start-${i}.sh &
|
||||||
|
|
||||||
# 'gcloud compute' past 2014.06.11 breaks the way we are specifying
|
gcutil addroute ${MINION_NAMES[$i]} ${MINION_IP_RANGES[$i]} \
|
||||||
# --next-hop-instance and there is no way to be compatible with both versions.
|
--norespect_terminal_width \
|
||||||
if [[ $GCLOUD_VERSION < "2014.06.11" ]]; then
|
--project ${PROJECT} \
|
||||||
gcloud compute routes create ${MINION_NAMES[$i]} \
|
--network ${NETWORK} \
|
||||||
--project ${PROJECT} \
|
--next_hop_instance ${ZONE}/instances/${MINION_NAMES[$i]} &
|
||||||
--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
|
|
||||||
done
|
done
|
||||||
|
|
||||||
FAIL=0
|
FAIL=0
|
||||||
|
@ -150,5 +140,3 @@ echo " https://${user}:${passwd}@${KUBE_MASTER_IP}"
|
||||||
echo
|
echo
|
||||||
echo "Security note: The server above uses a self signed certificate. This is"
|
echo "Security note: The server above uses a self signed certificate. This is"
|
||||||
echo " subject to \"Man in the middle\" type attacks."
|
echo " subject to \"Man in the middle\" type attacks."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,9 @@ function detect-project () {
|
||||||
function detect-minions () {
|
function detect-minions () {
|
||||||
KUBE_MINION_IP_ADDRESSES=()
|
KUBE_MINION_IP_ADDRESSES=()
|
||||||
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
|
||||||
local minion_ip=$(gcloud compute instances get ${MINION_NAMES[$i]} \
|
local minion_ip=$(gcutil listinstances --format=csv --sort=external-ip \
|
||||||
--fields networkInterfaces[].accessConfigs[].natIP --format=text \
|
--columns=external-ip --filter="name eq ${MINION_NAMES[$i]}" \
|
||||||
| tail -n 1 | cut -f 2 -d ' ')
|
| tail -n 1)
|
||||||
echo "Found ${MINION_NAMES[$i]} at ${minion_ip}"
|
echo "Found ${MINION_NAMES[$i]} at ${minion_ip}"
|
||||||
KUBE_MINION_IP_ADDRESSES+=("${minion_ip}")
|
KUBE_MINION_IP_ADDRESSES+=("${minion_ip}")
|
||||||
done
|
done
|
||||||
|
@ -71,9 +71,9 @@ function detect-minions () {
|
||||||
function detect-master () {
|
function detect-master () {
|
||||||
KUBE_MASTER=${MASTER_NAME}
|
KUBE_MASTER=${MASTER_NAME}
|
||||||
if [ -z "$KUBE_MASTER_IP" ]; then
|
if [ -z "$KUBE_MASTER_IP" ]; then
|
||||||
KUBE_MASTER_IP=$(gcloud compute instances get ${MASTER_NAME} \
|
KUBE_MASTER_IP=$(gcutil listinstances --format=csv --sort=external-ip \
|
||||||
--fields networkInterfaces[].accessConfigs[].natIP --format=text \
|
--columns=external-ip --filter="name eq ${MASTER_NAME}" \
|
||||||
| tail -n 1 | cut -f 2 -d ' ')
|
| tail -n 1)
|
||||||
fi
|
fi
|
||||||
if [ -z "$KUBE_MASTER_IP" ]; then
|
if [ -z "$KUBE_MASTER_IP" ]; then
|
||||||
echo "Could not detect Kubernetes master node. Make sure you've launched a cluster with 'kube-up.sh'"
|
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 {
|
function get-password {
|
||||||
file=${HOME}/.kubernetes_auth
|
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"]')
|
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"]')
|
passwd=$(cat $file | python -c 'import json,sys;print json.load(sys.stdin)["Password"]')
|
||||||
return
|
return
|
||||||
|
@ -101,4 +101,3 @@ function get-password {
|
||||||
EOF
|
EOF
|
||||||
chmod 0600 ~/.kubernetes_auth
|
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:
|
If you ssh to that machine, you can run `docker ps` to see the actual pod:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ gcloud compute ssh kubernetes-minion-3 --zone us-central1-b
|
$ gcutil ssh kubernetes-minion-3 --zone us-central1-b
|
||||||
$ sudo docker ps
|
$ sudo docker ps
|
||||||
|
|
||||||
me@kubernetes-minion-3:~$ sudo docker ps
|
me@kubernetes-minion-3:~$ sudo docker ps
|
||||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
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.)
|
(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.
|
### 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`:
|
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
|
[cloud-console]: https://console.developer.google.com
|
||||||
|
|
|
@ -33,8 +33,11 @@ $(dirname $0)/../cluster/kube-up.sh
|
||||||
# Auto shutdown cluster when we exit
|
# Auto shutdown cluster when we exit
|
||||||
function shutdown-test-cluster () {
|
function shutdown-test-cluster () {
|
||||||
echo "Shutting down test cluster in background."
|
echo "Shutting down test cluster in background."
|
||||||
gcloud compute firewalls delete --quiet ${MINION_TAG}-http-alt \
|
gcutil deletefirewall \
|
||||||
--project ${PROJECT} &
|
--project ${PROJECT} \
|
||||||
|
--norespect_terminal_width \
|
||||||
|
--force \
|
||||||
|
${MINION_TAG}-http-alt &
|
||||||
$(dirname $0)/../cluster/kube-down.sh > /dev/null &
|
$(dirname $0)/../cluster/kube-down.sh > /dev/null &
|
||||||
}
|
}
|
||||||
trap shutdown-test-cluster EXIT
|
trap shutdown-test-cluster EXIT
|
||||||
|
@ -43,10 +46,13 @@ trap shutdown-test-cluster EXIT
|
||||||
detect-project
|
detect-project
|
||||||
|
|
||||||
# Open up port 8080 so nginx containers on minions can be reached
|
# 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} \
|
--project ${PROJECT} \
|
||||||
--target-tags ${MINION_TAG} \
|
--target_tags ${MINION_TAG} \
|
||||||
--allow tcp:8080 &
|
--allowed tcp:8080 \
|
||||||
|
--network ${NETWORK} \
|
||||||
|
${MINION_TAG}-http-alt &
|
||||||
|
|
||||||
# Launch a container
|
# Launch a container
|
||||||
$(dirname $0)/../cluster/cloudcfg.sh -p 8080:80 run dockerfile/nginx 2 myNginx
|
$(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"
|
echo "Release: $RELEASE_PREFIX$RELEASE_NAME"
|
||||||
|
|
||||||
# Make sure that prerequisites are installed.
|
# Make sure that prerequisites are installed.
|
||||||
for x in gcloud gsutil; do
|
for x in gcloud gcutil gsutil; do
|
||||||
if [ "$(which $x)" == "" ]; then
|
if [ "$(which $x)" == "" ]; then
|
||||||
echo "Can't find $x in PATH, please fix and retry."
|
echo "Can't find $x in PATH, please fix and retry."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue