Skip to content

Commit

Permalink
Merge pull request #83 from Altinity/release-0.2.2
Browse files Browse the repository at this point in the history
Release 0.2.2
  • Loading branch information
alex-zaitsev committed Apr 30, 2019
2 parents 1b4a27b + 44b0604 commit 7934c83
Show file tree
Hide file tree
Showing 41 changed files with 1,808 additions and 254 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@

# Skip log folder
log
dev/log
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ ClickHouse Operator is in beta. You can use it at your own risk. There may be ba

The ClickHouse Operator for Kubernetes currently provides the following:

- Creates cluster of the ClickHouse database based on Custom Resource [specification][crd_spec] provided
- Supports Storage customization (VolumeClaim templates)
- Supports Pod template customization (Volume and Container templates)
- Supports ClickHouse configuration customization (including Zookeeper integration)
- Supports ClickHouse metrics export to Prometheus
- Creates ClickHouse cluster based on Custom Resource [specification][crd_spec] provided
- Storage customization (VolumeClaim templates)
- Pod template customization (Volume and Container templates)
- ClickHouse configuration customization (including Zookeeper integration)
- ClickHouse cluster scaling including automatic schema propagation
- ClickHouse cluster version upgrades
- Exporting ClickHouse metrics to Prometheus

## Requirements

Expand All @@ -40,11 +42,14 @@ The ClickHouse Operator for Kubernetes currently provides the following:
* Adding shards and replicas
* [Automatic schema creation][schema_migration]
* [Update ClickHouse version][update_clickhouse_version]
* [Update Operator version][update_operator]

**Monitoring**
* [Prometheus & clickhouse-operator integration][prometheus_setup]
* [Grafana & Prometheus integration][grafana_setup]

**All docs**
* [All available docs list][all_docs_list]
## License

Copyright (c) 2019, Altinity Ltd and/or its affiliates. All rights reserved.
Expand All @@ -65,5 +70,7 @@ See [LICENSE](./LICENSE) for more details.
[storage]: ./docs/storage.md
[update_cluster_add_replication]: ./docs/chi_update_add_replication.md
[update_clickhouse_version]: ./docs/chi_update_clickhouse_version.md
[update_operator]: ./docs/operator_upgrade.md
[schema_migration]: ./docs/schema_migration.md
[operator_configuration]: ./docs/operator_configuration.md
[all_docs_list]: ./docs/README.md
6 changes: 0 additions & 6 deletions build_binary.sh

This file was deleted.

12 changes: 0 additions & 12 deletions build_image.sh

This file was deleted.

9 changes: 0 additions & 9 deletions build_image_dev.sh

This file was deleted.

3 changes: 0 additions & 3 deletions clean_binary.sh

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/clickhouse-operator/app/clickhouse_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
)

// Version defines current build versionRequest
const Version = "0.2.0-beta"
const Version = "0.2.2"

// Prometheus exporter defaults
const (
Expand Down
11 changes: 11 additions & 0 deletions dev/binary_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Build clickhouse-operator
# Do not forget to update version

source ./binary_build_config.sh

#CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${CUR_DIR}/clickhouse-operator ${SRC_ROOT}/cmd/clickhouse-operator
CGO_ENABLED=0 go build -o ${OPERATOR_BIN} ${SRC_ROOT}/cmd/clickhouse-operator

exit $?
7 changes: 7 additions & 0 deletions dev/binary_build_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Build configuration options

CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
SRC_ROOT=$(realpath ${CUR_DIR}/..)
OPERATOR_BIN=${CUR_DIR}/clickhouse-operator
8 changes: 8 additions & 0 deletions dev/binary_clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Delete clickhouse-operator
# Do not forget to update version

source ./binary_build_config.sh

rm -f ${OPERATOR_BIN}
15 changes: 15 additions & 0 deletions dev/image_build_altinity.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Production docker image builder

# Externally configurable build-dependent options
TAG="${TAG:-altinity/clickhouse-operator:dev}"
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN:-altinitybuilds}"
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
MINIKUBE="${MINIKUBE:-no}"

TAG="${TAG}" \
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
MINIKUBE="${MINIKUBE}" \
./image_build_universal.sh
15 changes: 15 additions & 0 deletions dev/image_build_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Dev docker image builder

# Externally configurable build-dependent options
TAG="${TAG:-sunsingerus/clickhouse-operator:dev}"
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN:-sunsingerus}"
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
MINIKUBE="${MINIKUBE:-no}"

TAG="${TAG}" \
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
MINIKUBE="${MINIKUBE}" \
./image_build_universal.sh
28 changes: 28 additions & 0 deletions dev/image_build_universal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# Universal docker image builder

# Externally configurable build-dependent options
TAG="${TAG:-sunsingerus/clickhouse-operator:dev}"
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN:-sunsingerus}"
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
MINIKUBE="${MINIKUBE:-no}"

# Source-dependent options
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
SRC_ROOT="$(realpath ${CUR_DIR}/..)"
DOCKERFILE_DIR="${SRC_ROOT}"
DOCKERFILE="${DOCKERFILE_DIR}/Dockerfile"

# Build image with Docker
if [[ "${MINIKUBE}" == "yes" ]]; then
# We'd like to build for minikube
eval $(minikube docker-env)
fi
cat "${DOCKERFILE}" | envsubst | docker build -t "${TAG}" "${SRC_ROOT}"

# Publish image
if [[ "${DOCKERHUB_PUBLISH}" == "yes" ]]; then
docker login -u "${DOCKERHUB_LOGIN}"
docker push "${TAG}"
fi
18 changes: 12 additions & 6 deletions run_dev.sh → dev/run_dev.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/bash

# Run clickhouse-operator
# Do not forget to update version

