From 63533a0058f9e313dbd818fceb5551813f0a8950 Mon Sep 17 00:00:00 2001 From: Bryan Sullivan Date: Tue, 31 Oct 2017 07:20:28 -0700 Subject: Add log function; fix line endings JIRA: MODELS-23 Change-Id: Ie464181659db2d229dc83b9877dea2a64d6bb06b Signed-off-by: Bryan Sullivan --- tools/kubernetes/ceph-helm.sh | 61 +++++++++++++++++++++-------------------- tools/kubernetes/demo_deploy.sh | 6 ++-- tools/kubernetes/k8s-cluster.sh | 3 ++ tools/maas/deploy.sh | 8 +++--- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/tools/kubernetes/ceph-helm.sh b/tools/kubernetes/ceph-helm.sh index 534fd86..73a32b0 100644 --- a/tools/kubernetes/ceph-helm.sh +++ b/tools/kubernetes/ceph-helm.sh @@ -31,20 +31,24 @@ #. Status: work in progress, incomplete # +function log() { + echo "${FUNCNAME[0]} $(date): $1" +} + function setup_ceph() { nodes=$1 private_net=$2 public_net=$3 dev=$4 # per https://github.com/att/netarbiter/tree/master/sds/ceph-docker/examples/helm - echo "${FUNCNAME[0]}: Clone netarbiter" + log "Clone netarbiter" git clone https://github.com/att/netarbiter.git cd netarbiter/sds/ceph-docker/examples/helm - echo "${FUNCNAME[0]}: Prepare a ceph namespace in your K8s cluster" + log "Prepare a ceph namespace in your K8s cluster" ./prep-ceph-ns.sh - echo "${FUNCNAME[0]}: Run ceph-mon, ceph-mgr, ceph-mon-check, and rbd-provisioner" + log "Run ceph-mon, ceph-mgr, ceph-mon-check, and rbd-provisioner" # Pre-req per https://github.com/att/netarbiter/tree/master/sds/ceph-docker/examples/helm#notes kubedns=$(kubectl get service -o json --namespace kube-system kube-dns | \ jq -r '.spec.clusterIP') @@ -57,32 +61,32 @@ EOF ./helm-install-ceph.sh cephtest $private_net $public_net - echo "${FUNCNAME[0]}: Check the pod status of ceph-mon, ceph-mgr, ceph-mon-check, and rbd-provisioner" + log "Check the pod status of ceph-mon, ceph-mgr, ceph-mon-check, and rbd-provisioner" services="rbd-provisioner ceph-mon-0 ceph-mgr ceph-mon-check" for service in $services; do pod=$(kubectl get pods --namespace ceph | awk "/$service/{print \$1}") status=$(kubectl get pods --namespace ceph $pod -o json | jq -r '.status.phase') while [[ "x$status" != "xRunning" ]]; do - echo "${FUNCNAME[0]}: $pod status is \"$status\". Waiting 10 seconds for it to be 'Running'" + log "$pod status is \"$status\". Waiting 10 seconds for it to be 'Running'" sleep 10 status=$(kubectl get pods --namespace ceph $pod -o json | jq -r '.status.phase') done done kubectl get pods --namespace ceph - echo "${FUNCNAME[0]}: Check ceph health status" + log "Check ceph health status" status=$(kubectl -n ceph exec -it ceph-mon-0 -- ceph -s | awk "/health:/{print \$2}") while [[ "x$status" != "xHEALTH_OK" ]]; do - echo "${FUNCNAME[0]}: ceph status is \"$status\". Waiting 10 seconds for it to be 'HEALTH_OK'" + log "ceph status is \"$status\". Waiting 10 seconds for it to be 'HEALTH_OK'" kubectl -n ceph exec -it ceph-mon-0 -- ceph -s sleep 10 status=$(kubectl -n ceph exec -it ceph-mon-0 -- ceph -s | awk "/health:/{print \$2}") done - echo "${FUNCNAME[0]}: ceph status is 'HEALTH_OK'" + log "ceph status is 'HEALTH_OK'" kubectl -n ceph exec -it ceph-mon-0 -- ceph -s for node in $nodes; do - echo "${FUNCNAME[0]}: setup resolv.conf for $node" + log "install ceph, setup resolv.conf, zap disk for $node" ssh -x -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \ ubuntu@$node < 0 ]]; do - echo "${FUNCNAME[0]}: test job is still running, waiting 10 seconds for it to complete" + log "test job is still running, waiting 10 seconds for it to complete" kubectl describe pods --namespace default $pod | awk '/Events:/{y=1;next}y' sleep 10 active=$(kubectl get jobs --namespace default -o json ceph-test-job | jq -r '.status.active') done - echo "${FUNCNAME[0]}: test job succeeded" + log "test job succeeded" kubectl delete jobs ceph-secret-generator -n ceph kubectl delete pvc ceph-test - echo "${FUNCNAME[0]}: Ceph setup complete!" + log "Ceph setup complete!" } if [[ "$1" != "" ]]; then diff --git a/tools/kubernetes/demo_deploy.sh b/tools/kubernetes/demo_deploy.sh index 8d5cbd2..7489622 100644 --- a/tools/kubernetes/demo_deploy.sh +++ b/tools/kubernetes/demo_deploy.sh @@ -56,7 +56,7 @@ eval `ssh-agent` ssh-add $key if [[ "x$extras" != "x" ]]; then source $extras; fi scp -o StrictHostKeyChecking=no $key ubuntu@$master:/home/ubuntu/$key -echo "Setting up kubernetes..." +echo "$0 $(date): Setting up kubernetes..." scp -r -o StrictHostKeyChecking=no ~/models/tools/kubernetes/* \ ubuntu@$master:/home/ubuntu/. ssh -x -o StrictHostKeyChecking=no ubuntu@$master <" [ceph_dev] #. Runs all the steps above #. +#. When deployment is complete, the k8s API will be available at the master +#. node, e.g. via: curl -k https://:6443/api/v1 +#. #. Status: work in progress, incomplete # diff --git a/tools/maas/deploy.sh b/tools/maas/deploy.sh index 18373cc..1c0880f 100644 --- a/tools/maas/deploy.sh +++ b/tools/maas/deploy.sh @@ -29,17 +29,17 @@ function wait_node_status() { status=$(maas opnfv machines read hostname=$1 | jq -r ".[0].status_name") while [[ "x$status" != "x$2" ]]; do - echo "$1 status is $status ... waiting for it to be $2" + echo "$0 $(date): $1 status is $status ... waiting for it to be $2" sleep 30 status=$(maas opnfv machines read hostname=$1 | jq -r ".[0].status_name") done - echo "$1 status is $status" + echo "$0 $(date): $1 status is $status" } function release_nodes() { nodes=$1 for node in $nodes; do - echo "Releasing node $node" + echo "$0 $(date): Releasing node $node" id=$(maas opnfv machines read hostname=$node | jq -r '.[0].system_id') maas opnfv machines release machines=$id done @@ -48,7 +48,7 @@ function release_nodes() { function deploy_nodes() { nodes=$1 for node in $nodes; do - echo "Deploying node $node" + echo "$0 $(date): Deploying node $node" id=$(maas opnfv machines read hostname=$node | jq -r '.[0].system_id') maas opnfv machines allocate system_id=$id maas opnfv machine deploy $id -- cgit 1.2.3-korg