Skip to content

Commit d58cb44

Browse files
authored
chore(deploy): add all in one yaml file to deploy operator (#6165)
1 parent 21420b5 commit d58cb44

File tree

12 files changed

+247076
-12
lines changed

12 files changed

+247076
-12
lines changed

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ push/%:
4747
.PHONY: deploy
4848
deploy: crd
4949
$(KUBECTL) apply --server-side=true -f $(ROOT)/manifests/crd
50-
$(KUBECTL) apply --server-side=true -f $(ROOT)/manifests/rbac
5150
$(KUBECTL) apply --server-side=true -f $(ROOT)/manifests/deploy
5251

5352
.PHONY: codegen
@@ -79,15 +78,15 @@ overlaygen: bin/overlay-gen
7978
--go-header-file=$(BOILERPLATE_FILE) \
8079
k8s.io/api/core/v1
8180

81+
.PHONY: yamlgen
82+
yamlgen: crd
83+
$(ROOT)/hack/yaml.sh
84+
8285
.PHONY: crd
8386
crd: bin/controller-gen build/crd-modifier
8487
$(CONTROLLER_GEN) crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=$(ROOT)/manifests/crd paths=$(API_PATH)/...
8588
$(BIN_DIR)/crd-modifier -dir $(ROOT)/manifests/crd
8689

87-
# Deprecate this generator, rbac generator cannot well handle nonResourceURLs
88-
.PHONY: rbac
89-
rbac: bin/controller-gen
90-
$(CONTROLLER_GEN) rbac:roleName=tidb-operator output:rbac:artifacts:config=$(ROOT)/manifests/rbac paths=$(API_PATH)/...
9190

9291
.PHONY: tidy
9392
tidy:
@@ -103,7 +102,7 @@ gengo: bin/mockgen
103102
license: bin/license-eye
104103
$(LICENSE_EYE) -c .github/licenserc.yaml header fix
105104

106-
ALL_GEN = tidy codegen crd gengo overlaygen
105+
ALL_GEN = tidy codegen crd gengo overlaygen yamlgen
107106
.PHONY: generate
108107
generate: $(ALL_GEN) license
109108

hack/lib/e2e.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ function e2e::install_crds() {
6464
$KUBECTL apply --server-side=true -f $ROOT/manifests/crd
6565
}
6666

67-
function e2e::install_rbac() {
68-
echo "installing RBAC..."
69-
$KUBECTL -n $V_DEPLOY_NAMESPACE apply --server-side=true -f $ROOT/manifests/rbac
70-
}
71-
7267
function e2e::install_operator() {
7368
echo "installing operator..."
7469
$KUBECTL -n $V_DEPLOY_NAMESPACE apply --server-side=true -f $ROOT/manifests/deploy
@@ -126,7 +121,6 @@ function e2e::prepare() {
126121
e2e::ensure_cert_manager
127122

128123
e2e::install_crds
129-
e2e::install_rbac
130124

131125
# build the operator image and load it into the kind cluster
132126
image::build prestop-checker operator testing-workload backup-manager --push

hack/lib/vars.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ set -o pipefail
2323

2424
ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/../..; pwd -P)
2525

26+
# Set LC_ALL to avoid sort issue
27+
# See https://www.gnu.org/software/coreutils/manual/html_node/ls-invocation.html#ls-invocation
28+
readonly LC_ALL=C
29+
2630
# ---
2731
# Global variables definitions.
2832
# All variables should be in format V_XXX

hack/yaml.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2024 PingCAP, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/..; pwd -P)
22+
source $ROOT/hack/lib/vars.sh
23+
24+
OPERATOR=$ROOT/manifests/tidb-operator.yaml
25+
CRDS=$ROOT/manifests/tidb-operator.crds.yaml
26+
27+
echo -n > $CRDS
28+
echo -n > $OPERATOR
29+
for f in $ROOT/manifests/crd/*.yaml; do
30+
echo "append $f"
31+
cat $f >> $CRDS
32+
cat $f >> $OPERATOR
33+
done
34+
35+
for f in $ROOT/manifests/deploy/*.yaml; do
36+
echo "append $f"
37+
cat $f >> $OPERATOR
38+
done

manifests/rbac/namespace.yaml renamed to manifests/deploy/00-ns.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: Namespace
34
metadata:

manifests/rbac/service_account.yaml renamed to manifests/deploy/01-sa.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: v1
23
kind: ServiceAccount
34
metadata:
File renamed without changes.

manifests/rbac/role_binding.yaml renamed to manifests/deploy/03-role_binding.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: rbac.authorization.k8s.io/v1
23
kind: ClusterRoleBinding
34
metadata:

manifests/deploy/webhook.yaml renamed to manifests/deploy/04-webhook.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
# This policy is defined to avoid unexpected deletion of tikv pods.
23
# We cannot change grace period after it has been set because of this issue
34
# https://github.com/kubernetes/kubernetes/issues/83916.

manifests/deploy/deploy.yaml renamed to manifests/deploy/05-deploy.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
apiVersion: apps/v1
23
kind: Deployment
34
metadata:

0 commit comments

Comments
 (0)