Skip to content

Commit

Permalink
Merge pull request #120 from Altinity/0.4.0
Browse files Browse the repository at this point in the history
Release 0.4.0
  • Loading branch information
alex-zaitsev committed Jun 18, 2019
2 parents dbd6fb9 + 30336ee commit b509fd6
Show file tree
Hide file tree
Showing 60 changed files with 2,553 additions and 955 deletions.
13 changes: 7 additions & 6 deletions dev/binary_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
source "${CUR_DIR}/binary_build_config.sh"

REPO="github.com/altinity/clickhouse-operator"
VERSION=$(cd ${SRC_ROOT}; cat release)
GIT_SHA=$(cd ${CUR_DIR}; git rev-parse --short HEAD)
VERSION=$(cd "${SRC_ROOT}"; cat release)
GIT_SHA=$(cd "${CUR_DIR}"; git rev-parse --short HEAD)

# Build clickhouse-operator install .yaml manifest
${SRC_ROOT}/manifests/operator/build-clickhouse-operator-yaml.sh
"${SRC_ROOT}/manifests/operator/build-clickhouse-operator-install-yaml.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 \
-v -a \
-ldflags "-X ${REPO}/pkg/version.Version=${VERSION} -X ${REPO}/pkg/version.GitSHA=${GIT_SHA}" \
-o ${OPERATOR_BIN} \
${SRC_ROOT}/cmd/manager/main.go
-o "${OPERATOR_BIN}" \
"${SRC_ROOT}/cmd/manager/main.go"

exit $?
4 changes: 2 additions & 2 deletions dev/binary_build_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Build configuration options

CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
SRC_ROOT=$(realpath ${CUR_DIR}/..)
SRC_ROOT="$(realpath "${CUR_DIR}/..")"

# Operator binary name can be specified externally
# Default - put 'clickhouse-operator' into cur dir
OPERATOR_BIN=${OPERATOR_BIN:-${CUR_DIR}/clickhouse-operator}
OPERATOR_BIN="${OPERATOR_BIN:-${CUR_DIR}/clickhouse-operator}"
4 changes: 2 additions & 2 deletions dev/binary_clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
source "${CUR_DIR}/binary_build_config.sh"

rm -f ${OPERATOR_BIN}
rm -f "${OPERATOR_BIN}"
6 changes: 3 additions & 3 deletions dev/find_unformatted_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ set -o pipefail

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
source "${CUR_DIR}/binary_build_config.sh"

# Prepare list of all .go files in the project, but exclude all files from /vendor/ folder
GO_FILES_LIST=$(find ${SRC_ROOT} -name \*.go -not -path "${SRC_ROOT}/vendor/*" -print)
GO_FILES_LIST=$(find "${SRC_ROOT}" -name \*.go -not -path "${SRC_ROOT}/vendor/*" -print)
# Prepare unformatted files list
UNFORMATTED_FILES_LIST=$(gofmt -l ${GO_FILES_LIST})

if [[ ${UNFORMATTED_FILES_LIST} ]]; then
for FILE in ${UNFORMATTED_FILES_LIST}; do
echo ${FILE}
echo "${FILE}"
done
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions dev/format_unformatted_sources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ set -o pipefail

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
source "${CUR_DIR}/binary_build_config.sh"

# Iterate over list of unformatted files and format each of them
${CUR_DIR}/find_unformatted_sources.sh | while read -r FILE; do
go fmt ${FILE}
"${CUR_DIR}/find_unformatted_sources.sh" | while read -r FILE; do
go fmt "${FILE}"
done
4 changes: 2 additions & 2 deletions dev/image_build_altinity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
source "${CUR_DIR}/binary_build_config.sh"

