diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 472cd3c611..4a7900e1dd 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -14,14 +14,6 @@ $ export GOPATH=$HOME/go $ export PATH=$PATH:$GOPATH/bin ``` -## Dependency management - -TiDB Operator uses [retool](https://github.com/twitchtv/retool) to manage Go related tools. - -```sh -$ go get -u github.com/twitchtv/retool -``` - ## Workflow ### Step 1: Fork TiDB Operator on GitHub @@ -112,6 +104,49 @@ $ make check This will show errors if your code change does not pass checks (e.g. fmt, lint). Please fix them before submitting the PR. +#### Start tidb-operator locally and do manual tests + +We uses [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation) to +start a Kubernetes cluster locally and +[kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) must be +installed to access Kubernetes cluster. + +You can refer to their official references to install them on your machine, or +run the following command to install them into our local binary directory: +`output/bin`. + +``` +$ hack/install-up-operator.sh -i +$ export PATH=$(pwd)/output/bin:$PATH +``` + +Make sure they are installed correctly: + +``` +$ kind --version +... +$ kubectl version --client +... +``` + +Create a Kubernetes cluster with `kind`: + +``` +$ kind create cluster +``` + +Build and run tidb-operator: + +``` +$ ./hack/local-up-operator.sh +``` + +Start a basic TiDB cluster: + +``` +$ kubectl apply -f examples/basic/tidb-cluster.yaml +``` + #### Run unit tests Before running your code in a real Kubernetes cluster, make sure it passes all unit tests. diff --git a/hack/local-up-operator.sh b/hack/local-up-operator.sh index 6367326fd7..2d8bdac03a 100755 --- a/hack/local-up-operator.sh +++ b/hack/local-up-operator.sh @@ -33,6 +33,7 @@ This commands run tidb-operator in Kubernetes. Usage: hack/local-up-operator.sh [-hd] -h show this message and exit + -i install dependencies only Environments: @@ -48,12 +49,16 @@ Environments: EOF } -while getopts "h?" opt; do +installOnly=false +while getopts "h?i" opt; do case "$opt" in h|\?) usage exit 0 ;; + i) + installOnly=true + ;; esac done @@ -67,8 +72,13 @@ IMAGE_TAG=${IMAGE_TAG:-latest} SKIP_IMAGE_BUILD=${SKIP_IMAGE_BUILD:-} hack::ensure_kubectl +hack::ensure_kind hack::ensure_helm +if [[ "$installOnly" == "true" ]]; then + exit 0 +fi + function hack::create_namespace() { local ns="$1" $KUBECTL_BIN create namespace $ns