Uploaded image for project: 'Couchbase Kubernetes'
  1. Couchbase Kubernetes
  2. K8S-1111

make the CRD `cbc` types ready to use for `kubectl wait` ?

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.0.0
    • 1.0.0, 1.1.0, 1.2.0, 1.2.1
    • operator, testing

    Description

      Raised originally [Github| on https://github.com/couchbase/couchbase-operator/issues/14].

      (copied here)

      The kubectl wait is a standard command useful for the common case when need to wait all pods ready by a Deployment,

      https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#wait

      All the standard K8s types like `deploy,service,...` all supports this wait command,

      When we're making the DBaaS product, somewhere in the code I need to wait the Cluster created by Operator and ready to use, in different K8s environments it sometimes take minutes to bring all pods up and join the cluster ;

      So I feel kubectl wait is good for this purpose, But, this does not work

      ➸ kubectl wait --for=condition=available cbc/cp-couchbase
      error: .status.conditions accessor error: map[Available:map[lastTransitionTime:2019-07-24T07:58:49Z
       lastUpdateTime:2019-07-24T07:58:49Z reason:Cluster available status:True]
       Balanced:map[lastTransitionTime:2019-07-24T07:59:52Z lastUpdateTime:2019-07-24T07:59:52Z
       message:Data is equally distributed across all nodes in the cluster
       reason:Cluster is balanced status:True]]}}{ is of the type map[string]interface {}, expected []interface{}
      

       
      We're using some shell workaround like this waiting for first_pod

      until kubectl get pods -l "couchbase_cluster=cb-$DATABASE_ID" -o name | head -n 1 | grep .; do
        echo "Waiting for the first couchbase pod to exist..."}}
        sleep 1
      done
      first_pod=$(kubectl get pods -l "couchbase_cluster=cb-$DATABASE_ID" -o name | head -n 1 | grep .)
      timeout="5m" 
      # it can take quite a while for couchbase to spin up
      echo "Waiting up to ${timeout} for the ${first_pod} to become ready..."
      if ! kubectl wait --for condition=ready --timeout "${timeout}" "${first_pod}"; then
        kubectl describe pod "${first_pod}"
        echo
        echo "Failed to become ready. See above output for details."
        exit 1
      fi
      

      This report can also be a question if you know a better workaround.

      Thanks

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            simon.murray Simon Murray
            thomas.cheng thomas.c [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty