Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support debug and ctop commands in CLI #387

Merged
merged 15 commits into from
Apr 17, 2019
Merged
22 changes: 20 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ ifeq ($(GO111), 1)
$(error Please upgrade your Go compiler to 1.11 or higher version)
endif

GOENV := GO15VENDOREXPERIMENT="1" GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64
GOOS := $(if $(GOOS),$(GOOS),linux)
GOARCH := $(if $(GOARCH),$(GOARCH),amd64)
GOENV := GO15VENDOREXPERIMENT="1" GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH)
GO := $(GOENV) go build
GOTEST := CGO_ENABLED=0 GO111MODULE=on go test -v -cover

Expand Down Expand Up @@ -123,4 +125,20 @@ check-gosec:
@echo "security checking"
CGO_ENABLED=0 retool do gosec $$($(PACKAGE_DIRECTORIES))

.PHONY: check check-setup check-all build e2e-build
cli:
$(GO) -ldflags '$(LDFLAGS)' -o tkc cmd/tkctl/main.go

debug-docker-push: debug-build-docker
docker push "${DOCKER_REGISTRY}/pingcap/debug-launcher:latest"
docker push "${DOCKER_REGISTRY}/pingcap/tidb-control:latest"
docker push "${DOCKER_REGISTRY}/pingcap/tidb-debug:latest"

debug-build-docker: debug-build
docker build -t "${DOCKER_REGISTRY}/pingcap/debug-launcher:latest" misc/images/debug-launcher
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-control:latest" misc/images/tidb-control
docker build -t "${DOCKER_REGISTRY}/pingcap/tidb-debug:latest" misc/images/tidb-debug

debug-build:
$(GO) -ldflags '$(LDFLAGS)' -o misc/images/debug-launcher/bin/debug-launcher misc/cmd/debug-launcher/main.go

.PHONY: check check-setup check-all build e2e-build debug-build cli
60 changes: 60 additions & 0 deletions ci/release_cli_binary_and_debug_image.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
def call(BUILD_BRANCH, RELEASE_TAG) {

env.GOPATH = "/go"
env.GOROOT = "/usr/local/go"
env.PATH = "${env.GOROOT}/bin:${env.GOPATH}/bin:/bin:${env.PATH}:/home/jenkins/bin"

def GITHASH
def TKC_CLI_PACKAGE = "tkc-${GOOS}-${GOARCH}-${RELEASE_TAG}"

catchError {
node('k8s_centos7_build') {
def WORKSPACE = pwd()

dir("${WORKSPACE}/operator"){
stage('Build and release CLI to qiniu'){
checkout([$class: 'GitSCM', branches: [[name: "${BUILD_BRANCH}"]], userRemoteConfigs:[[url: "${BUILD_URL}", credentialsId: "${CREDENTIALS_ID}"]]])
GITHASH = sh(returnStdout: true, script: "git rev-parse HEAD").trim()
def GOARCH = "amd64"
["linux", "darwin", "windows"].each {
sh """
GOOS=${it} GOARCH=${GOARCH} make cli
tar -zcf ${TKC_CLI_PACKAGE}.tgz tkc
sha256sum ${TKC_CLI_PACKAGE}.tgz > ${TKC_CLI_PACKAGE}.sha256

upload.py ${TKC_CLI_PACKAGE}.tgz ${TKC_CLI_PACKAGE}.tgz
upload.py ${TKC_CLI_PACKAGE}.sha256 ${TKC_CLI_PACKAGE}.sha256
"""
}
}

stage('Build and push debug images'){
withDockerServer([uri: "${env.DOCKER_HOST}"]) {
DOCKER_REGISTRY="" make debug-docker-push
DOCKER_REGISTRY="uhub.service.ucloud.cn" make debug-docker-push
}
}
}
}
currentBuild.result = "SUCCESS"
}
stage('Summary') {
echo("echo summary info ########")
def DURATION = ((System.currentTimeMillis() - currentBuild.startTimeInMillis) / 1000 / 60).setScale(2, BigDecimal.ROUND_HALF_UP)
def slackmsg = "[${env.JOB_NAME.replaceAll('%2F','/')}-${env.BUILD_NUMBER}] `${currentBuild.result}`" + "\n" +
"Elapsed Time: `${DURATION}` Mins" + "\n" +
"tidb-operator Branch: `${BUILD_BRANCH}`, Githash: `${GITHASH.take(7)}`" + "\n" +
"Display URL:" + "\n" +
"${env.RUN_DISPLAY_URL}"

if(currentBuild.result != "SUCCESS"){
slackSend channel: '#cloud_jenkins', color: 'danger', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}"
} else {
slackmsg = "${slackmsg}" + "\n" +
"tkc cli tool build and debug image build failed for BRANCH:${BUILD_BRANCH} and TAG:${RELEASE_TAG}`"
slackSend channel: '#cloud_jenkins', color: 'good', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}"
}
}
}