# Externally configurable build-dependent options
TAG="${TAG:-altinity/clickhouse-operator:dev}"
Expand All @@ -16,4 +16,4 @@ TAG="${TAG}" \
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
MINIKUBE="${MINIKUBE}" \
${CUR_DIR}/image_build_universal.sh
"${CUR_DIR}/image_build_universal.sh"
4 changes: 2 additions & 2 deletions dev/image_build_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
source "${CUR_DIR}/binary_build_config.sh"

# Externally configurable build-dependent options
TAG="${TAG:-sunsingerus/clickhouse-operator:dev}"
Expand All @@ -16,4 +16,4 @@ TAG="${TAG}" \
DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
MINIKUBE="${MINIKUBE}" \
${CUR_DIR}/image_build_universal.sh
"${CUR_DIR}/image_build_universal.sh"
4 changes: 2 additions & 2 deletions dev/image_build_universal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ MINIKUBE="${MINIKUBE:-no}"

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

# Build clickhouse-operator install .yaml manifest
${SRC_ROOT}/manifests/operator/build-clickhouse-operator-yaml.sh
"${SRC_ROOT}/manifests/operator/build-clickhouse-operator-install-yaml.sh"

# Build image with Docker
if [[ "${MINIKUBE}" == "yes" ]]; then
Expand Down
16 changes: 8 additions & 8 deletions dev/run_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

# Source configuration
CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source ${CUR_DIR}/binary_build_config.sh
LOG_DIR=${CUR_DIR}/log
source "${CUR_DIR}/binary_build_config.sh"
LOG_DIR="${CUR_DIR}/log"

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

mkdir -p ${LOG_DIR}
rm -f ${LOG_DIR}/clickhouse-operator.*.log.*
${OPERATOR_BIN} \
mkdir -p "${LOG_DIR}"
rm -f "${LOG_DIR}"/clickhouse-operator.*.log.*
"${OPERATOR_BIN}" \
-alsologtostderr=true \
-log_dir=log \
-v=1
Expand All @@ -27,12 +27,12 @@ if ${CUR_DIR}/binary_build.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
${CUR_DIR}/binary_clean.sh
"${CUR_DIR}/binary_clean.sh"

