Skip to content

Commit 6a382fe

Browse files
authored
Merge pull request #229 from Altinity/0.8.0
0.8.0
2 parents a743757 + 666e122 commit 6a382fe

File tree

92 files changed

+7767
-4918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+7767
-4918
lines changed

cmd/metrics_exporter/app/metrics_exporter.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ import (
1818
"context"
1919
"flag"
2020
"fmt"
21-
"github.com/altinity/clickhouse-operator/pkg/apis/metrics"
22-
chopconfig "github.com/altinity/clickhouse-operator/pkg/config"
23-
"github.com/altinity/clickhouse-operator/pkg/version"
24-
"github.com/golang/glog"
2521
"os"
2622
"os/signal"
2723
"syscall"
24+
25+
"github.com/golang/glog"
26+
27+
"github.com/altinity/clickhouse-operator/pkg/apis/metrics"
28+
"github.com/altinity/clickhouse-operator/pkg/chop"
29+
"github.com/altinity/clickhouse-operator/pkg/version"
2830
)
2931

3032
// Prometheus exporter defaults
@@ -77,20 +79,26 @@ func Run() {
7779
}()
7880

7981
//
80-
// Create operator config
82+
// Create operator instance
8183
//
82-
chopConfigManager := chopconfig.NewConfigManager(nil, chopConfigFile)
83-
if err := chopConfigManager.Init(); err != nil {
84-
glog.Fatalf("Unable to build config file %v\n", err)
84+
chop := chop.NewChop(version.Version, nil, chopConfigFile)
85+
if err := chop.Init(); err != nil {
86+
glog.Fatalf("Unable to init CHOP instance %v\n", err)
8587
os.Exit(1)
8688
}
8789

8890
glog.V(1).Info("Starting metrics exporter\n")
8991

9092
metrics.StartMetricsREST(
91-
chopConfigManager.Config().ChUsername, chopConfigManager.Config().ChPassword, chopConfigManager.Config().ChPort,
92-
metricsEP, metricsPath,
93-
chiListEP, chiListPath,
93+
chop.Config().ChUsername,
94+
chop.Config().ChPassword,
95+
chop.Config().ChPort,
96+
97+
metricsEP,
98+
metricsPath,
99+
100+
chiListEP,
101+
chiListPath,
94102
)
95103

96104
<-ctx.Done()

cmd/operator/app/clickhouse_operator.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import (
2626
"syscall"
2727
"time"
2828

29-
chopconfig "github.com/altinity/clickhouse-operator/pkg/config"
29+
"github.com/altinity/clickhouse-operator/pkg/chop"
30+
"github.com/altinity/clickhouse-operator/pkg/controller/chi"
3031
"github.com/altinity/clickhouse-operator/pkg/version"
3132

3233
chopclientset "github.com/altinity/clickhouse-operator/pkg/client/clientset/versioned"
3334
chopinformers "github.com/altinity/clickhouse-operator/pkg/client/informers/externalversions"
34-
"github.com/altinity/clickhouse-operator/pkg/controller/chi"
35+
3536
kubeinformers "k8s.io/client-go/informers"
3637
kube "k8s.io/client-go/kubernetes"
3738
kuberest "k8s.io/client-go/rest"
@@ -45,7 +46,7 @@ const (
4546
defaultMetricsEndpoint = ":8888"
4647
metricsPath = "/metrics"
4748
defaultInformerFactoryResyncPeriod = 60 * time.Second
48-
defaultInformerFactoryResyncDebugPeriod = 600 * time.Second
49+
defaultInformerFactoryResyncDebugPeriod = 60 * time.Second
4950
)
5051

5152
const (
@@ -167,11 +168,11 @@ func Run() {
167168
kubeClient, chopClient := createClientsets(kubeConfig)
168169

169170
//
170-
// Create operator config
171+
// Create operator instance
171172
//
172-
chopConfigManager := chopconfig.NewConfigManager(chopClient, chopConfigFile)
173-
if err := chopConfigManager.Init(); err != nil {
174-
glog.Fatalf("Unable to build config file %v\n", err)
173+
chop := chop.NewChop(version.Version, chopClient, chopConfigFile)
174+
if err := chop.Init(); err != nil {
175+
glog.Fatalf("Unable to init CHOP instance %v\n", err)
175176
os.Exit(1)
176177
}
177178

@@ -181,20 +182,19 @@ func Run() {
181182
kubeInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(
182183
kubeClient,
183184
kubeInformerFactoryResyncPeriod,
184-
kubeinformers.WithNamespace(chopConfigManager.Config().GetInformerNamespace()),
185+
kubeinformers.WithNamespace(chop.Config().GetInformerNamespace()),
185186
)
186187
chopInformerFactory := chopinformers.NewSharedInformerFactoryWithOptions(
187188
chopClient,
188189
chopInformerFactoryResyncPeriod,
189-
chopinformers.WithNamespace(chopConfigManager.Config().GetInformerNamespace()),
190+
chopinformers.WithNamespace(chop.Config().GetInformerNamespace()),
190191
)
191192

192193
//
193194
// Create Controller
194195
//
195196
chiController := chi.NewController(
196-
version.Version,
197-
chopConfigManager,
197+
chop,
198198
chopClient,
199199
kubeClient,
200200
chopInformerFactory,

config/config-dev.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# Concurrently running operators should watch on different namespaces
99
watchNamespaces:
1010
- dev
11+
- test
1112
# - info
1213
# - onemore
1314

@@ -47,13 +48,15 @@ statefulSetUpdatePollPeriod: 10
4748
# Possible options:
4849
# 1. abort - do nothing, just break the process and wait for admin
4950
# 2. delete - delete newly created problematic StatefulSet
51+
# 3. ignore - ignore error, pretend nothing happened and move on to the next StatefulSet
5052
onStatefulSetCreateFailureAction: delete
5153

5254
# What to do in case updated StatefulSet is not in Ready after `statefulSetUpdateTimeout` seconds
5355
# Possible options:
5456
# 1. abort - do nothing, just break the process and wait for admin
5557
# 2. rollback - delete Pod and rollback StatefulSet to previous Generation.
5658
# Pod would be recreated by StatefulSet based on rollback-ed configuration
59+
# 3. ignore - ignore error, pretend nothing happened and move on to the next StatefulSet
5760
onStatefulSetUpdateFailureAction: rollback
5861

5962
################################################
@@ -70,9 +73,13 @@ onStatefulSetUpdateFailureAction: rollback
7073
chConfigUserDefaultProfile: default
7174
chConfigUserDefaultQuota: default
7275
chConfigUserDefaultNetworksIP:
73-
- "::/0"
76+
- "::1"
77+
- "127.0.0.1"
7478
chConfigUserDefaultPassword: "default"
7579

80+
# Default host_regexp to limit network connectivity from outside
81+
ChConfigNetworksHostRegexpTemplate: "chi-{chi}-[^.]+\\d+-\\d+\\.{namespace}.svc.cluster.local$"
82+
7683
################################################
7784
##
7885
## Operator's access to ClickHouse instances

config/config.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ statefulSetUpdatePollPeriod: 10
4747
# Possible options:
4848
# 1. abort - do nothing, just break the process and wait for admin
4949
# 2. delete - delete newly created problematic StatefulSet
50+
# 3. ignore - ignore error, pretend nothing happened and move on to the next StatefulSet
5051
onStatefulSetCreateFailureAction: delete
5152

5253
# What to do in case updated StatefulSet is not in Ready after `statefulSetUpdateTimeout` seconds
5354
# Possible options:
5455
# 1. abort - do nothing, just break the process and wait for admin
5556
# 2. rollback - delete Pod and rollback StatefulSet to previous Generation.
5657
# Pod would be recreated by StatefulSet based on rollback-ed configuration
58+
# 3. ignore - ignore error, pretend nothing happened and move on to the next StatefulSet
5759
onStatefulSetUpdateFailureAction: rollback
5860

5961
################################################
@@ -70,9 +72,13 @@ onStatefulSetUpdateFailureAction: rollback
7072
chConfigUserDefaultProfile: default
7173
chConfigUserDefaultQuota: default
7274
chConfigUserDefaultNetworksIP:
73-
- "::/0"
75+
- "::1"
76+
- "127.0.0.1"
7477
chConfigUserDefaultPassword: "default"
7578

79+
# Default host_regexp to limit network connectivity from outside
80+
ChConfigNetworksHostRegexpTemplate: "chi-{chi}-[^.]+\\d+-\\d+\\.{namespace}.svc.cluster.local$"
81+
7682
################################################
7783
##
7884
## Operator's access to ClickHouse instances

config/users.d/01-clickhouse-user.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
<ip>0.0.0.0/0</ip>
77
<ip>::/0</ip>
88
</networks>
9-
<password>clickhouse_operator_password</password>
10-
<profile>default</profile>
9+
<password_sha256_hex>716b36073a90c6fe1d445ac1af85f4777c5b7a155cea359961826a030513e448</password_sha256_hex>
10+
<profile>clickhouse_operator</profile>
1111
<quota>default</quota>
1212
</clickhouse_operator>
1313
</users>
14+
<profiles>
15+
<clickhouse_operator>
16+
<log_queries>0</log_queries>
17+
</clickhouse_operator>
18+
</profiles>
1419
</yandex>

0 commit comments

Comments
 (0)