Skip to content

Commit

Permalink
Merge branch 'main' into feature/available-probe-and-conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Oct 31, 2024
2 parents ffd74d7 + 37026cf commit bbbf47c
Show file tree
Hide file tree
Showing 61 changed files with 2,554 additions and 635 deletions.
3 changes: 1 addition & 2 deletions apis/apps/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import (
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:categories={kubeblocks,all}
// +kubebuilder:printcolumn:name="CLUSTER-DEFINITION",type="string",JSONPath=".spec.clusterDefinitionRef",description="ClusterDefinition referenced by cluster."
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.clusterVersionRef",description="Cluster Application Version."
// +kubebuilder:printcolumn:name="CLUSTER-DEFINITION",type="string",JSONPath=".spec.clusterDef",description="ClusterDefinition referenced by cluster."
// +kubebuilder:printcolumn:name="TERMINATION-POLICY",type="string",JSONPath=".spec.terminationPolicy",description="Cluster termination policy."
// +kubebuilder:printcolumn:name="STATUS",type="string",JSONPath=".status.phase",description="Cluster Status."
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
Expand Down
6 changes: 1 addition & 5 deletions config/crd/bases/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ spec:
versions:
- additionalPrinterColumns:
- description: ClusterDefinition referenced by cluster.
jsonPath: .spec.clusterDefinitionRef
jsonPath: .spec.clusterDef
name: CLUSTER-DEFINITION
type: string
- description: Cluster Application Version.
jsonPath: .spec.clusterVersionRef
name: VERSION
type: string
- description: Cluster termination policy.
jsonPath: .spec.terminationPolicy
name: TERMINATION-POLICY
Expand Down
8 changes: 2 additions & 6 deletions controllers/apps/clusterdefinition_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"

appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
appsconfig "github.com/apecloud/kubeblocks/controllers/apps/configuration"
"github.com/apecloud/kubeblocks/pkg/constant"
"github.com/apecloud/kubeblocks/pkg/controller/component"
intctrlutil "github.com/apecloud/kubeblocks/pkg/controllerutil"
Expand Down Expand Up @@ -117,11 +116,8 @@ func (r *ClusterDefinitionReconciler) deletionHandler(rctx intctrlutil.RequestCt
}

func (r *ClusterDefinitionReconciler) deleteExternalResources(rctx intctrlutil.RequestCtx, clusterDef *appsv1.ClusterDefinition) error {
// delete any external resources associated with the cronJob
//
// Ensure that delete implementation is idempotent and safe to invoke
// multiple times for same object.
return appsconfig.DeleteConfigMapFinalizer(r.Client, rctx, clusterDef)
// delete any external resources associated with the cluster definition CR.
return nil
}

func (r *ClusterDefinitionReconciler) available(rctx intctrlutil.RequestCtx, clusterDef *appsv1.ClusterDefinition) error {
Expand Down
6 changes: 1 addition & 5 deletions deploy/helm/crds/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ spec:
versions:
- additionalPrinterColumns:
- description: ClusterDefinition referenced by cluster.
jsonPath: .spec.clusterDefinitionRef
jsonPath: .spec.clusterDef
name: CLUSTER-DEFINITION
type: string
- description: Cluster Application Version.
jsonPath: .spec.clusterVersionRef
name: VERSION
type: string
- description: Cluster termination policy.
jsonPath: .spec.terminationPolicy
name: TERMINATION-POLICY
Expand Down
12 changes: 7 additions & 5 deletions deploy/helm/templates/_dataprotection.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ Render the secret key reference of the encryptionKey.
name: {{ include "kubeblocks.fullname" . }}-secret
key: dataProtectionEncryptionKey
{{- else -}}
{{- $secret := lookup "v1" "Secret" .Release.Namespace $ref.name -}}
{{- if not $secret -}}
{{- fail (printf "Invalid value \".Values.dataProtection.encryptionKeySecretKeyRef\", secret %q is not found from the namespace %q." $ref.name .Release.Namespace) -}}
{{- else if not (hasKey $secret.data $ref.key) -}}
{{- fail (printf "Invalid value \".Values.dataProtection.encryptionKeySecretKeyRef\", secret %q doesn't have key %q." $ref.name $ref.key) -}}
{{- if not .Values.dataProtection.encryptionKeySecretKeyRef.skipValidation -}}
{{- $secret := lookup "v1" "Secret" .Release.Namespace $ref.name -}}
{{- if not $secret -}}
{{- fail (printf "Invalid value \".Values.dataProtection.encryptionKeySecretKeyRef\", secret %q is not found from the namespace %q." $ref.name .Release.Namespace) -}}
{{- else if not (hasKey $secret.data $ref.key) -}}
{{- fail (printf "Invalid value \".Values.dataProtection.encryptionKeySecretKeyRef\", secret %q doesn't have key %q." $ref.name $ref.key) -}}
{{- end -}}
{{- end -}}
name: {{ $ref.name }}
key: {{ $ref.key }}
Expand Down
3 changes: 2 additions & 1 deletion deploy/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ dataProtection:
encryptionKeySecretKeyRef:
name: ""
key: ""
skipValidation: false
enableBackupEncryption: false
backupEncryptionAlgorithm: ""
gcFrequencySeconds: 3600
Expand Down Expand Up @@ -2011,4 +2012,4 @@ vmagent:
crd:
enabled: true

userAgent: kubeblocks
userAgent: kubeblocks
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
position: 2
position: 3
label: Install with helm
collapsible: true
collapsed: true
28 changes: 17 additions & 11 deletions docs/user_docs/installation/install-with-helm/install-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ sidebar_position: 3
sidebar_label: Install Addons
---

# Install addons
# Install Addons

With the release of KubeBlocks v0.8.0, Addons are decoupled from KubeBlocks and some Addons are not installed by default. If you want to use these Addons, install Addons first by index. Or if you uninstalled some Addons, you can follow the steps in this tutorial to install them again.

This tutorial takes etcd as an example. You can replace etcd with the Addon you need.

The official index repo is [KubeBlocks index](https://github.com/apecloud/block-index). The code of all Addons is maintained in the [KubeBlocks Addon repo](https://github.com/apecloud/kubeblocks-addons).

1. (Optional) Add the KubeBlocks repo. If you install KubeBlocks with Helm, just run `helm repo update`.

Expand All @@ -15,32 +21,32 @@ sidebar_label: Install Addons
helm repo update
```

2. View the addon versions.
2. View the Addon versions.

```bash
helm search repo kubeblocks/mariadb --devel --versions
helm search repo kubeblocks/etcd --devel --versions
```

3. Install the addon (take mariadb as example).
3. Install the Addon (take etcd as example). Specify a version with `--version`.

```bash
helm install mariadb kubeblocks/mariadb --namespace kb-system --create-namespace --version 0.9.0
helm install etcd kubeblocks/etcd --namespace kb-system --create-namespace --version x.y.z
```

4. Verify whether this addon is installed.
4. Verify whether this Addon is installed.

The STATUS is `deployed` and this addon is installed successfully.
The STATUS is `deployed` and this Addon is installed successfully.

```bash
helm list -A
>
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
......
mariadb kb-system 1 2024-05-08 17:41:29.112721 +0800 CST deployed mariadb-0.9.0 10.6.15
etcd kb-system 1 2024-10-25 07:18:35.294326176 +0000 UTC deployed etcd-0.9.0 v3.5.6
```

5. (Optional) You can run the command below to disable the addon.
5. (Optional) You can run the command below to disable the Addon.

```bash
helm uninstall mariadb --namespace kb-system
helm uninstall etcd --namespace kb-system
```
41 changes: 22 additions & 19 deletions docs/user_docs/installation/install-with-helm/install-kubeblocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import TabItem from '@theme/TabItem';

KubeBlocks is Kubernetes-native, you can use Helm or kubectl with a YAML file to install it.

To try out KubeBlocks on your local host, you can use the [Playground](./../../try-out-on-playground/try-kubeblocks-on-your-laptop.md) or [create a local Kubernetes test cluster first](./../prerequisite/prepare-a-local-k8s-cluster.md) and then follow the steps in this tutorial to install KubeBlocks.

:::note

If you install KubeBlocks with Helm, to uninstall it, you have to use Helm too.
Expand Down Expand Up @@ -60,15 +62,14 @@ Use Helm and follow the steps below to install KubeBlocks.
1. Create dependent CRDs. Specify the version you want to install.

```bash
kubectl create -f https://github.com/apecloud/kubeblocks/releases/download/vx.x.x/kubeblocks_crds.yaml
kubectl create -f https://github.com/apecloud/kubeblocks/releases/download/vx.y.z/kubeblocks_crds.yaml
```
You can view all versions of kubeblocks, including alpha and beta releases, on the [kubeblocks releases list](https://github.com/apecloud/kubeblocks/releases).

To get stable releases, use this command:
```bash
curl -s "https://api.github.com/repos/apecloud/kubeblocks/releases?per_page=100&page=1" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -V
curl -s "https://api.github.com/repos/apecloud/kubeblocks/releases?per_page=100&page=1" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -V -r
```


2. Add the KubeBlocks Helm repo.

Expand Down Expand Up @@ -97,7 +98,7 @@ Use Helm and follow the steps below to install KubeBlocks.
2. Specify a version with `--version` and run the command below.

```bash
helm install kubeblocks kubeblocks/kubeblocks --namespace kb-system --create-namespace --version="x.x.x"
helm install kubeblocks kubeblocks/kubeblocks --namespace kb-system --create-namespace --version="x.y.z"
```

:::note
Expand All @@ -110,13 +111,14 @@ Use Helm and follow the steps below to install KubeBlocks.

<TabItem value="kubectl" label="Install with kubectl">

KubeBlocks can be installed like any other resource in Kubernetes, through a YAML manifest applied via `kubectl`.
Like any other resource in Kubernetes, KubeBlocks can be installed through a YAML manifest applied via `kubectl`.

Run the following command to install the latest operator manifest for this minor release:
1. Copy the URL of the `kubeblocks.yaml file` for the version you need from the Assets on the [KubeBlocks Release page](https://github.com/apecloud/kubeblocks/releases).
2. Replace the YAML file URL in the command below and run this command to install KubeBlocks.

```bash
kubectl create -f \address.yaml
```
```bash
kubectl create -f https://github.com/apecloud/kubeblocks/releases/download/vx.y.x/kubeblocks.yaml
```

</TabItem>

Expand All @@ -135,14 +137,15 @@ kubectl -n kb-system get pods
If the KubeBlocks Workloads are all ready, KubeBlocks has been installed successfully.

```bash
NAME READY STATUS AGE
kb-addon-snapshot-controller-7b447684d4-q86zf 1/1 Running 33d
kb-addon-csi-hostpath-driver-0 8/8 Running 33d
kb-addon-grafana-54b9cbf65d-k8522 3/3 Running 33d
kb-addon-apecloud-otel-collector-j4thb 1/1 Running 33d
kubeblocks-5b5648bfd9-8jpvv 1/1 Running 33d
kubeblocks-dataprotection-f54c9486c-2nfmr 1/1 Running 33d
kb-addon-alertmanager-webhook-adaptor-76b87f9df8-xb74g 2/2 Running 33d
kb-addon-prometheus-server-0 2/2 Running 33d
kb-addon-prometheus-alertmanager-0 2/2 Running 33d
NAME READY STATUS RESTARTS AGE
alertmanager-webhook-adaptor-8dfc4878d-svzrc 2/2 Running 0 3m56s
grafana-77dfd6959-4gnhp 1/1 Running 0 3m56s
kb-addon-snapshot-controller-546f84b78d-8rjs4 1/1 Running 0 3m56s
kubeblocks-7cf7745685-ddlwk 1/1 Running 0 4m39s
kubeblocks-dataprotection-95fbc79cc-b544l 1/1 Running 0 4m39s
prometheus-alertmanager-5c9fc88996-qltrk 2/2 Running 0 3m56s
prometheus-kube-state-metrics-5dbbf757f5-db9v6 1/1 Running 0 3m56s
prometheus-node-exporter-r6kvl 1/1 Running 0 3m56s
prometheus-pushgateway-8555888c7d-xkgfc 1/1 Running 0 3m56s
prometheus-server-5759b94fc8-686xp 2/2 Running 0 3m56s
```
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ kubectl get crd -o name | grep kubeblocks.io | xargs kubectl delete

<TabItem value="YAML" label="YAML">

You can generate YAMLs from the KubeBlocks chart and uninstall using `kubectl`.
You can generate YAMLs from the KubeBlocks chart and uninstall using `kubectl`. Use `--version x.y.z` to specify a version and make sure the uninstalled version is the same as the installed one.

```bash
helm template kubeblocks kubeblocks/kubeblocks --namespace kb-system | kubectl delete -f -
helm template kubeblocks kubeblocks/kubeblocks --namespace kb-system --version x.y.z | kubectl delete -f -
```

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
position: 1
position: 2
label: Install with kbcli
collapsible: true
collapsed: true
56 changes: 37 additions & 19 deletions docs/user_docs/installation/install-with-kbcli/install-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ sidebar_label: Install Addons

# Install Addons

## Use the index to install an addon
## Use the index to install an Addon

With the release of KubeBlocks v0.8.0, addons are decoupled from KubeBlocks and some addons are not installed by default. If you want to use these addons, add addons first by index.
With the release of KubeBlocks v0.8.0, Addons are decoupled from KubeBlocks and some Addons are not installed by default. If you want to use these Addons, install Addons first by index. Or if you uninstalled some Addons, you can follow the steps in this tutorial to install them again.

The official index repo is [KubeBlocks index](https://github.com/apecloud/block-index). The code of all addons is maintained in the [KubeBlocks addon repo](https://github.com/apecloud/kubeblocks-addons).
This tutorial takes etcd as an example. You can replace etcd with the Addon you need.

The official index repo is [KubeBlocks index](https://github.com/apecloud/block-index). The code of all Addons is maintained in the [KubeBlocks Addon repo](https://github.com/apecloud/kubeblocks-addons).

1. View the index.

Expand All @@ -37,49 +39,65 @@ The official index repo is [KubeBlocks index](https://github.com/apecloud/block-
kbcli addon index update kubeblocks
```

2. (Optional) Search whether the addon exists in the index.
2. (Optional) Search whether the Addon exists in the index.

```bash
kbcli addon search mariadb
kbcli addon search etcd
>
ADDON VERSION INDEX
mariadb 0.7.0 kubeblocks
ADDON VERSION INDEX
etcd 0.7.0 kubeblocks
etcd 0.8.0 kubeblocks
etcd 0.9.0 kubeblocks
```

3. Install the addon.
3. Install the Addon.

If there are multiple index sources and versions for an addon, you can specify them by adding flags. The system installs the latest version in the `kubeblocks` index by default.
If there are multiple index sources and versions for an Addon, you can specify an index by `--index` and a version by `--version`. The system installs the latest version in the `kubeblocks` index by default.

```bash
kbcli addon install mariadb --index kubeblocks --version 0.7.0
kbcli addon install etcd --index kubeblocks --version x.y.z
```

**What's next**
After the addon is installed, you can list and enable it.
After the Addon is installed, you can list and enable it.
## List addons
## List Addons
To list supported addons, run `kbcli addon list` command.
To list supported Addons, run `kbcli addon list` command.
## Enable/Disable addons
## Enable/Disable Addons
To manually enable or disable addons, follow the steps below.
To manually enable or disable Addons, follow the steps below.
***Steps:***
1. To enable an addon, use `kbcli addon enable`.
1. To enable an Addon, use `kbcli addon enable`.
***Example***
```bash
kbcli addon enable snapshot-controller
kbcli addon enable etcd
```
To disable an addon, use `kbcli addon disable`.
To disable an Addon, use `kbcli addon disable`.
2. List the addons again to check whether it is enabled.
2. List the Addons again to check whether it is enabled.
```bash
kbcli addon list
```
## Uninstall Addons
You can also uninstall the Addons. If you have created a related cluster, delete the cluster first.
```bash
kbcli cluster delete <name>
```
Uninstall an Addon.
```bash
kbcli addon uninstall etcd
```
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ You can install kbcli with `curl` or `brew`.
2. Specify a version with `-s` and run the command below.

```bash
curl -fsSL https://kubeblocks.io/installer/install_cli.sh | bash -s x.x.x
curl -fsSL https://kubeblocks.io/installer/install_cli.sh | bash -s x.y.z
```
You can view all versions of kbcli, including alpha and beta releases, on the [kbcli releases list](https://github.com/apecloud/kbcli/releases).

To get stable releases, use this command:
```bash
curl -s "https://api.github.com/repos/apecloud/kbcli/releases?per_page=100&page=1" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -V
curl -s "https://api.github.com/repos/apecloud/kbcli/releases?per_page=100&page=1" | jq -r '.[] | select(.prerelease == false) | .tag_name' | sort -V -r
```

:::note
Expand Down Expand Up @@ -86,7 +86,7 @@ You can install kbcli with `curl` or `brew`.
brew search kbcli
# Specify a version
brew install kbcli@x.x.x
brew install kbcli@x.y.z
```

3. Verify that kbcli is successfully installed.
Expand Down
Loading

0 comments on commit bbbf47c

Please sign in to comment.