Skip to content

Commit 314e4d4

Browse files
authored
chore(release): support release crds and deploy files (#6197)
1 parent 4bf727e commit 314e4d4

File tree

21 files changed

+125
-317441
lines changed

21 files changed

+125
-317441
lines changed

.github/workflows/release-v2.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: release-v2
2+
3+
run-name: Release ${{ github.ref_name }}
4+
5+
on:
6+
push:
7+
tags:
8+
- "v2.*.*"
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: make release ${{ github.ref_name }}
16+
run: V_RELEASE=${{ github.ref_name }} make release
17+
- name: release
18+
uses: softprops/action-gh-release@v2
19+
with:
20+
files: |
21+
_output/manifests/tidb-operator.crds.yaml
22+
_output/manifests/tidb-operator.yaml
23+

Makefile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ KIND_VERSION ?= v0.24.0
2929
# TODO: use kubectl in _output
3030
KUBECTL = kubectl -n tidb-admin --context kind-tidb-operator
3131

32-
ALL_CMD = operator prestop-checker testing-workload backup-manager
32+
ALL_CMD = tidb-operator prestop-checker testing-workload backup-manager
3333
.PHONY: build
3434
build: $(addprefix build/,$(ALL_CMD))
3535
build/%:
@@ -46,9 +46,9 @@ push/%:
4646
$(ROOT)/hack/image.sh $* --push
4747

4848
.PHONY: deploy
49-
deploy: crd
50-
$(KUBECTL) apply --server-side=true -f $(ROOT)/manifests/crd
51-
$(KUBECTL) apply --server-side=true -f $(ROOT)/manifests/deploy
49+
deploy: release
50+
$(KUBECTL) apply --server-side=true -f $(OUTPUT_DIR)/manifests/tidb-operator.crds.yaml
51+
$(KUBECTL) apply --server-side=true -f $(OUTPUT_DIR)/manifests/tidb-operator.yaml
5252

5353
.PHONY: codegen
5454
codegen: bin/deepcopy-gen bin/register-gen bin/overlay-gen
@@ -86,9 +86,9 @@ runtimegen: bin/runtime-gen
8686
--go-header-file=$(BOILERPLATE_FILE) \
8787
github.com/pingcap/tidb-operator/api/v2/core/v1alpha1
8888

89-
.PHONY: yamlgen
90-
yamlgen: crd
91-
$(ROOT)/hack/yaml.sh
89+
.PHONY: release
90+
release: bin/helm crd
91+
$(ROOT)/hack/release.sh
9292

9393
.PHONY: doc
9494
doc: bin/mdtoc
@@ -114,7 +114,7 @@ gengo: bin/mockgen
114114
license: bin/license-eye
115115
$(LICENSE_EYE) -c .github/licenserc.yaml header fix
116116

117-
ALL_GEN = tidy codegen crd gengo overlaygen runtimegen yamlgen doc
117+
ALL_GEN = tidy codegen crd gengo overlaygen runtimegen doc
118118
.PHONY: generate
119119
generate: $(ALL_GEN) license
120120

@@ -146,15 +146,15 @@ unit:
146146
check: lint unit verify
147147

148148
.PHONY: e2e/prepare
149-
e2e/prepare: bin/kind crd
149+
e2e/prepare: bin/kind release
150150
$(ROOT)/hack/e2e.sh --prepare
151151

152152
.PHONY: e2e/run
153153
e2e/run:
154154
$(ROOT)/hack/e2e.sh run $(GINKGO_OPTS)
155155

156156
.PHONY: e2e
157-
e2e: bin/kind crd
157+
e2e: bin/kind release
158158
$(ROOT)/hack/e2e.sh --prepare run $(GINKGO_OPTS)
159159

160160
.PHONY: e2e/reinstall-operator
@@ -228,3 +228,8 @@ bin/ginkgo:
228228
MDTOC = $(BIN_DIR)/mdtoc
229229
bin/mdtoc:
230230
$(ROOT)/hack/download.sh go_install $(MDTOC) sigs.k8s.io/mdtoc v1.1.0
231+
232+
.PHONY: bin/helm
233+
HELM = $(BIN_DIR)/helm
234+
bin/helm:
235+
$(ROOT)/hack/download.sh go_install $(HELM) helm.sh/helm/v3/cmd/helm v3.17.3 "version --template='{{.Version}}' | xargs printf '%s.3'"

charts/tidb-operator/Chart.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
apiVersion: v1
1+
apiVersion: v2
22
description: tidb-operator Helm chart for Kubernetes
33
name: tidb-operator
4-
version: v2-canary
5-
appVersion: v2-canary
64
home: https://github.com/pingcap/tidb-operator
75
sources:
86
- https://github.com/pingcap/tidb-operator
@@ -20,3 +18,9 @@ maintainers:
2018
2119
- name: fgksgf
2220
21+
22+
kubeVersion: ">=1.30.0"
23+
24+
# will be set when package
25+
version: v0.0.0
26+
appVersion: v0.0.0

charts/tidb-operator/templates/deployment.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ metadata:
99
namespace: {{ .Release.Namespace }}
1010
labels:
1111
app.kubernetes.io/name: {{ template "chart.name" . }}
12-
app.kubernetes.io/managed-by: {{ .Release.Service }}
1312
app.kubernetes.io/instance: {{ .Release.Name }}
1413
app.kubernetes.io/component: tidb-operator
15-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
1614
spec:
1715
replicas: {{ .Values.operator.replicas }}
1816
selector:
@@ -44,7 +42,7 @@ spec:
4442
{{- end }}
4543
containers:
4644
- command:
47-
- /operator
45+
- /tidb-operator
4846
args:
4947
- --backup-manager-image={{ .Values.backupManager.image }}
5048
{{- if .Values.operator.extraArgs }}

charts/tidb-operator/templates/rbac.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,41 @@ metadata:
1010
namespace: {{ .Release.Namespace }}
1111
labels:
1212
app.kubernetes.io/name: {{ template "chart.name" . }}
13-
app.kubernetes.io/managed-by: {{ .Release.Service }}
1413
app.kubernetes.io/instance: {{ .Release.Name }}
1514
app.kubernetes.io/component: tidb-operator
16-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
1715
---
1816
apiVersion: rbac.authorization.k8s.io/v1
1917
kind: ClusterRole
2018
metadata:
2119
name: {{ .Release.Name }}:tidb-operator
2220
labels:
2321
app.kubernetes.io/name: {{ template "chart.name" . }}
24-
app.kubernetes.io/managed-by: {{ .Release.Service }}
2522
app.kubernetes.io/instance: {{ .Release.Name }}
2623
app.kubernetes.io/component: tidb-operator
27-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
2824
rules:
2925
- nonResourceURLs: ["/metrics"]
3026
verbs: ["get"]
3127
- apiGroups: [""]
32-
resources: ["configmaps", "events", "persistentvolumeclaims", "pods", "services"]
33-
verbs: ["*"]
28+
resources: ["configmaps", "persistentvolumeclaims", "pods", "services"]
29+
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
30+
- apiGroups: [""]
31+
resources: ["events"]
32+
verbs: ["create"]
3433
- apiGroups: [""]
3534
resources: ["nodes", "persistentvolumes", "secrets"]
3635
verbs: ["get", "list", "watch"]
3736
- apiGroups: ["apps"]
3837
resources: ["controllerrevisions"]
39-
verbs: ["*"]
38+
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
4039
- apiGroups: ["batch"]
4140
resources: ["jobs"]
42-
verbs: ["*"]
41+
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
4342
- apiGroups: ["storage.k8s.io"]
4443
resources: ["storageclasses", "volumeattributesclasses"]
4544
verbs: ["get", "list", "watch"]
4645
- apiGroups: ["coordination.k8s.io"]
4746
resources: ["leases"]
48-
verbs: ["*"]
47+
verbs: ["get", "list", "watch", "create", "delete", "update", "patch"]
4948
- apiGroups: ["core.pingcap.com"]
5049
resources: ["*"]
5150
verbs: ["*"]
@@ -59,10 +58,8 @@ metadata:
5958
name: {{ .Release.Name }}:tidb-operator
6059
labels:
6160
app.kubernetes.io/name: {{ template "chart.name" . }}
62-
app.kubernetes.io/managed-by: {{ .Release.Service }}
6361
app.kubernetes.io/instance: {{ .Release.Name }}
6462
app.kubernetes.io/component: tidb-operator
65-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
6663
roleRef:
6764
apiGroup: rbac.authorization.k8s.io
6865
kind: ClusterRole

charts/tidb-operator/templates/webhook.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ metadata:
1010
name: "delete-pod.policy.pingcap.com"
1111
labels:
1212
app.kubernetes.io/name: {{ template "chart.name" . }}
13-
app.kubernetes.io/managed-by: {{ .Release.Service }}
1413
app.kubernetes.io/instance: {{ .Release.Name }}
1514
app.kubernetes.io/component: webhook
16-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
1715
spec:
1816
failurePolicy: Fail
1917
matchConstraints:
@@ -32,10 +30,8 @@ metadata:
3230
name: "delete-pod.policy.pingcap.com"
3331
labels:
3432
app.kubernetes.io/name: {{ template "chart.name" . }}
35-
app.kubernetes.io/managed-by: {{ .Release.Service }}
3633
app.kubernetes.io/instance: {{ .Release.Name }}
3734
app.kubernetes.io/component: webhook
38-
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
3935
spec:
4036
policyName: "delete-pod.policy.pingcap.com"
4137
validationActions: [Deny]
File renamed without changes.
Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env bash
21
# Copyright 2024 PingCAP, Inc.
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,27 +11,3 @@
1211
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1312
# See the License for the specific language governing permissions and
1413
# 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

hack/lib/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function build::all() {
4646
shift
4747
done
4848
if [[ ${#targets[@]} -eq 0 ]]; then
49-
targets=("operator" "prestop-checker" "testing-workload" "backup-manager")
49+
targets=("tidb-operator" "prestop-checker" "testing-workload" "backup-manager")
5050
fi
5151

5252
local platforms

hack/lib/e2e.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function e2e::install_crds() {
6666

6767
function e2e::install_operator() {
6868
echo "installing operator..."
69-
$KUBECTL -n $V_DEPLOY_NAMESPACE apply --server-side=true -f $ROOT/manifests/deploy
69+
$KUBECTL -n $V_DEPLOY_NAMESPACE apply --server-side=true -f $OUTPUT_DIR/manifests/tidb-operator.yaml
7070

7171
echo "waiting for operator to be ready..."
7272
$KUBECTL -n $V_DEPLOY_NAMESPACE wait --for=condition=Available --timeout=5m deployment/tidb-operator
@@ -80,7 +80,7 @@ function e2e::uninstall_operator() {
8080
fi
8181

8282
echo "uninstalling operator..."
83-
$KUBECTL -n $V_DEPLOY_NAMESPACE delete -f $ROOT/manifests/deploy
83+
$KUBECTL -n $V_DEPLOY_NAMESPACE delete -f $OUTPUT_DIR/manifests/tidb-operator.yaml
8484

8585
echo "waiting for operator to be deleted..."
8686
$KUBECTL -n $V_DEPLOY_NAMESPACE wait --for=delete --timeout=5m deployment/tidb-operator
@@ -123,7 +123,7 @@ function e2e::prepare() {
123123
e2e::install_crds
124124

125125
# build the operator image and load it into the kind cluster
126-
image::build prestop-checker operator testing-workload backup-manager --push
126+
image::build prestop-checker tidb-operator testing-workload backup-manager --push
127127
e2e::uninstall_operator
128128
e2e::install_operator
129129

0 commit comments

Comments
 (0)