Skip to content

Commit db29299

Browse files
author
smiletan
authored
Merge pull request #412 from intelligentfu8/doris-cli
[Feature]Doris cli
2 parents bec13e6 + e64e95e commit db29299

File tree

20 files changed

+907
-14
lines changed

20 files changed

+907
-14
lines changed

Dockerfile_doris_debug

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ WORKDIR /workspace
2424
COPY . .
2525

2626
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o doris-debug cmd/doris-debug/main.go
27+
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o dorisctl cmd/dorisctl/main.go
2728

2829
FROM ubuntu:22.04
2930

3031
WORKDIR /
3132

3233
COPY --from=builder /workspace/doris-debug .
33-
34+
COPY --from=builder /workspace/dorisctl .
3435

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ endif
113113
.PHONY: build
114114
build: manifests generate fmt vet helm ## Build manager binary.
115115
go build -ldflags=$(LDFLAGS) -o bin/dorisoperator cmd/operator/main.go
116+
go build -ldflags=$(LDFLAGS) -o bin/dorisctrl cmd/dorisctl/main.go
117+
go build -o bin/doris-debug cmd/doris-debug/main.go
116118

117119
.PHONY: run
118120
run: manifests generate fmt vet ## Run a controller from your host.

api/disaggregated/v1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ type FeSpec struct {
104104

105105
// ComputeGroup describe the specification that a group of compute node.
106106
type ComputeGroup struct {
107-
//the unique identifier of compute group, first register in fe will use UniqueId as cluster name.
107+
//the unique identifier of compute group, first register in fe will use UniqueId as compute group name.
108108
UniqueId string `json:"uniqueId"`
109109

110110
// EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.

api/disaggregated/v1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dorisctl/main.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package main
18+
19+
import (
20+
"fmt"
21+
"github.com/apache/doris-operator/cmd/dorisctl/root_command"
22+
"os"
23+
)
24+
25+
func main() {
26+
27+
cmd, err := root_command.NewDorisctlCommand(os.Stdout)
28+
if err != nil {
29+
fmt.Println("new dorisctl failed," + err.Error())
30+
os.Exit(1)
31+
}
32+
if err := cmd.Execute(); err != nil {
33+
fmt.Println("command execute failed, " + err.Error())
34+
os.Exit(1)
35+
}
36+
}

cmd/dorisctl/root_command/cmd.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package root_command
18+
19+
import (
20+
"github.com/apache/doris-operator/pkg/common/cmd/get"
21+
"github.com/apache/doris-operator/pkg/common/cmd/templates"
22+
cmdutil "github.com/apache/doris-operator/pkg/common/cmd/util"
23+
"github.com/spf13/cobra"
24+
"io"
25+
)
26+
27+
func NewDorisctlCommand(out io.Writer) (*cobra.Command, error) {
28+
cmds := &cobra.Command{
29+
Use: "dorisctl",
30+
Short: "dorisctl controls the doris cluster manager",
31+
Long: templates.LongDesc(`
32+
dorisctl controls the doris cluster manager.
33+
`),
34+
}
35+
36+
var dc cmdutil.DorisConfig
37+
38+
flags := cmds.PersistentFlags()
39+
flags.StringVar(&dc.FeHost, "fe-host", "", "The fe access address.")
40+
flags.StringVar(&dc.User, "user", "", "The name of user to access doris.")
41+
flags.StringVar(&dc.Password, "password", "", "The password of login in doris.")
42+
flags.IntVar(&dc.QueryPort, "query-port", 9030, "The FE mysql protocol listen port")
43+
groups := templates.CommandGroups{
44+
{
45+
Message: "Basic Commands (Beginner):",
46+
Commands: []*cobra.Command{
47+
get.NewCmdGet("dorisctl", &dc, out),
48+
},
49+
},
50+
}
51+
52+
groups.Add(cmds)
53+
return cmds, nil
54+
}

config/crd/bases/crds.yaml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10386,6 +10386,14 @@ spec:
1038610386
type: string
1038710387
type: object
1038810388
type: object
10389+
enableWorkloadGroup:
10390+
description: |-
10391+
EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
10392+
Default value is 'false'.
10393+
Enabling it means that the container must be started in privileged mode.
10394+
Please confirm whether the host machine and k8s cluster allow it.
10395+
Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
10396+
type: boolean
1038910397
envVars:
1039010398
description: EnvVars is a slice of environment variables that
1039110399
are added to the pods, the default is empty.
@@ -11310,7 +11318,7 @@ spec:
1131011318
type: object
1131111319
type: object
1131211320
service:
11313-
description: export metaservice for accessing from outside k8s.
11321+
description: export service for accessing from outside k8s.
1131411322
properties:
1131511323
annotations:
1131611324
additionalProperties:
@@ -11433,7 +11441,7 @@ spec:
1143311441
type: array
1143411442
uniqueId:
1143511443
description: the unique identifier of compute group, first register
11436-
in fe will use UniqueId as cluster name.
11444+
in fe will use UniqueId as compute group name.
1143711445
type: string
1143811446
required:
1143911447
- uniqueId
@@ -13546,7 +13554,7 @@ spec:
1354613554
type: object
1354713555
type: object
1354813556
service:
13549-
description: export metaservice for accessing from outside k8s.
13557+
description: export service for accessing from outside k8s.
1355013558
properties:
1355113559
annotations:
1355213560
additionalProperties:
@@ -13659,6 +13667,25 @@ spec:
1365913667
type: object
1366013668
type: array
1366113669
type: object
13670+
kerberosInfo:
13671+
description: KerberosInfo contains a series of access key files, Provides
13672+
access to kerberos.
13673+
properties:
13674+
keytabPath:
13675+
description: |-
13676+
KeytabPath is the path where the Secret is finally stored inside the pod. default '/etc/keytab/'.
13677+
It is not recommended to modify it unless necessary.
13678+
This path is the path filled in when configuring "hadoop.kerberos.keytab".
13679+
type: string
13680+
keytabSecretName:
13681+
description: "SecretName is the name of sercet within '*.keytab'
13682+
files,\nrefer to the following command to create a Secret :\n\t'kubectl
13683+
create secret generic {secret-name} --from-file=. '"
13684+
type: string
13685+
krb5ConfigMap:
13686+
description: Krb5ConfigMap is the name of configmap within 'krb5.conf'
13687+
type: string
13688+
type: object
1366213689
metaService:
1366313690
description: MetaService describe the metaservice that cluster want
1366413691
to storage metadata.
@@ -15775,7 +15802,7 @@ spec:
1577515802
type: object
1577615803
type: object
1577715804
service:
15778-
description: export metaservice for accessing from outside k8s.
15805+
description: export service for accessing from outside k8s.
1577915806
properties:
1578015807
annotations:
1578115808
additionalProperties:
@@ -15982,6 +16009,10 @@ spec:
1598216009
description: Phase represent the stage of reconciling.
1598316010
type: string
1598416011
type: object
16012+
observedGeneration:
16013+
description: is the most recent generation observed for DorisDisaggregatedCluster
16014+
format: int64
16015+
type: integer
1598516016
type: object
1598616017
type: object
1598716018
served: true

config/crd/bases/disaggregated.cluster.doris.com_dorisdisaggregatedclusters.yaml

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,14 @@ spec:
12591259
type: string
12601260
type: object
12611261
type: object
1262+
enableWorkloadGroup:
1263+
description: |-
1264+
EnableWorkloadGroup is a switch that determines whether the doris cluster enables the workload group.
1265+
Default value is 'false'.
1266+
Enabling it means that the container must be started in privileged mode.
1267+
Please confirm whether the host machine and k8s cluster allow it.
1268+
Doris workloadgroup reference document: https://doris.apache.org/docs/admin-manual/resource-admin/workload-group
1269+
type: boolean
12621270
envVars:
12631271
description: EnvVars is a slice of environment variables that
12641272
are added to the pods, the default is empty.
@@ -2183,7 +2191,7 @@ spec:
21832191
type: object
21842192
type: object
21852193
service:
2186-
description: export metaservice for accessing from outside k8s.
2194+
description: export service for accessing from outside k8s.
21872195
properties:
21882196
annotations:
21892197
additionalProperties:
@@ -2306,7 +2314,7 @@ spec:
23062314
type: array
23072315
uniqueId:
23082316
description: the unique identifier of compute group, first register
2309-
in fe will use UniqueId as cluster name.
2317+
in fe will use UniqueId as compute group name.
23102318
type: string
23112319
required:
23122320
- uniqueId
@@ -4419,7 +4427,7 @@ spec:
44194427
type: object
44204428
type: object
44214429
service:
4422-
description: export metaservice for accessing from outside k8s.
4430+
description: export service for accessing from outside k8s.
44234431
properties:
44244432
annotations:
44254433
additionalProperties:
@@ -4532,6 +4540,25 @@ spec:
45324540
type: object
45334541
type: array
45344542
type: object
4543+
kerberosInfo:
4544+
description: KerberosInfo contains a series of access key files, Provides
4545+
access to kerberos.
4546+
properties:
4547+
keytabPath:
4548+
description: |-
4549+
KeytabPath is the path where the Secret is finally stored inside the pod. default '/etc/keytab/'.
4550+
It is not recommended to modify it unless necessary.
4551+
This path is the path filled in when configuring "hadoop.kerberos.keytab".
4552+
type: string
4553+
keytabSecretName:
4554+
description: "SecretName is the name of sercet within '*.keytab'
4555+
files,\nrefer to the following command to create a Secret :\n\t'kubectl
4556+
create secret generic {secret-name} --from-file=. '"
4557+
type: string
4558+
krb5ConfigMap:
4559+
description: Krb5ConfigMap is the name of configmap within 'krb5.conf'
4560+
type: string
4561+
type: object
45354562
metaService:
45364563
description: MetaService describe the metaservice that cluster want
45374564
to storage metadata.
@@ -6648,7 +6675,7 @@ spec:
66486675
type: object
66496676
type: object
66506677
service:
6651-
description: export metaservice for accessing from outside k8s.
6678+
description: export service for accessing from outside k8s.
66526679
properties:
66536680
annotations:
66546681
additionalProperties:
@@ -6855,6 +6882,10 @@ spec:
68556882
description: Phase represent the stage of reconciling.
68566883
type: string
68576884
type: object
6885+
observedGeneration:
6886+
description: is the most recent generation observed for DorisDisaggregatedCluster
6887+
format: int64
6888+
type: integer
68586889
type: object
68596890
type: object
68606891
served: true

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ toolchain go1.23.6
77
require (
88
github.com/DATA-DOG/go-sqlmock v1.5.2
99
github.com/FoundationDB/fdb-kubernetes-operator v1.36.0
10+
github.com/MakeNowJust/heredoc v1.0.0
1011
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1112
github.com/go-sql-driver/mysql v1.8.1
1213
github.com/jmoiron/sqlx v1.4.0
1314
github.com/magiconair/properties v1.8.7
1415
github.com/onsi/ginkgo/v2 v2.21.0
1516
github.com/onsi/gomega v1.35.1
17+
github.com/russross/blackfriday/v2 v2.1.0
18+
github.com/spf13/cobra v1.8.1
1619
github.com/spf13/viper v1.16.0
20+
github.com/tidwall/gjson v1.18.0
1721
k8s.io/api v0.32.0
1822
k8s.io/apimachinery v0.32.0
1923
k8s.io/client-go v0.32.0
@@ -48,6 +52,7 @@ require (
4852
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
4953
github.com/google/uuid v1.6.0 // indirect
5054
github.com/hashicorp/hcl v1.0.0 // indirect
55+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5156
github.com/josharian/intern v1.0.0 // indirect
5257
github.com/json-iterator/go v1.1.12 // indirect
5358
github.com/mailru/easyjson v0.7.7 // indirect
@@ -66,6 +71,8 @@ require (
6671
github.com/spf13/jwalterweatherman v1.1.0 // indirect
6772
github.com/spf13/pflag v1.0.5 // indirect
6873
github.com/subosito/gotenv v1.4.2 // indirect
74+
github.com/tidwall/match v1.1.1 // indirect
75+
github.com/tidwall/pretty v1.2.0 // indirect
6976
github.com/x448/float16 v0.8.4 // indirect
7077
go.uber.org/multierr v1.11.0 // indirect
7178
go.uber.org/zap v1.27.0 // indirect

0 commit comments

Comments
 (0)