Skip to content

Commit 928b3ce

Browse files
authored
chore: kb uninstall only remove crds that match label (#505) (#616)
1 parent a074805 commit 928b3ce

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

docs/user_docs/cli/kbcli_cluster_create_kafka.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ kbcli cluster create kafka NAME [flags]
3434
--memory float Memory, the unit is Gi. Value range [0.5, 1000]. (default 0.5)
3535
--meta-storage float Metadata Storage size, the unit is Gi. Value range [1, 10000]. (default 5)
3636
--meta-storage-class string The StorageClass for Kafka Metadata Storage.
37-
--mode string Mode for Kafka kraft cluster, 'combined' is combined Kafka controller and broker,'separated' is broker and controller running independently. Legal values [combined, separated]. (default "combined")
37+
--mode string Mode for Kafka kraft cluster, 'combined' is combined Kafka controller and broker,'separated' is broker and controller running independently. Legal values [combined, separated, withZookeeper-10]. (default "combined")
3838
--monitor-enable Enable monitor for Kafka. (default true)
3939
--monitor.limit.cpu float (default 0.5)
4040
--monitor.limit.memory float (default 1)
@@ -47,6 +47,7 @@ kbcli cluster create kafka NAME [flags]
4747
--pod-anti-affinity string Pod anti-affinity type, one of: (Preferred, Required) (default "Preferred")
4848
--replicas int The number of Kafka broker replicas for combined mode. Legal values [1, 3, 5]. (default 1)
4949
--sasl-enable Enable authentication using SASL/PLAIN for Kafka.
50+
--sasl-scram-enable Enable authentication using SASL/SCRAM for Kafka.
5051
--storage float Data Storage size, the unit is Gi. Value range [1, 10000]. (default 10)
5152
--storage-class string The StorageClass for Kafka Data Storage.
5253
--storage-enable Enable storage for Kafka.

pkg/cmd/kubeblocks/kubeblocks_objects.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package kubeblocks
2222
import (
2323
"context"
2424
"encoding/json"
25+
"fmt"
2526
"strings"
2627

2728
corev1 "k8s.io/api/core/v1"
@@ -82,7 +83,9 @@ func getKBObjects(dynamic dynamic.Interface, namespace string, addons []*extensi
8283
ctx := context.TODO()
8384

8485
// get CRDs
85-
crds, err := dynamic.Resource(types.CRDGVR()).List(ctx, metav1.ListOptions{})
86+
crds, err := dynamic.Resource(types.CRDGVR()).List(ctx, metav1.ListOptions{
87+
LabelSelector: fmt.Sprintf("%s=%s", constant.AppNameLabelKey, types.KubeBlocksChartName),
88+
})
8689
appendErr(err)
8790
kbObjs[types.CRDGVR()] = &unstructured.UnstructuredList{}
8891

pkg/cmd/kubeblocks/kubeblocks_objects_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,15 @@ func mockName() string {
155155
}
156156

157157
func mockCRD() []runtime.Object {
158+
label := map[string]string{constant.AppNameLabelKey: types.KubeBlocksChartName}
158159
clusterCRD := v1.CustomResourceDefinition{
159160
TypeMeta: metav1.TypeMeta{
160161
Kind: "CustomResourceDefinition",
161162
APIVersion: "apiextensions.k8s.io/v1",
162163
},
163164
ObjectMeta: metav1.ObjectMeta{
164-
Name: "clusters.apps.kubeblocks.io",
165+
Name: "clusters.apps.kubeblocks.io",
166+
Labels: label,
165167
},
166168
Spec: v1.CustomResourceDefinitionSpec{
167169
Group: types.AppsAPIGroup,
@@ -174,7 +176,8 @@ func mockCRD() []runtime.Object {
174176
APIVersion: "apiextensions.k8s.io/v1",
175177
},
176178
ObjectMeta: metav1.ObjectMeta{
177-
Name: "clusterdefinitions.apps.kubeblocks.io",
179+
Name: "clusterdefinitions.apps.kubeblocks.io",
180+
Labels: label,
178181
},
179182
Spec: v1.CustomResourceDefinitionSpec{
180183
Group: types.AppsAPIGroup,
@@ -188,7 +191,8 @@ func mockCRD() []runtime.Object {
188191
APIVersion: "apiextensions.k8s.io/v1",
189192
},
190193
ObjectMeta: metav1.ObjectMeta{
191-
Name: "actionsets.dataprotection.kubeblocks.io",
194+
Name: "actionsets.dataprotection.kubeblocks.io",
195+
Labels: label,
192196
},
193197
Spec: v1.CustomResourceDefinitionSpec{
194198
Group: types.DPAPIGroup,

0 commit comments

Comments
 (0)