return this
13 changes: 11 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ module github.com/pingcap/tidb-operator
require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 // indirect
github.com/coreos/bbolt v1.3.1-coreos.6 // indirect
github.com/coreos/etcd v0.0.0-20180530235116-2b3aa7e1d49d // indirect
github.com/coreos/go-semver v0.2.0 // indirect
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 // indirect
github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea // indirect
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/dnephin/govet v0.0.0-20171012192244-4a96d43e39d3
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.13.1 // indirect
github.com/docker/docker v0.7.3-0.20171023200535-7848b8beb9d3
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.3.3 // indirect
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
Expand Down Expand Up @@ -53,9 +56,11 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo v1.6.0
github.com/onsi/gomega v1.4.1
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pingcap/check v0.0.0-20171206051426-1c287c953996 // indirect
Expand All @@ -67,9 +72,10 @@ require (
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e // indirect
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 // indirect
github.com/renstrom/dedent v1.1.0 // indirect
github.com/russross/blackfriday v1.5.2+incompatible // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/sirupsen/logrus v1.0.6 // indirect
github.com/sirupsen/logrus v1.0.6
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
Expand Down Expand Up @@ -105,7 +111,10 @@ require (
k8s.io/klog v0.2.0 // indirect
k8s.io/kube-openapi v0.0.0-20190320154901-5e45bb682580 // indirect
k8s.io/kubernetes v1.12.5
k8s.io/metrics v0.0.0-20190118124808-33c1aed8dc65 // indirect
k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 // indirect
sigs.k8s.io/yaml v1.1.0 // indirect
vbom.ml/util v0.0.0-20180919145318-efcd4e0f9787 // indirect
)

replace github.com/renstrom/dedent => github.com/lithammer/dedent v1.1.0
18 changes: 18 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e h1:eb0Pzkt15Bm7f2FFYv7sjY7NPFi3cPkS3tv1CcrFBWA=
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4=
github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 h1:HD4PLRzjuCVW79mQ0/pdsalOLHJ+FaEoqJLxfltpb2U=
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw=
github.com/coreos/bbolt v1.3.1-coreos.6 h1:uTXKg9gY70s9jMAKdfljFQcuh4e/BXOM+V+d00KFj3A=
github.com/coreos/bbolt v1.3.1-coreos.6/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v0.0.0-20180530235116-2b3aa7e1d49d h1:X15ii/EYFV9j7Hgj8VwtpSe65vGy7RYrX9oIDgXvRHk=
Expand All @@ -23,12 +27,18 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 h1:d/cVoZOrJPJHKH1NdeUjyVAWKp4OpOT+Q+6T1sH7jeU=
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dnephin/govet v0.0.0-20171012192244-4a96d43e39d3 h1:LrNBULdC8dhFb7VeeIfuLAVq2IOFtVD9zIYh838jWfM=
github.com/dnephin/govet v0.0.0-20171012192244-4a96d43e39d3/go.mod h1:pPTX0MEEoAnfbrAGFj4nSVNhl6YbugRj6eardUZdtGo=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v0.0.0-20170601211448-f5ec1e2936dc h1:S8H7eaOGNNOZ83UGSgpgv4FlCtoBTJxG6GzFNkwJr5Q=
github.com/docker/docker v0.0.0-20170601211448-f5ec1e2936dc/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v0.7.3-0.20171023200535-7848b8beb9d3 h1:zP6PLsIZzP7GvGgoXb3fKlp0hoMdcskl9Je1GaHzFJM=
github.com/docker/docker v0.7.3-0.20171023200535-7848b8beb9d3/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v1.13.1 h1:IkZjBSIc8hBjLpqeAbeE5mca5mNgeatLHBy3GO78BWo=
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
Expand Down Expand Up @@ -113,6 +123,8 @@ github.com/juju/loggo v0.0.0-20180524022052-584905176618 h1:MK144iBQF9hTSwBW/9eJ
github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U=
github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073 h1:WQM1NildKThwdP7qWrNAFGzp4ijNLw8RlgENkaI4MJs=
github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA=
github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffktY=
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
Expand All @@ -125,12 +137,16 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.1 h1:PZSj/UFNaVp3KxrzHOcS7oyuWA7LoOY/77yCTEFu21U=
github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA=
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI=
Expand Down Expand Up @@ -300,6 +316,8 @@ k8s.io/kubernetes v1.12.5 h1:pdQvCJZPGRNVS3CaajKuoPCZKreQaglbRcXwkDwR598=
k8s.io/kubernetes v1.12.5/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/kubernetes v1.12.6 h1:Uh8wsnpa6khE5ylCoLBP0UomxD5h0FK8OWV9MLiSKjI=
k8s.io/kubernetes v1.12.6/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk=
k8s.io/metrics v0.0.0-20190118124808-33c1aed8dc65 h1:0VelqHP6rojigdeX7EfWJ26OCw7PSvCGz7xGg7ukN8U=
k8s.io/metrics v0.0.0-20190118124808-33c1aed8dc65/go.mod h1:a25VAbm3QT3xiVl1jtoF1ueAKQM149UdZ+L93ePfV3M=
k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7 h1:8r+l4bNWjRlsFYlQJnKJ2p7s1YQPj4XyXiJVqDHRx7c=
k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
Expand Down
34 changes: 34 additions & 0 deletions misc/cmd/debug-launcher/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright 2019. PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
"github.com/pingcap/tidb-operator/pkg/tkctl/debug"
"log"
"os"
)

