From 888b3172b1fd0408b273ffb87dffd2be8aed6a8a Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 30 Mar 2018 16:53:52 -0600 Subject: [PATCH] Put some documentation headers in the install/*.sh scripts (#30) * Documented most of the scripts. Removed one that wasn't used. * Removed run_local script. * Updated README-DEV to remove the deleted script. --- README-DEV.md | 10 ++---- install/build_mixer_docker.sh | 15 +++++++++ install/install_docker.sh | 3 ++ install/install_gcloud.sh | 3 ++ install/local_install.sh | 13 ++++++++ install/push_docker_to_gke.sh | 40 ------------------------ install/run_local.sh | 59 ----------------------------------- 7 files changed, 37 insertions(+), 106 deletions(-) delete mode 100755 install/push_docker_to_gke.sh delete mode 100755 install/run_local.sh diff --git a/README-DEV.md b/README-DEV.md index e3c61ff..11c8a69 100644 --- a/README-DEV.md +++ b/README-DEV.md @@ -68,12 +68,8 @@ Note from above: you can only do this on Linux. 1. First, build the docker image: export GCP_PROJECT=my-gcp-project + export TARGET_DOCKER_IMAGE=gcr.io/my-gcp-project/istio-mixer:some-tag $GOPATH/src/github.com/apigee/istio-mixer-adapter/install/build_mixer_docker.sh -2. Next, push to GKE: - - export GCP_PROJECT=my-gcp-project - $GOPATH/src/github.com/apigee/istio-mixer-adapter/install/push_docker_to_gke.sh - -3. Go to [Pantheon](https://pantheon.corp.google.com/kubernetes/workload), you - should see the mixer running there. +2. Next, use that image in your GKE Istio setup. You can follow the directions + in the [README](README.md) to set up Istio. diff --git a/install/build_mixer_docker.sh b/install/build_mixer_docker.sh index 38be7a5..7736e69 100755 --- a/install/build_mixer_docker.sh +++ b/install/build_mixer_docker.sh @@ -1,5 +1,20 @@ #!/bin/bash +# This script will take the compiled mixer, construct a Docker image for it, +# and upload it to GCR. +# +# Prereqs: +# - run the local_install.sh script to build the mixer. +# - docker is installed. +# - gcloud is installed. +# - GOPATH is set. +# +# Variables: +# - GCLOUD_SERVICE_KEY - auth key for the service account (used in CI to build +# nightlies) +# - GCP_PROJECT - which GCP_PROJECT to upload the image to. +# - TARGET_DOCKER_IMAGE - the name of the docker image to build. + echo "Checking environment settings..." if [[ $GCLOUD_SERVICE_KEY == "" ]]; then diff --git a/install/install_docker.sh b/install/install_docker.sh index 2bb0796..fbf1e1c 100755 --- a/install/install_docker.sh +++ b/install/install_docker.sh @@ -1,5 +1,8 @@ #!/bin/bash +# This script will install Docker on the local machine. Not recommended for use +# on development machines, it is mainly used for containers in CI. + if [[ `command -v docker` != "" ]]; then echo "Docker already installed." exit 0 diff --git a/install/install_gcloud.sh b/install/install_gcloud.sh index 535a1bb..8673cf3 100755 --- a/install/install_gcloud.sh +++ b/install/install_gcloud.sh @@ -1,5 +1,8 @@ #!/bin/bash +# This script will install gcloud on the local machine. Not recommended for use +# on development machines, it is mainly used for containers in CI. + if [[ `command -v gcloud` != "" ]]; then echo "gcloud already installed." exit 0 diff --git a/install/local_install.sh b/install/local_install.sh index e0ba6e2..a2a9a93 100755 --- a/install/local_install.sh +++ b/install/local_install.sh @@ -1,5 +1,18 @@ #!/bin/bash +# This script builds the Mixer with the Apigee adapter on the local machine. +# It will clone Istio if necessary. +# +# Prereqs: +# - GOPATH is set. +# - Apigee mixer adapter is checked out to: +# $GOPATH/src/github.com/apigee/istio-mixer-adapter +# - on Mac: dep is installed. +# +# Variables: +# - INSTALL_PROTOC - installs protoc if set to 1. Used for CI. + + echo "Installing all the things" if [[ "${GOPATH}" == "" ]]; then diff --git a/install/push_docker_to_gke.sh b/install/push_docker_to_gke.sh deleted file mode 100755 index 9b92899..0000000 --- a/install/push_docker_to_gke.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -echo "Checking environment settings..." - -if [[ "${GCP_PROJECT}" == "" ]]; then - echo "GCP_PROJECT not set, please set it." - exit 1 -fi - -if [[ "${DOCKER_IMAGE}" == "" ]]; then - DOCKER_IMAGE="gcr.io/${GCP_PROJECT}/istio-mixer" - echo "DOCKER_IMAGE not set, defaulting to ${DOCKER_IMAGE}." -fi - -if [[ "${GKE_CLUSTER_NAME}" == "" ]]; then - GKE_CLUSTER_NAME=apigee-istio-mixer - echo "GKE_CLUSTER_NAME not set, defaulting to ${GKE_CLUSTER_NAME}." -fi - -if [[ "${GKE_DEPLOYMENT_NAME}" == "" ]]; then - GKE_DEPLOYMENT_NAME=istio-mixer - echo "GKE_DEPLOYMENT_NAME not set, defaulting to ${GKE_DEPLOYMENT_NAME}." -fi - -if [[ "${PORT}" == "" ]]; then - PORT=8080 - echo "PORT not set, defaulting to ${PORT}." -fi - -gcloud config set project "${GCP_PROJECT}" - -CLUSTER=$(gcloud container clusters list | grep "${GKE_CLUSTER_NAME}") -if [[ "${CLUSTER}" == "" ]]; then - echo "GKE cluster ${GKE_CLUSTER_NAME} does not exist, creating..." - gcloud container clusters create "${GKE_CLUSTER_NAME}" -fi - -gcloud container clusters get-credentials "${GKE_CLUSTER_NAME}" -kubectl run "${GKE_DEPLOYMENT_NAME}" --image "${DOCKER_IMAGE}" --port "${PORT}" -kubectl expose deployment "${GKE_DEPLOYMENT_NAME}" --type LoadBalancer diff --git a/install/run_local.sh b/install/run_local.sh deleted file mode 100755 index 4f48f83..0000000 --- a/install/run_local.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash - -echo "Checking environment settings..." - -if [[ "${APIGEE_ORG}" == "" ]]; then - echo "APIGEE_ORG not set, please set it." - exit 1 -fi - -if [[ "${APIGEE_ENV}" == "" ]]; then - echo "APIGEE_ENV not set, please set it." - exit 1 -fi - -if [[ "${GOPATH}" == "" ]]; then - echo "GOPATH not set, please set it." - exit 1 -fi - -export ISTIO="${GOPATH}/src/istio.io" - -if [ ! -d "${ISTIO}/istio" ]; then - echo "istio repo not found, please run local_install.sh to set it up." - exit 1 -fi - -GOARCH=amd64 # this is hard-coded by Istio so hopefully they don't change it - -if [[ `uname` == "Linux" ]]; then - GOOS=linux -elif [[ `uname` == "Darwin" ]]; then - GOOS=darwin -else - echo "Unknown OS $(uname)" - exit 1 -fi - - -echo "Writing config files..." -CONFIG_FILE="${ISTIO}/istio/mixer/testdata/config/apigee.yaml" - -cat "${GOPATH}/src/github.com/apigee/istio-mixer-adapter/testdata/operatorconfig/config.yaml" \ - | sed "s/theganyo1-eval/${APIGEE_ORG}/" \ - | sed "s/test/${APIGEE_ENV}/" \ - > "${CONFIG_FILE}" - -ATTR_FILE="${ISTIO}/istio/mixer/testdata/config/attributes.yaml" - -if [[ `grep 'request.auth.claims' "${ATTR_FILE}"` == "" ]]; then - sed -i \ - -e "/request.auth.principal/ i \ request.auth.claims:" \ - -e "/request.auth.principal/ i \ value_type: STRING_MAP" \ - "${ATTR_FILE}" -fi - -MIXS="${GOPATH}/out/${GOOS}_${GOARCH}/release/mixs" - -"${MIXS}" server --alsologtostderr \ - "--configStoreURL=fs://${ISTIO}/istio/mixer/testdata/config"