source ./binary_build_config.sh
LOG_DIR=${CUR_DIR}/log

echo -n "Building binary, please wait..."
if ./build_binary.sh; then
if ./binary_build.sh; then
echo "successfully built clickhouse-operator. Starting"

mkdir -p log
rm -f log/clickhouse-operator.*.log.*
./clickhouse-operator \
mkdir -p ${LOG_DIR}
rm -f ${LOG_DIR}/clickhouse-operator.*.log.*
${OPERATOR_BIN} \
-alsologtostderr=true \
-log_dir=log \
-v=1
Expand All @@ -19,12 +25,12 @@ if ./build_binary.sh; then
# -stderrthreshold=FATAL Log events at or above this severity are logged to standard error as well as to files

# And clean binary after run. It'll be rebuilt next time
./clean_binary.sh
./binary_clean.sh

echo "======================"
echo "=== Logs available ==="
echo "======================"
ls log/*
ls ${LOG_DIR}/*
else
echo "unable to build clickhouse-operator"
fi
19 changes: 19 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Table of Contents
1. [architecture.md](./architecture.md) - architecture overview
1. [chi_update_add_replication.md](./chi_update_add_replication.md) - how to add replication
1. [chi_update_clickhouse_version.md](./chi_update_clickhouse_version.md) - how to update version
1. [clickhouse_config_errors_handling.md](./clickhouse_config_errors_handling.md) - how operator handles ClickHouse's config errors
1. [custom_resource_explained.md](./custom_resource_explained.md) - explain Custom Resource Definition in details
1. [grafana_setup.md](./grafana_setup.md) - how to setup Grafana
1. [introduction.md](./introduction.md) - general introduction
1. [k8s_cluster_access.md](./k8s_cluster_access.md) - how to setup cluster access
1. [operator_build_from_sources.md](./operator_build_from_sources.md) - how to build operator from sources
1. [operator_configuration.md](./operator_configuration.md) - operator configuration in details
1. [operator_installation_details.md](./operator_installation_details.md) - how to install operator in details
1. [operator_upgrade.md](./operator_upgrade.md) - how to upgrade operator to the different version
1. [prometheus_setup.md](./prometheus_setup.md) - how to setup Prometheus
1. [quick-start.md](./quick-start.md) - quick start
1. [replication_setup.md](./replication_setup.md) - how to setup replication
1. [schema_migration.md](./schema_migration.md) - how operator migrates shena during cluster resize
1. [storage.md](./storage.md) - storage explained
1. [zookeeper_setup.md](./zookeeper_setup.md) - how to setup zookeeper
36 changes: 36 additions & 0 deletions docs/clickhouse_config_errors_handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# ClickHouse Configuration Errors Handling

When operator performs rolling update and create procedures, it monitors health of the updated/created StatefulSets.
Operator polls StatefulSet status and wait for some configurable time for StatefulSet to report **Ready** status reached.
In case StatefulSet successfully reports **Ready** status, all is good and operator can move on to the next StatefulSet.
However, in case ClickHouse configuration is incorrect or due to any other reason ClickHouse is unable to start, StatefulSet would not reach **Ready** status.
In tis case, operator has to do something and decide what to do regarding the following questions:
1. What to do with current failed StatefulSet?
1. Should operator continue with rolling update?

Regarding failed StatefulSet, operator can either do nothing and leave the situation to admin to solve or can try to rollback StatefulSet to previous state.
In case of newly created StatefulSet, rollback means *to delete StatefulSet*
This behavior is configured with the following operator configuration options:
```yaml
# What to do in case created StatefulSet is not in Ready after `statefulSetUpdateTimeout` seconds
# Possible options:
# 1. abort - do nothing, just break the process and wait for admin
# 2. delete - delete newly created problematic StatefulSet
onStatefulSetCreateFailureAction: delete

# What to do in case updated StatefulSet is not in Ready after `statefulSetUpdateTimeout` seconds
# Possible options:
# 1. abort - do nothing, just break the process and wait for admin
# 2. rollback - delete Pod and rollback StatefulSet to previous Generation.
# Pod would be recreated by StatefulSet based on rollback-ed configuration
onStatefulSetUpdateFailureAction: rollback
```

Regarding should operator continue with rolling update/create in case of failed StatefulSet it met - current behavior is to abort rolling process and let admin to decide how to proceed with current situation.

# Plans and discussion
Interesting question is what to do with StatefulSets that were already successfully updated on the same run, before failed StatefulSet met.
Available options are:
1. Do nothing. In this case ClickHouse cluster may be in some inconsistent state, because some replicas may be updated and some not.
1. try to rollback the whole cluster to some **previous** state. What this **previous** state be is a matter of discussion.
Currently operator goes with 'do nothing' approach.
58 changes: 58 additions & 0 deletions docs/examples-withstand-errors/01-incorrect-image-create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "incorrect-image-create"
spec:
configuration:
clusters:
- name: adv
layout:
type: Advanced
shards:
- definitionType: Replicas
replicas:
- deployment:
podTemplate: clickhouse:19.3.5
- deployment:
podTemplate: clickhouse:19.3.100
- deployment:
podTemplate: clickhouse:19.3.7

templates:
podTemplates:
- name: clickhouse:19.3.5
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.5
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009

- name: clickhouse:19.3.7
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.7
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009

# Incorrect image
- name: clickhouse:19.3.100
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.100
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "incorrect-image-version-update"
spec:
configuration:
clusters:
- name: update
deployment:
podTemplate: clickhouse:19.1.10
layout:
type: Advanced
shards:
- definitionType: Replicas
replicas:
- port: 9000
- port: 9000
- port: 9000

templates:
podTemplates:
- name: clickhouse:19.1.10
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.1.10
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009
Loading

0 comments on commit 7934c83

Please sign in to comment.