func main() {

iostreams := debug.IOStreams{
In: os.Stdin,
Out: os.Stdout,
ErrOut: os.Stderr,
}
cmd := debug.NewLauncherCmd(iostreams)
if err := cmd.Execute(); err != nil {
log.Fatal(err)
os.Exit(1)
}
}
7 changes: 7 additions & 0 deletions misc/images/debug-launcher/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM bash
ENV TERM=linux

ADD bin/debug-launcher /debug-launcher
ADD entry-point.sh /entry-point.sh
ENTRYPOINT ["/entry-point.sh"]

4 changes: 4 additions & 0 deletions misc/images/debug-launcher/entry-point.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

# launch container under bash to get proper tty
/debug-launcher $@
14 changes: 14 additions & 0 deletions misc/images/tidb-control/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM bash:4.3.48
RUN wget -q http://download.pingcap.org/tidb-latest-linux-amd64.tar.gz \
&& tar xzf tidb-latest-linux-amd64.tar.gz \
&& mv tidb-latest-linux-amd64/bin/pd-ctl \
tidb-latest-linux-amd64/bin/tidb-ctl \
/usr/local/bin/ \
&& rm -rf tidb-latest-linux-amd64.tar.gz tidb-latest-linux-amd64

ADD banner /etc/banner
ADD profile /etc/profile

CMD ["/usr/local/bin/bash", "-l"]


48 changes: 48 additions & 0 deletions misc/images/tidb-control/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Tidb Cluster Control Image

`tidb-control` is a docker image containing the main control tools for tidb cluster: `pd-ctl` and `tidb-ctl`.

# Usage

```shell
$ docker run -it --rm pingcap/tidb-control:latest

# enter docker shell
→ / tidb-ctl
Usage:
tidb-ctl [flags]
tidb-ctl [command]

Available Commands:
base64decode decode base64 value
decoder decode key
etcd control the info about etcd by grpc_gateway
help Help about any command
mvcc MVCC Information
region Region information
schema Schema Information
table Table information

Flags:
-h, --help help for tidb-ctl
--host ip TiDB server host (default 127.0.0.1)
--pdhost ip PD server host (default 127.0.0.1)
--pdport uint16 PD server port (default 2379)
--port uint16 TiDB server port (default 10080)

Use "tidb-ctl [command] --help" for more information about a command.
→ / pd-ctl --help
Usage of pd-ctl:
--cacert string path of file that contains list of trusted SSL CAs.
--cert string path of file that contains X509 certificate in PEM format.
-d, --detach Run pdctl without readline
--key string path of file that contains X509 key in PEM format.
-u, --pd string The pd address (default "http://127.0.0.1:2379")
-V, --version print version information and exit
pflag: help requested

# mount CA certificate files if necessary
$ docker run -v $(pwd)/ca.pem:$(pwd)/ca.pem -v $(pwd)/client.pem:$(pwd)/client.pem -it --rm pingcap/tidb-control:latest
```

PS: `library/bash` is a `busybox` based image, so some dynamic linked binaries like `tikv-ctl` cannot work in this minimal image. If you are looking for `tikv-ctl` or more tools, take a look at [tidb-debug](../tidb-debug/).
9 changes: 9 additions & 0 deletions misc/images/tidb-control/banner
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

████████╗██╗██████╗ ██████╗ ██████╗████████╗██╗
╚══██╔══╝╚═╝██╔══██╗██╔══██╗ ██╔════╝╚══██╔══╝██║
██║ ██╗██║ ██║██████╔╝ ██║ ██║ ██║
██║ ██║██║ ██║██╔══██╗ ██║ ██║ ██║
██║ ██║██████╔╝██████╔╝ ╚██████╗ ██║ ███████╗
╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚══════╝

Welcome to tidb cluster control! (https://github.com/pingcap/tidb)
18 changes: 18 additions & 0 deletions misc/images/tidb-control/profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cat /etc/banner

export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export LS_OPTIONS='--color=auto'

# aliases
alias ls='ls $LS_OPTIONS'

function prompt {
local GREENBOLD="\[\033[1;32m\]"
local RESETCOLOR="\[\e[00m\]"

export PS1="$GREENBOLD→ \w $RESETCOLOR"
export PS2=" | → $RESETCOLOR "
}

prompt
Loading