echo "======================"
echo "=== Logs available ==="
echo "======================"
ls ${LOG_DIR}/*
ls "${LOG_DIR}"/*
else
echo "unable to build clickhouse-operator"
fi
6 changes: 3 additions & 3 deletions dev/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ set -o nounset
# Only exit with zero if all commands of the pipeline exit successfully
set -o pipefail

PROJECT_ROOT=$(dirname ${BASH_SOURCE})/..
CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${PROJECT_ROOT}; ls -d -1 ${PROJECT_ROOT}/vendor/k8s.io/code-generator 2>/dev/null || echo ${GOPATH}/src/k8s.io/code-generator)}
PROJECT_ROOT="$(dirname "${BASH_SOURCE}")/.."
CODEGEN_PKG="${CODEGEN_PKG:-$(cd "${PROJECT_ROOT}"; ls -d -1 "${PROJECT_ROOT}/vendor/k8s.io/code-generator" 2>/dev/null || echo "${GOPATH}/src/k8s.io/code-generator")}"

${PROJECT_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh all \
"${PROJECT_ROOT}/vendor/k8s.io/code-generator/generate-groups.sh" all \
github.com/altinity/clickhouse-operator/pkg/client \
github.com/altinity/clickhouse-operator/pkg/apis \
"clickhouse.altinity.com:v1"
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
templates:
volumeClaimTemplates:
- name: volumeclaim-template
# reclaimPolicy: Retain
spec:
accessModes:
- ReadWriteOnce
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#
# AWS-specific labels, applicable in 'nodeAffinity' statements
#
# beta.kubernetes.io/arch=amd64
# beta.kubernetes.io/instance-type=t2.medium
# beta.kubernetes.io/os=linux
#
# failure-domain.beta.kubernetes.io/region=us-east-1
# failure-domain.beta.kubernetes.io/zone=us-east-1a
#
# kubernetes.io/hostname=ip-172-20-37-97.ec2.internal
# kubernetes.io/role=node
# node-role.kubernetes.io/node=
#
# kops.k8s.io/instancegroup=nodes2
#
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "aws-zones"
spec:
configuration:
clusters:
- name: zoned-cluster
layout:
shards:
- replicas:
- templates:
podTemplate: clickhouse-in-zone-us-east-1a
- templates:
podTemplate: clickhouse-in-zone-us-east-1a
- templates:
podTemplate: clickhouse-in-zone-us-east-1a
- templates:
podTemplate: clickhouse-in-zone-us-east-1b
- templates:
podTemplate: clickhouse-in-zone-us-east-1b
- templates:
podTemplate: clickhouse-in-zone-us-east-1b

templates:
podTemplates:
# Specify Pod Templates with affinity

- name: clickhouse-in-zone-us-east-1a
zone:
values:
- "us-east-1a"
spec:
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.7
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009

- name: clickhouse-in-zone-us-east-1b
zone:
values:
- "us-east-1b"
spec:
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.7
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009
49 changes: 49 additions & 0 deletions docs/examples/10-zones-01-simple-02-aws-pod-per-host.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# AWS-specific labels, applicable in 'nodeAffinity' statements
#
# beta.kubernetes.io/arch=amd64
# beta.kubernetes.io/instance-type=t2.medium
# beta.kubernetes.io/os=linux
#
# failure-domain.beta.kubernetes.io/region=us-east-1
# failure-domain.beta.kubernetes.io/zone=us-east-1a
#
# kubernetes.io/hostname=ip-172-20-37-97.ec2.internal
# kubernetes.io/role=node
# node-role.kubernetes.io/node=
#
# kops.k8s.io/instancegroup=nodes2
#
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "zones-pod-host"
spec:
defaults:
templates:
podTemplate: clickhouse-per-host-in-zone-us-east-1a
configuration:
clusters:
- name: zoned-cluster
layout:
shardsCount: 3

templates:
podTemplates:
# Specify Pod Templates with affinity
- name: clickhouse-per-host-in-zone-us-east-1a
zone:
values:
- "us-east-1a"
distribution: "OnePerHost"
spec:
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.7
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ spec:
templates:
podTemplates:
# Specify Pod Templates with affinity

- name: clickhouse-per-host-in-zone-us-east-1a
spec:
affinity:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#
# AWS-specific labels, applicable in 'nodeAffinity' statements
#
# beta.kubernetes.io/arch=amd64
# beta.kubernetes.io/instance-type=t2.medium
# beta.kubernetes.io/os=linux
#
# failure-domain.beta.kubernetes.io/region=us-east-1
# failure-domain.beta.kubernetes.io/zone=us-east-1a
#
# kubernetes.io/hostname=ip-172-20-37-97.ec2.internal
# kubernetes.io/role=node
# node-role.kubernetes.io/node=
#
# kops.k8s.io/instancegroup=nodes2
#
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "ch-per-host-pvc"
spec:
defaults:
templates:
podTemplate: clickhouse-per-host
volumeClaimTemplate: storage-vc-template
configuration:
templates:
serviceTemplate: ch-service
clusters:
- name: zoned
layout:
shardsCount: 2
templates:
serviceTemplates:
- name: ch-service
generateName: chendpoint
spec:
ports:
- name: http
port: 8123
- name: client
port: 9000
type: LoadBalancer
podTemplates:
# Specify Pod Templates with affinity
- name: clickhouse-per-host
zone:
key: "clickhouse"
values:
- "allow"
distribution: "OnePerHost"
spec:
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.3.7
ports:
- name: http
containerPort: 8123
- name: client
containerPort: 9000
- name: interserver
containerPort: 9009
volumeMounts:
- name: storage-vc-template
mountPath: /var/lib/clickhouse
volumeClaimTemplates:
- name: storage-vc-template
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
Loading

0 comments on commit b509fd6

Please sign in to comment.