├── .circleci
└── config.yml
├── .dockerignore
├── .gitignore
├── .gitsecret
├── keys
│ ├── pubring.kbx
│ ├── pubring.kbx~
│ └── trustdb.gpg
└── paths
│ └── mapping.cfg
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── Vagrantfile
├── cmd
├── metrics_exporter
│ ├── app
│ │ └── metrics_exporter.go
│ └── main.go
└── operator
│ ├── app
│ └── clickhouse_operator.go
│ └── main.go
├── config
├── conf.d
│ └── .gitkeep.xml
├── config-dev.yaml
├── config.d
│ ├── .gitkeep.xml
│ ├── 01-clickhouse-01-listen.xml
│ ├── 01-clickhouse-02-logger.xml
│ ├── 01-clickhouse-03-query_log.xml
│ └── 01-clickhouse-04-part_log.xml
├── config.yaml
├── secret.yaml
├── templates.d
│ ├── .001-gitkeep.yaml
│ ├── .002-gitkeep.yaml
│ ├── 001-templates.json.example
│ ├── default-pod-template.yaml.example
│ ├── default-storage-template.yaml.example
│ └── readme
└── users.d
│ ├── .gitkeep.xml
│ ├── 01-clickhouse-user.xml
│ ├── 02-clickhouse-default-profile.xml
│ └── 03-database-ordinary.xml
├── deploy
├── dev
│ ├── PersistentVolumeClaim
│ │ ├── nginx_pod.yaml
│ │ └── nginx_statefulset.yaml
│ ├── cat-clickhouse-operator-install-yaml.sh
│ ├── clickhouse-operator-install-dev.yaml
│ ├── clickhouse-operator-install-yaml-template-01-section-crd-01-chi.yaml
│ ├── clickhouse-operator-install-yaml-template-01-section-crd-02-chit.yaml
│ ├── clickhouse-operator-install-yaml-template-01-section-crd-03-chopconf.yaml
│ ├── clickhouse-operator-install-yaml-template-02-section-rbac.yaml
│ ├── clickhouse-operator-install-yaml-template-03-section-configmap-header.yaml
│ ├── clickhouse-operator-install-yaml-template-04-section-deployment-with-configmap.yaml
│ ├── clickhouse-operator-install-yaml-template-04-section-deployment.yaml
│ ├── clickhouse-operator-install-yaml-template-05-section-service.yaml
│ ├── clickhouse
│ │ ├── 01-service-client.yaml
│ │ ├── 02-headless-service.yaml
│ │ ├── 03-config.d-configmap.yaml
│ │ ├── 04-storageclass-clickhouse.yaml
│ │ ├── ch-statefulset-1.yaml
│ │ ├── chpod1.yaml
│ │ ├── chpod2.yaml
│ │ ├── chpod3.yaml
│ │ └── chpod4.yaml
│ ├── dev-config.sh
│ ├── dev-delete.sh
│ ├── dev-install.sh
│ ├── dev-reset.sh
│ ├── dev-show.sh
│ └── dev-watch.sh
├── grafana
│ ├── grafana-manually
│ │ ├── create-grafana.sh
│ │ ├── delete-grafana.sh
│ │ └── grafana.yaml
│ └── grafana-with-grafana-operator
│ │ ├── .gitignore
│ │ ├── grafana-cr-template.yaml
│ │ ├── grafana-dashboard-operator-cr-template.yaml
│ │ ├── grafana-dashboard-queries-cr-template.yaml
│ │ ├── grafana-dashboard-zookeeper-cr-template.yaml
│ │ ├── grafana-data-source-clickhouse-cr-template.yaml
│ │ ├── grafana-data-source-prometheus-cr-template.yaml
│ │ ├── install-grafana-operator.sh
│ │ ├── install-grafana-with-operator.sh
│ │ ├── open-grafana.sh
│ │ ├── proxy-grafana.sh
│ │ └── sensitive-data.sh.example
├── minio
│ ├── delete-minio.sh
│ ├── install-minio-operator.sh
│ ├── install-minio-tenant.sh
│ ├── minio-tenant-create-bucket-template.yaml
│ └── minio-tenant-template.yaml
├── operator-web-installer
│ ├── clickhouse-operator-delete.sh
│ └── clickhouse-operator-install.sh
├── operator
│ ├── build-clickhouse-operator-install-v1beta1-yaml.sh
│ ├── build-clickhouse-operator-install-yaml.sh
│ ├── clickhouse-operator-delete.sh
│ ├── clickhouse-operator-install-bundle-v1beta1.yaml
│ ├── clickhouse-operator-install-bundle.yaml
│ ├── clickhouse-operator-install-crd.yaml
│ ├── clickhouse-operator-install-deployment.yaml
│ ├── clickhouse-operator-install-service.yaml
│ ├── clickhouse-operator-install-template-crd.yaml
│ ├── clickhouse-operator-install-template-deployment.yaml
│ ├── clickhouse-operator-install-template-rbac.yaml
│ ├── clickhouse-operator-install-template-service.yaml
│ ├── clickhouse-operator-install-template-v1beta1.yaml
│ ├── clickhouse-operator-install-template.yaml
│ └── clickhouse-operator-install.sh
├── prometheus
│ ├── .gitignore
│ ├── create-prometheus.sh
│ ├── delete-prometheus.sh
│ ├── prometheus-alert-rules-backup.yaml
│ ├── prometheus-alert-rules-clickhouse.yaml
│ ├── prometheus-alert-rules-zookeeper.yaml
│ ├── prometheus-alertmanager-template.yaml
│ ├── prometheus-sensitive-data.example.sh
│ └── prometheus-template.yaml
└── zookeeper
│ ├── advanced
│ ├── 01-service-client-access.yaml
│ ├── 02-headless-service.yaml
│ ├── 03-pod-disruption-budget.yaml
│ ├── 04-storageclass-zookeeper.yaml
│ ├── 05-stateful-set-persistent-volume.yaml
│ ├── 05-stateful-set-volume-emptyDir.yaml
│ ├── zookeeper-create-universal.sh
│ ├── zookeeper-persistent-volume-create.sh
│ ├── zookeeper-persistent-volume-delete.sh
│ ├── zookeeper-volume-emptyDir-create.sh
│ ├── zookeeper-volume-emptyDir-delete.sh
│ └── zookeeper-watch.sh
│ ├── quick-start-persistent-volume
│ ├── README.md
│ ├── zookeeper-1-node-1GB-for-tests-only.yaml
│ ├── zookeeper-1-node-create.sh
│ ├── zookeeper-1-node-delete.sh
│ ├── zookeeper-1-node.yaml
│ ├── zookeeper-3-nodes-1GB-for-tests-only.yaml
│ ├── zookeeper-3-nodes-create.sh
│ ├── zookeeper-3-nodes-delete.sh
│ └── zookeeper-3-nodes.yaml
│ └── quick-start-volume-emptyDir
│ ├── zookeeper-1-node-create.sh
│ ├── zookeeper-1-node-delete.sh
│ ├── zookeeper-1-node.yaml
│ ├── zookeeper-3-nodes-create.sh
│ ├── zookeeper-3-nodes-delete.sh
│ └── zookeeper-3-nodes.yaml
├── dev
├── RnD
│ ├── StatefulSet
│ │ └── sts.yaml
│ ├── chopsim
│ │ ├── main.go
│ │ └── parser
│ │ │ └── parser.go
│ ├── diff
│ │ └── main.go
│ ├── glog
│ │ └── test.go
│ ├── map
│ │ └── test.go
│ └── messagediff
│ │ └── simple.go
├── community-operators-crd-diff.sh
├── find_unformatted_sources.sh
├── format_unformatted_sources.sh
├── go_build_all.sh
├── go_build_config.sh
├── go_build_metrics_exporter.sh
├── go_build_metrics_exporter_clean.sh
├── go_build_operator.sh
├── go_build_operator_clean.sh
├── image_build_all_dev.sh
├── image_build_all_radondb.sh
├── image_build_metrics_exporter_dev.sh
├── image_build_metrics_exporter_radondb.sh
├── image_build_metrics_exporter_universal.sh
├── image_build_operator_dev.sh
├── image_build_operator_radondb.sh
├── image_build_operator_universal.sh
├── run_code_generator.sh
├── run_gocard.sh
├── run_gosec.sh
├── run_metrics_exporter.sh
├── run_operator.sh
└── run_vet.sh
├── dockerfile
├── actions.secret
├── build-docker-files.sh
├── metrics-exporter
│ ├── Dockerfile
│ └── template
│ │ └── Dockerfile
└── operator
│ ├── Dockerfile
│ └── template
│ └── Dockerfile
├── docs
├── README.md
├── architecture.md
├── chi-examples-withstand-errors
│ ├── 01-incorrect-image-create.yaml
│ ├── 02-incorrect-image-update-01-initial-position.yaml
│ ├── 02-incorrect-image-update-02-apply-incorrect-update.yaml
│ ├── 02-incorrect-image-update-03-revert-and-apply.yaml
│ ├── 03-incorrect-settings-create.yaml
│ ├── 04-incorrect-settings-update-01-initial-position.yaml
│ ├── 04-incorrect-settings-update-02-apply-incorrect-update.yaml
│ ├── 04-incorrect-settings-update-03-revert-and-apply.yaml
│ └── 05-incorrect-pod-template.yaml
├── chi-examples
│ ├── 01-simple-layout-01-1shard-1repl.yaml
│ ├── 01-simple-layout-02-1shard-2repl.yaml
│ ├── 01-simple-layout-03-multiple-clusters.yaml
│ ├── 01-simple-layout-04-shards-and-replicas-customization.yaml
│ ├── 02-templates-01-pod-template.yaml
│ ├── 02-templates-02-volume-claim-template-assume-default.yaml
│ ├── 02-templates-03-service-template.yaml
│ ├── 02-templates-04-host-template-volume-claim-and-pod-resources-limit.yaml
│ ├── 02-templates-05-useTemplates-multiple.yaml
│ ├── 02-templates-06-sidecar.yaml
│ ├── 02-templates-07-bootstrap-schema.yaml
│ ├── 03-persistent-volume-01-default-volume.yaml
│ ├── 03-persistent-volume-02-pod-template.yaml
│ ├── 03-persistent-volume-03-custom-labels-and-annotations.yaml
│ ├── 03-persistent-volume-04-encrypted-volume.yaml
│ ├── 03-persistent-volume-05-resizeable-volume-1.yaml
│ ├── 03-persistent-volume-05-resizeable-volume-2.yaml
│ ├── 03-persistent-volume-06-add-log-volume-1.yaml
│ ├── 03-persistent-volume-06-add-log-volume-2.yaml
│ ├── 03-persistent-volume-07-multiple-resizable-volumes-1.yaml
│ ├── 03-persistent-volume-07-multiple-resizable-volumes-2.yaml
│ ├── 03-persistent-volume-07-multiple-resizable-volumes-3.yaml
│ ├── 03-persistent-volume-07-security-context.yaml
│ ├── 04-replication-zookeeper-01-minimal.yaml
│ ├── 04-replication-zookeeper-02-detailed.yaml
│ ├── 04-replication-zookeeper-03-minimal-AWS-persistent-volume.yaml
│ ├── 04-replication-zookeeper-04-medium-AWS-persistent-volume.yaml
│ ├── 04-replication-zookeeper-05-simple-PV.yaml
│ ├── 04-replication-zookeeper-06-on-cluster.yaml
│ ├── 05-settings-01-overview.yaml
│ ├── 05-settings-02-dictionary.yaml
│ ├── 05-settings-03-1-initial-position.yaml
│ ├── 05-settings-03-2-user2.yaml
│ ├── 05-settings-04-nested.yaml
│ ├── 05-settings-05-files-nested.yaml
│ ├── 05-settings-06-tilde.yaml
│ ├── 06-advanced-layout-01-shards.yaml
│ ├── 06-advanced-layout-02-replicas.yaml
│ ├── 06-advanced-layout-03-multiple-clusters.yaml
│ ├── 07-rolling-update-stateless-01-initial-position.yaml
│ ├── 07-rolling-update-stateless-02-apply-update.yaml
│ ├── 08-clickhouse-version-update-01-initial-position.yaml
│ ├── 08-clickhouse-version-update-02-apply-update-one.yaml
│ ├── 08-clickhouse-version-update-03-apply-update-all.yaml
│ ├── 09-rolling-update-emptydir-01-initial-position.yaml
│ ├── 09-rolling-update-emptydir-02-apply-update.yaml
│ ├── 10-zones-01-simple-01-aws-pods-in-availability-zones.yaml
│ ├── 10-zones-01-simple-02-aws-pod-per-host.yaml
│ ├── 10-zones-02-advanced-01-aws-pods-in-availability-zones.yaml
│ ├── 10-zones-02-advanced-02-aws-pod-per-host.yaml
│ ├── 10-zones-03-advanced-03-pod-per-host-default-storage-class.yaml
│ ├── 10-zones-04-advanced-04-pod-per-host-local-storage.yaml
│ ├── 11-local-storage-01-simple-host-path.yaml
│ ├── 11-local-storage-02-advanced-host-path.yaml
│ ├── 12-troubleshooting-01.yaml
│ ├── 13-distribution-01-distribution-scope.yaml
│ ├── 13-distribution-02-3x3-circular-replication.yaml
│ ├── 13-distribution-03-3x3-distribution-detailed.yaml
│ ├── 14-zones-distribution-01.yaml
│ ├── 15-hostNetwork-01-simple.yaml
│ ├── 15-hostNetwork-02-simple-port-distribution.yaml
│ ├── 15-hostNetwork-03-expanded-port-distribution.yaml
│ ├── 15-hostNetwork-04-simple-fixed-replicas.yaml
│ ├── 15-hostNetwork-05-expanded-fixed-replicas.yaml
│ ├── 16-custom-labels-and-annotations-01.yaml
│ ├── 17-monitoring-cluster-01.yaml
│ ├── 18-namespace-domain-pattern.yaml
│ ├── 19-pod-generate-name.yaml
│ ├── 20-protobuf-schema-example.yaml
│ ├── 50-chi-template-01.yaml
│ ├── 70-chop-config.yaml
│ ├── 98-quota-01.yaml
│ ├── 99-clickhouseinstallation-max.yaml
│ ├── 99-clickhouseupgrade-draft.yaml
│ ├── evolution
│ │ ├── 01-persistent-volume.yaml
│ │ ├── 02-introduce-replication.yaml
│ │ ├── 03-introduce-more-shards-and-zones.yaml
│ │ ├── 04-update-introduce-canary.yaml
│ │ └── 05-update-propagate-update.yaml
│ └── label_nodes.sh
├── chi_update_add_replication.md
├── chi_update_clickhouse_version.md
├── clickhouse_config_errors_handling.md
├── config-examples
│ └── templates
│ │ ├── .gitkeep
│ │ ├── 101-templates.yaml
│ │ ├── 102-templates.yaml
│ │ ├── 103-templates.yaml
│ │ ├── 104-templates.yaml
│ │ └── 105-templates.yaml
├── custom_resource_explained.md
├── fsm.xmi
├── grafana_setup.md
├── introduction.md
├── k8s_cluster_access.md
├── monitoring_setup.md
├── operator_build_from_sources.md
├── operator_configuration.md
├── operator_installation_details.md
├── operator_upgrade.md
├── prometheus_setup.md
├── pull_request_template.md
├── quick_start.md
├── reconciler.png
├── replication_setup.md
├── schema_migration.md
├── storage.md
└── zookeeper_setup.md
├── go.mod
├── go.sum
├── grafana-dashboard
├── ClickHouse_Queries_dashboard.json
├── RadonDB_ClickHouse_Operator_dashboard.json
└── Zookeeper_dashboard.json
├── hack
└── tools.go
├── pkg
├── announcer
│ └── announcer.go
├── apis
│ ├── clickhouse.radondb.com
│ │ ├── register.go
│ │ └── v1
│ │ │ ├── const.go
│ │ │ ├── doc.go
│ │ │ ├── env_vars.go
│ │ │ ├── register.go
│ │ │ ├── type_chi.go
│ │ │ ├── type_chi_host_address.go
│ │ │ ├── type_cluster.go
│ │ │ ├── type_config_chi.go
│ │ │ ├── type_config_chop.go
│ │ │ ├── type_defaults.go
│ │ │ ├── type_distributed_ddl.go
│ │ │ ├── type_host.go
│ │ │ ├── type_hosts_field.go
│ │ │ ├── type_replica.go
│ │ │ ├── type_settings.go
│ │ │ ├── type_shard.go
│ │ │ ├── type_status.go
│ │ │ ├── type_template_names.go
│ │ │ ├── type_templates.go
│ │ │ ├── type_zookeeper.go
│ │ │ ├── type_zookeeper_node.go
│ │ │ ├── types.go
│ │ │ └── zz_generated.deepcopy.go
│ └── metrics
│ │ ├── clickhouse_fetcher.go
│ │ ├── exporter.go
│ │ ├── prometheus_writer.go
│ │ ├── rest_client.go
│ │ ├── rest_machinery.go
│ │ ├── rest_server.go
│ │ ├── type_ch_access_info.go
│ │ └── type_watched_chi.go
├── chop
│ ├── chop.go
│ ├── config_manager.go
│ └── kube_machinery.go
├── client
│ ├── clientset
│ │ └── versioned
│ │ │ ├── clientset.go
│ │ │ ├── doc.go
│ │ │ ├── fake
│ │ │ ├── clientset_generated.go
│ │ │ ├── doc.go
│ │ │ └── register.go
│ │ │ ├── scheme
│ │ │ ├── doc.go
│ │ │ └── register.go
│ │ │ └── typed
│ │ │ └── clickhouse.radondb.com
│ │ │ └── v1
│ │ │ ├── clickhouse.radondb.com_client.go
│ │ │ ├── clickhouseinstallation.go
│ │ │ ├── clickhouseinstallationtemplate.go
│ │ │ ├── clickhouseoperatorconfiguration.go
│ │ │ ├── doc.go
│ │ │ ├── fake
│ │ │ ├── doc.go
│ │ │ ├── fake_clickhouse.radondb.com_client.go
│ │ │ ├── fake_clickhouseinstallation.go
│ │ │ ├── fake_clickhouseinstallationtemplate.go
│ │ │ └── fake_clickhouseoperatorconfiguration.go
│ │ │ └── generated_expansion.go
│ ├── informers
│ │ └── externalversions
│ │ │ ├── clickhouse.radondb.com
│ │ │ ├── interface.go
│ │ │ └── v1
│ │ │ │ ├── clickhouseinstallation.go
│ │ │ │ ├── clickhouseinstallationtemplate.go
│ │ │ │ ├── clickhouseoperatorconfiguration.go
│ │ │ │ └── interface.go
│ │ │ ├── factory.go
│ │ │ ├── generic.go
│ │ │ └── internalinterfaces
│ │ │ └── factory_interfaces.go
│ └── listers
│ │ └── clickhouse.radondb.com
│ │ └── v1
│ │ ├── clickhouseinstallation.go
│ │ ├── clickhouseinstallationtemplate.go
│ │ ├── clickhouseoperatorconfiguration.go
│ │ └── expansion_generated.go
├── controller
│ └── chi
│ │ ├── announcer.go
│ │ ├── context.go
│ │ ├── controller.go
│ │ ├── creator.go
│ │ ├── deleter.go
│ │ ├── discoverer.go
│ │ ├── event.go
│ │ ├── getter.go
│ │ ├── labeler.go
│ │ ├── options.go
│ │ ├── pods.go
│ │ ├── poller.go
│ │ ├── type_cmd_queue.go
│ │ ├── type_controller.go
│ │ ├── volumes.go
│ │ └── worker.go
├── model
│ ├── action_plan.go
│ ├── affinity.go
│ ├── builder
│ │ └── xml
│ │ │ └── xml.go
│ ├── ch_config_const.go
│ ├── ch_config_files_generator.go
│ ├── ch_config_generator.go
│ ├── clickhouse
│ │ ├── cluster.go
│ │ ├── connection.go
│ │ ├── connection_params.go
│ │ ├── endpoint_credentials.go
│ │ ├── endpoint_credentials_cluster.go
│ │ ├── pool.go
│ │ ├── query_options.go
│ │ ├── query_result.go
│ │ └── timeouts.go
│ ├── cluster.go
│ ├── const.go
│ ├── creator.go
│ ├── deleter.go
│ ├── labeler.go
│ ├── namer.go
│ ├── normalizer.go
│ ├── registry.go
│ └── schemer.go
├── util
│ ├── array.go
│ ├── context.go
│ ├── dir.go
│ ├── dump.go
│ ├── duration.go
│ ├── fingerprint.go
│ ├── fs.go
│ ├── hash.go
│ ├── k8s.go
│ ├── map.go
│ ├── messagediff.go
│ ├── print.go
│ ├── retry
│ │ └── retry.go
│ ├── runtime
│ │ └── runtime.go
│ └── string.go
└── version
│ └── version.go
├── release
├── release_notes.md
└── tests
├── alerts.py
├── clickhouse.py
├── configs
├── test-001.yaml
├── test-002-tpl.yaml
├── test-003-complex-layout.yaml
├── test-004-tpl.yaml
├── test-005-acm.yaml
├── test-006-ch-upgrade-1.yaml
├── test-006-ch-upgrade-2.yaml
├── test-006-ch-upgrade-3.yaml
├── test-007-custom-ports.yaml
├── test-008-operator-restart-1.yaml
├── test-008-operator-restart-2.yaml
├── test-009-operator-upgrade-1.yaml
├── test-009-operator-upgrade-2.yaml
├── test-010-zkroot.yaml
├── test-011-insecured-cluster.yaml
├── test-011-secured-cluster.yaml
├── test-011-secured-default-2.yaml
├── test-011-secured-default-3.yaml
├── test-011-secured-default.yaml
├── test-012-service-template-2.yaml
├── test-012-service-template.yaml
├── test-013-add-shards-1.yaml
├── test-013-add-shards-2.yaml
├── test-014-replication-1.yaml
├── test-014-replication-2.yaml
├── test-015-host-network.yaml
├── test-016-settings-01.yaml
├── test-016-settings-02.yaml
├── test-016-settings-03.yaml
├── test-016-settings-04.yaml
├── test-017-multi-version.yaml
├── test-018-configmap-1.yaml
├── test-018-configmap-2.yaml
├── test-019-retain-volume-1.yaml
├── test-019-retain-volume-2.yaml
├── test-019-retain-volume-3.yaml
├── test-019-retain-volume-4.yaml
├── test-020-multi-volume.yaml
├── test-021-rescale-volume-01.yaml
├── test-021-rescale-volume-02-enlarge-disk.yaml
├── test-021-rescale-volume-03-add-disk.yaml
├── test-021-rescale-volume-04-decrease-disk.yaml
├── test-022-broken-image.yaml
├── test-024-template-annotations.yaml
├── test-025-rescaling-2.yaml
├── test-025-rescaling.yaml
├── test-026-mixed-replicas.yaml
├── test-027-troubleshooting-1-bad-config.yaml
├── test-027-troubleshooting-2-troubleshoot.yaml
├── test-027-troubleshooting-3-fixed-config.yaml
├── test-029-distribution.yaml
├── test-ch-001-insert-quorum.yaml
├── test-ch-002-row-level.yaml
├── test-cluster-for-alerts-changed-settings.yaml
├── test-cluster-for-alerts.yaml
├── test-cluster-for-backups-fake.yaml
├── test-cluster-for-backups.yaml
└── test-cluster-for-zookeeper.yaml
├── kubectl.py
├── manifest.py
├── requirements.txt
├── run_tests.sh
├── run_tests_cycle.sh
├── settings.py
├── templates
├── tpl-clickhouse-19.11.yaml
├── tpl-clickhouse-20.1.yaml
├── tpl-clickhouse-20.3.yaml
├── tpl-clickhouse-20.4.yaml
├── tpl-clickhouse-20.5.yaml
├── tpl-clickhouse-20.6.yaml
├── tpl-clickhouse-20.7.yaml
├── tpl-clickhouse-20.8.yaml
├── tpl-clickhouse-21.3.yaml
├── tpl-clickhouse-21.8.yaml
├── tpl-clickhouse-alerts.yaml
├── tpl-clickhouse-auto.yaml
├── tpl-clickhouse-backups-fake.yaml
├── tpl-clickhouse-backups.yaml
├── tpl-clickhouse-latest.yaml
├── tpl-clickhouse-stable.yaml
├── tpl-log-volume.yaml
├── tpl-one-per-host.yaml
├── tpl-persistent-volume-100Mi.yaml
└── tpl-text-log.yaml
├── test.py
├── test_backup_alerts.py
├── test_clickhouse.py
├── test_examples.py
├── test_metrics_alerts.py
├── test_metrics_exporter.py
├── test_operator.py
├── test_zookeeper.py
└── util.py
/.dockerignore:
--------------------------------------------------------------------------------
1 | vendor/
2 | docs/
3 | .vagrant/
4 | *.log
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.exe~
4 | *.dll
5 | *.so
6 | *.dylib
7 |
8 | # Test binary, build with `go test -c`
9 | *.test
10 |
11 | # Output of the go coverage tool, specifically when used with LiteIDE
12 | *.out
13 |
14 | # IDE folders
15 | .idea
16 | /.project
17 | /.pydevproject
18 |
19 | # Skip log folder
20 | log
21 | *.log
22 | __pycache__
23 |
24 | # Skip dev runtime-produced
25 | dev/bin
26 | dev/log
27 |
28 | .vagrant
29 | /.DS_Store
30 |
31 | # Skip vendor
32 | vendor
33 |
34 | operator_output
35 | .gitsecret/keys/random_seed
36 | !*.secret
37 | dockerfile/actions
38 |
39 | # python virtualenv
40 | venv
41 |
--------------------------------------------------------------------------------
/.gitsecret/keys/pubring.kbx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/.gitsecret/keys/pubring.kbx
--------------------------------------------------------------------------------
/.gitsecret/keys/pubring.kbx~:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/.gitsecret/keys/pubring.kbx~
--------------------------------------------------------------------------------
/.gitsecret/keys/trustdb.gpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/.gitsecret/keys/trustdb.gpg
--------------------------------------------------------------------------------
/.gitsecret/paths/mapping.cfg:
--------------------------------------------------------------------------------
1 | dockerfile/actions:1af73143ca360a88cb062455755370b8f6cad99d5c517963baae0866cef064d7
2 |
--------------------------------------------------------------------------------
/cmd/metrics_exporter/main.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "github.com/radondb/clickhouse-operator/cmd/metrics_exporter/app"
19 | )
20 |
21 | func main() {
22 | // Application entry point
23 | app.Run()
24 | }
25 |
--------------------------------------------------------------------------------
/cmd/operator/main.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "github.com/radondb/clickhouse-operator/cmd/operator/app"
19 | )
20 |
21 | func main() {
22 | // Application entry point
23 | app.Run()
24 | }
25 |
--------------------------------------------------------------------------------
/config/conf.d/.gitkeep.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/config/conf.d/.gitkeep.xml
--------------------------------------------------------------------------------
/config/config.d/.gitkeep.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/config/config.d/.gitkeep.xml
--------------------------------------------------------------------------------
/config/config.d/01-clickhouse-01-listen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | ::
4 | 0.0.0.0
5 | 1
6 |
7 |
--------------------------------------------------------------------------------
/config/config.d/01-clickhouse-02-logger.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | information
5 | /var/log/clickhouse-server/clickhouse-server.log
6 | /var/log/clickhouse-server/clickhouse-server.err.log
7 | 1000M
8 | 10
9 |
10 | 1
11 |
12 |
13 |
--------------------------------------------------------------------------------
/config/config.d/01-clickhouse-03-query_log.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | system
4 |
5 | Engine = MergeTree PARTITION BY event_date ORDER BY event_time TTL event_date + interval 30 day
6 | 7500
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/config/config.d/01-clickhouse-04-part_log.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | system
4 |
5 | Engine = MergeTree PARTITION BY event_date ORDER BY event_time TTL event_date + interval 30 day
6 | 7500
7 |
8 |
9 |
--------------------------------------------------------------------------------
/config/secret.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Secret
3 | metadata:
4 | namespace: dev
5 | name: chop-clickhouse-credentials
6 | type: Opaque
7 | stringData:
8 | username: chuser
9 | password: chpassword
10 |
--------------------------------------------------------------------------------
/config/templates.d/.001-gitkeep.yaml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/config/templates.d/.001-gitkeep.yaml
--------------------------------------------------------------------------------
/config/templates.d/.002-gitkeep.yaml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/config/templates.d/.002-gitkeep.yaml
--------------------------------------------------------------------------------
/config/templates.d/001-templates.json.example:
--------------------------------------------------------------------------------
1 | {
2 | "apiVersion": "clickhouse.radondb.com/v1",
3 | "kind": "ClickHouseInstallationTemplate",
4 | "metadata": {
5 | "name": "01-default-volumeclaimtemplate"
6 | },
7 | "spec": {
8 | "templates": {
9 | "volumeClaimTemplates": [
10 | {
11 | "name": "chi-default-volume-claim-template",
12 | "spec": {
13 | "accessModes": [
14 | "ReadWriteOnce"
15 | ],
16 | "resources": {
17 | "requests": {
18 | "storage": "2Gi"
19 | }
20 | }
21 | }
22 | }
23 | ],
24 | "podTemplates": [
25 | {
26 | "name": "chi-default-oneperhost-pod-template",
27 | "distribution": "OnePerHost",
28 | "spec": {
29 | "containers" : [
30 | {
31 | "name": "clickhouse",
32 | "image": "radondb/clickhouse-server:21.1.3.32",
33 | "ports": [
34 | {
35 | "name": "http",
36 | "containerPort": 8123
37 | },
38 | {
39 | "name": "client",
40 | "containerPort": 9000
41 | },
42 | {
43 | "name": "interserver",
44 | "containerPort": 9009
45 | }
46 | ]
47 | }
48 | ]
49 | }
50 | }
51 | ]
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/config/templates.d/default-pod-template.yaml.example:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "default-oneperhost-pod-template"
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: default-oneperhost-pod-template
9 | distribution: "OnePerHost"
--------------------------------------------------------------------------------
/config/templates.d/default-storage-template.yaml.example:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "default-storage-template-2Gi"
5 | spec:
6 | templates:
7 | volumeClaimTemplates:
8 | - name: default-storage-template-2Gi
9 | spec:
10 | accessModes:
11 | - ReadWriteOnce
12 | resources:
13 | requests:
14 | storage: 2Gi
15 |
--------------------------------------------------------------------------------
/config/templates.d/readme:
--------------------------------------------------------------------------------
1 | Templates in this folder are packaged with an operator and available via 'useTemplate'
--------------------------------------------------------------------------------
/config/users.d/.gitkeep.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/config/users.d/.gitkeep.xml
--------------------------------------------------------------------------------
/config/users.d/01-clickhouse-user.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 127.0.0.1
6 | 0.0.0.0/0
7 | ::/0
8 |
9 | 716b36073a90c6fe1d445ac1af85f4777c5b7a155cea359961826a030513e448
10 | clickhouse_operator
11 | default
12 |
13 |
14 |
15 |
16 | 0
17 | 1
18 | 10
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/config/users.d/02-clickhouse-default-profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 1
5 | 1000
6 | 1
7 | 1
8 |
9 |
10 |
--------------------------------------------------------------------------------
/config/users.d/03-database-ordinary.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ordinary
6 |
7 |
8 |
--------------------------------------------------------------------------------
/deploy/dev/PersistentVolumeClaim/nginx_pod.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: PersistentVolumeClaim
3 | metadata:
4 | name: myclaim
5 | spec:
6 | accessModes:
7 | - ReadWriteOnce
8 | resources:
9 | requests:
10 | storage: 1G
11 | ---
12 | apiVersion: v1
13 | kind: Pod
14 | metadata:
15 | name: nginx
16 | spec:
17 | containers:
18 | - name: nginx
19 | image: k8s.gcr.io/nginx-slim:0.8
20 | ports:
21 | - containerPort: 80
22 | name: web
23 | volumeMounts:
24 | # references .spec.volumes[0]
25 | - name: www
26 | mountPath: /usr/share/nginx/html
27 | volumes:
28 | # references PersistentVolumeClaim
29 | - name: www
30 | persistentVolumeClaim:
31 | claimName: myclaim
32 |
--------------------------------------------------------------------------------
/deploy/dev/PersistentVolumeClaim/nginx_statefulset.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: Service
3 | metadata:
4 | name: nginx
5 | labels:
6 | app: nginx
7 | spec:
8 | ports:
9 | - port: 80
10 | name: web
11 | clusterIP: None
12 | selector:
13 | app: nginx
14 | ---
15 | apiVersion: apps/v1
16 | kind: StatefulSet
17 | metadata:
18 | name: web
19 | spec:
20 | serviceName: "nginx"
21 | replicas: 2
22 | selector:
23 | matchLabels:
24 | app: nginx
25 | template:
26 | metadata:
27 | labels:
28 | app: nginx
29 | spec:
30 | containers:
31 | - name: nginx
32 | image: k8s.gcr.io/nginx-slim:0.8
33 | ports:
34 | - containerPort: 80
35 | name: web
36 | volumeMounts:
37 | # directly references .spec.volumeClaimTemplates[0]
38 | - name: www
39 | mountPath: /usr/share/nginx/html
40 | volumeClaimTemplates:
41 | - metadata:
42 | name: www
43 | spec:
44 | accessModes: [ "ReadWriteOnce" ]
45 | resources:
46 | requests:
47 | storage: 1Gi
48 |
--------------------------------------------------------------------------------
/deploy/dev/clickhouse-operator-install-yaml-template-03-section-configmap-header.yaml:
--------------------------------------------------------------------------------
1 | # Possible Template Parameters:
2 | #
3 | # ${OPERATOR_NAMESPACE}
4 | # ${OPERATOR_IMAGE}
5 | # ${CONFIGMAP_NAME}
6 | #
7 | apiVersion: v1
8 | kind: ConfigMap
9 | metadata:
10 | name: ${CONFIGMAP_NAME}
11 | namespace: ${OPERATOR_NAMESPACE}
12 | labels:
13 | app: clickhouse-operator
14 | data:
15 |
--------------------------------------------------------------------------------
/deploy/dev/clickhouse-operator-install-yaml-template-05-section-service.yaml:
--------------------------------------------------------------------------------
1 | # Possible Template Parameters:
2 | #
3 | # ${OPERATOR_NAMESPACE}
4 | #
5 | # Setup ClusterIP Service to provide monitoring metrics for Prometheus
6 | # Service would be created in kubectl-specified namespace
7 | # In order to get access outside of k8s it should be exposed as:
8 | # kubectl --namespace prometheus port-forward service/prometheus 9090
9 | # and point browser to localhost:9090
10 | kind: Service
11 | apiVersion: v1
12 | metadata:
13 | name: clickhouse-operator-metrics
14 | namespace: ${OPERATOR_NAMESPACE}
15 | labels:
16 | app: clickhouse-operator
17 | spec:
18 | ports:
19 | - port: 8888
20 | name: clickhouse-operator-metrics
21 | selector:
22 | app: clickhouse-operator
23 |
--------------------------------------------------------------------------------
/deploy/dev/clickhouse/01-service-client.yaml:
--------------------------------------------------------------------------------
1 | # Setup Service to provide access to clickhouse
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: clickhouse-service
6 | labels:
7 | app: clickhouse
8 | spec:
9 | ports:
10 | - port: 8123
11 | name: http
12 | - port: 9000
13 | name: client
14 | - port: 9009
15 | name: interserver
16 | selector:
17 | dns: chi1
18 |
--------------------------------------------------------------------------------
/deploy/dev/clickhouse/02-headless-service.yaml:
--------------------------------------------------------------------------------
1 | # Setup Headless Service for StatefulSet
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | name: chpod-hs
6 | labels:
7 | app: chpod
8 | spec:
9 | clusterIP: None
10 | selector:
11 | dns: chi1
12 |
13 |
--------------------------------------------------------------------------------
/deploy/dev/clickhouse/04-storageclass-clickhouse.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: storage.k8s.io/v1
2 | kind: StorageClass
3 | metadata:
4 | name: storage-clickhouse
5 | provisioner: kubernetes.io/no-provisioner
6 | #volumeBindingMode: WaitForFirstConsumer
7 | volumeBindingMode: Immediate
8 |
9 |
--------------------------------------------------------------------------------
/deploy/dev/dev-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
4 |
5 | source "${CUR_DIR}/dev-config.sh"
6 |
7 | if [[ "${OPERATOR_NAMESPACE}" == "kube-system" ]]; then
8 | echo "Default k8s namespace 'kube-system' must not be deleted"
9 |
10 | elif kubectl get namespace "${OPERATOR_NAMESPACE}"; then
11 | echo "Delete ClickHouse Operator namespace ${OPERATOR_NAMESPACE}"
12 | kubectl delete namespace "${OPERATOR_NAMESPACE}"
13 |
14 | else
15 | echo "No namespace ${OPERATOR_NAMESPACE} available"
16 | fi
17 |
--------------------------------------------------------------------------------
/deploy/dev/dev-reset.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
4 |
5 | source "${CUR_DIR}/dev-config.sh"
6 |
7 | echo "Reset namespace: ${OPERATOR_NAMESPACE}"
8 | "${CUR_DIR}/dev-delete.sh" && "${CUR_DIR}/dev-install.sh"
9 |
--------------------------------------------------------------------------------
/deploy/dev/dev-show.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
4 |
5 | source "${CUR_DIR}/dev-config.sh"
6 |
7 | echo "=== Pod ==="
8 | kubectl -n "${OPERATOR_NAMESPACE}" -o wide get pod
9 |
10 | echo "=== Service ==="
11 | kubectl -n "${OPERATOR_NAMESPACE}" -o wide get service
12 |
13 | echo "=== StatefulSet ==="
14 | kubectl -n "${OPERATOR_NAMESPACE}" -o wide get statefulset
15 |
16 | echo "=== ConfigMap ==="
17 | kubectl -n "${OPERATOR_NAMESPACE}" -o wide get configmap
18 |
19 | echo "=== StorageClass ==="
20 | kubectl get storageclasses
21 |
22 | echo "=== PersistentVolumeClaim ==="
23 | kubectl -n "${OPERATOR_NAMESPACE}" -o wide get persistentvolumeclaims
24 |
25 | echo "=== PersistentVolume ==="
26 | kubectl -n "${OPERATOR_NAMESPACE}" -o wide get persistentvolume
27 |
--------------------------------------------------------------------------------
/deploy/dev/dev-watch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
4 |
5 | source "${CUR_DIR}/dev-config.sh"
6 |
7 | watch -n0 " \
8 | kubectl -n ${OPERATOR_NAMESPACE} get chi,chit -o wide; \
9 | echo ''; \
10 | kubectl -n ${OPERATOR_NAMESPACE} get pod -o wide; \
11 | echo ''; \
12 | kubectl -n ${OPERATOR_NAMESPACE} get service,configmap,pv,statefulset,pvc; \
13 | "
14 |
15 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-manually/create-grafana.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | GRAFANA_NAMESPACE="${GRAFANA_NAMESPACE:-grafana}"
4 |
5 | echo "Setup Grafana into ${GRAFANA_NAMESPACE} namespace"
6 |
7 | # Let's setup all grafana-related stuff into dedicated namespace called "grafana"
8 | kubectl create namespace "${GRAFANA_NAMESPACE}"
9 |
10 | # Setup grafana into dedicated namespace
11 | kubectl apply --namespace="${GRAFANA_NAMESPACE}" -f grafana.yaml
12 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-manually/delete-grafana.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | GRAFANA_NAMESPACE="${GRAFANA_NAMESPACE:-grafana}"
4 |
5 | echo "Delete Grafana namespace ${GRAFANA_NAMESPACE}"
6 |
7 | kubectl delete namespace "${GRAFANA_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/.gitignore:
--------------------------------------------------------------------------------
1 | sensitive-data.sh
2 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/grafana-cr-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: integreatly.org/v1alpha1
2 | kind: Grafana
3 | metadata:
4 | name: "$GRAFANA_NAME"
5 | spec:
6 | ingress:
7 | enabled: False
8 | client:
9 | timeout: 30
10 | preferService: True
11 | config:
12 | log:
13 | mode: "console"
14 | level: "warn"
15 | security:
16 | admin_user: "$GRAFANA_ADMIN_USER"
17 | admin_password: "$GRAFANA_ADMIN_PASSWORD"
18 | auth:
19 | disable_login_form: $GRAFANA_DISABLE_LOGIN_FORM
20 | disable_signout_menu: $GRAFANA_DISABLE_SIGNOUT_MENU
21 | # required for Dashboard Installation - https://github.com/integr8ly/grafana-operator/issues/92
22 | auth.basic:
23 | enabled: True
24 | auth.anonymous:
25 | enabled: True
26 | # look to https://grafana.com/docs/grafana/latest/auth/generic-oauth/
27 | # server:
28 | # root_url: $GRAFANA_ROOT_URL
29 | # auth.generic_oauth:
30 | # enabled: True
31 | # name: OAuth
32 | # allow_sign_up: True
33 | # allowed_domains: $OAUTH_ALLOWED_DOMAINS
34 | # team_ids: $OAUTH_ALLOWED_TEAM_IDS
35 | # allowed_organizations: $OAUTH_ALLOWED_ORGANIZATIONS
36 | # client_id: $OAUTH_CLIENT_ID
37 | # client_secret: $OAUTH_CLIENT_SECRET
38 | # scopes: openid profile email
39 | # auth_url: https://$OAUTH_DOMAIN/authorize
40 | # token_url: https://$OAUTH_DOMAIN/oauth/token
41 | # api_url: https://$OAUTH_DOMAIN/userinfo
42 | dashboardLabelSelector:
43 | - matchExpressions:
44 | - {key: app, operator: In, values: [grafana]}
45 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/grafana-dashboard-operator-cr-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: integreatly.org/v1alpha1
2 | kind: GrafanaDashboard
3 | metadata:
4 | name: "$GRAFANA_DASHBOARD_NAME"
5 | labels:
6 | app: grafana
7 | spec:
8 | url: https://raw.githubusercontent.com/RadonDB/clickhouse-operator/master/grafana-dashboard/RadonDB_ClickHouse_Operator_dashboard.json
9 | # look to https://github.com/integr8ly/grafana-operator/issues/416#issuecomment-849498860, json used as fallback
10 | json: ""
11 | datasources:
12 | - inputName: "DS_PROMETHEUS"
13 | datasourceName: "$GRAFANA_PROMETHEUS_DATASOURCE_NAME"
14 | # TODO remove this plugin definition after resolve https://github.com/integr8ly/grafana-operator/issues/155
15 | plugins:
16 | - name: "vertamedia-clickhouse-datasource"
17 | version: "2.3.1"
18 | - name: "grafana-piechart-panel"
19 | version: "1.6.1"
20 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/grafana-dashboard-queries-cr-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: integreatly.org/v1alpha1
2 | kind: GrafanaDashboard
3 | metadata:
4 | name: "$GRAFANA_DASHBOARD_NAME"
5 | labels:
6 | app: grafana
7 | spec:
8 | url: https://raw.githubusercontent.com/RadonDB/clickhouse-operator/master/grafana-dashboard/ClickHouse_Queries_dashboard.json
9 | # look to https://github.com/integr8ly/grafana-operator/issues/416#issuecomment-849498860, json used as fallback
10 | json: ""
11 | datasources:
12 | - inputName: "DS_PROMETHEUS"
13 | datasourceName: "$GRAFANA_PROMETHEUS_DATASOURCE_NAME"
14 | plugins:
15 | - name: "vertamedia-clickhouse-datasource"
16 | version: "2.3.1"
17 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/grafana-dashboard-zookeeper-cr-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: integreatly.org/v1alpha1
2 | kind: GrafanaDashboard
3 | metadata:
4 | name: "$GRAFANA_ZOOKEEPER_DASHBOARD_NAME"
5 | labels:
6 | app: grafana
7 | spec:
8 | url: https://raw.githubusercontent.com/RadonDB/clickhouse-operator/master/grafana-dashboard/Zookeeper_dashboard.json
9 | # look to https://github.com/integr8ly/grafana-operator/issues/416#issuecomment-849498860, json used as fallback
10 | json: ""
11 | datasources:
12 | - inputName: "DS_PROMETHEUS"
13 | datasourceName: "$GRAFANA_PROMETHEUS_DATASOURCE_NAME"
14 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/grafana-data-source-clickhouse-cr-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: integreatly.org/v1alpha1
2 | kind: GrafanaDataSource
3 | metadata:
4 | name: "${GRAFANA_CLICKHOUSE_DATASOURCE_NAME}"
5 | spec:
6 | name: ${ENDPOINT}.yaml
7 | datasources:
8 | - name: "${GRAFANA_CLICKHOUSE_DATASOURCE_NAME}"
9 | type: vertamedia-clickhouse-datasource
10 | access: proxy
11 | url: "${CLICKHOUSE_URL}"
12 | basicAuth: false
13 | basicAuthUser: "${OPERATOR_CH_USER}"
14 | basicAuthPassword: "${OPERATOR_CH_PASS}"
15 | isDefault: false
16 | version: 1
17 | editable: true
18 | jsonData:
19 | tlsSkipVerify: true
20 | addCorsHeader: true
21 | defaultDatabase: "default"
22 | usePOST: true
23 | useYandexCloudAuthorization: true
24 | xHeaderUser: "${OPERATOR_CH_USER}"
25 | xHeaderKey: "${OPERATOR_CH_PASS}"
26 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/grafana-data-source-prometheus-cr-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: integreatly.org/v1alpha1
2 | kind: GrafanaDataSource
3 | metadata:
4 | name: "$GRAFANA_PROMETHEUS_DATASOURCE_NAME"
5 | spec:
6 | name: ${GRAFANA_PROMETHEUS_DATASOURCE_NAME}.yaml
7 | datasources:
8 | - name: "${GRAFANA_PROMETHEUS_DATASOURCE_NAME}"
9 | type: prometheus
10 | access: proxy
11 | url: "${PROMETHEUS_URL}"
12 | isDefault: true
13 | version: 1
14 | editable: false
15 | jsonData:
16 | tlsSkipVerify: true
17 | timeInterval: "5s"
18 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/open-grafana.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Grafana has to be proxified with `proxy-grafana.sh` before this
4 |
5 | firefox http://localhost:3000
6 |
7 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/proxy-grafana.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | GRAFANA_NAMESPACE="${GRAFANA_NAMESPACE:-grafana}"
4 |
5 | kubectl --namespace="${GRAFANA_NAMESPACE}" port-forward service/grafana-service 3000
6 |
7 |
--------------------------------------------------------------------------------
/deploy/grafana/grafana-with-grafana-operator/sensitive-data.sh.example:
--------------------------------------------------------------------------------
1 | export OAUTH_CLIENT_ID=XXX
2 | export OAUTH_CLIENT_SECRET=XXX
3 | export OAUTH_DOMAIN=yourcompany.auth0.com
4 | # domain parts from user email
5 | export OAUTH_ALLOWED_DOMAINS="localhost your-organization-domain.com"
6 | # organizations from api_url/orgs
7 | export OAUTH_ALLOWED_ORGANIZATIONS=""
8 | # teams from api_url/teams
9 | export OAUTH_ALLOWED_TEAM_IDS=""
10 |
--------------------------------------------------------------------------------
/deploy/minio/delete-minio.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | MINIO_NAMESPACE="${MINIO_NAMESPACE:-minio}"
4 |
5 | echo "Delete Minio namespace ${MINIO_NAMESPACE}"
6 |
7 | kubectl delete namespace "${MINIO_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/deploy/minio/minio-tenant-create-bucket-template.yaml:
--------------------------------------------------------------------------------
1 | ## JOB for create Bucket
2 | apiVersion: batch/v1
3 | kind: Job
4 | metadata:
5 | name: minio-create-bucket
6 | spec:
7 | template:
8 | spec:
9 | restartPolicy: Never
10 | containers:
11 | - name: minio-client
12 | image: "minio/mc:${MINIO_CLIENT_VERSION}"
13 | imagePullPolicy: Always
14 | command:
15 | - /bin/bash
16 | - -xc
17 | - mc alias set miniok8s https://minio-hl.minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY} --insecure && mc mb miniok8s/${MINIO_BACKUP_BUCKET} --ignore-existing --insecure
18 |
19 | backoffLimit: 10
20 |
--------------------------------------------------------------------------------
/deploy/operator/clickhouse-operator-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | OPERATOR_NAMESPACE="${OPERATOR_NAMESPACE:-kube-system}"
4 |
5 |
6 | if [[ "${OPERATOR_NAMESPACE}" == "kube-system" ]]; then
7 | echo "Default k8s namespace 'kube-system' must not be deleted"
8 | echo "Delete components only"
9 | kubectl delete --namespace="${OPERATOR_NAMESPACE}" -f clickhouse-operator-install-bundle.yaml
10 | else
11 | echo "Delete ClickHouse Operator namespace ${OPERATOR_NAMESPACE}"
12 | kubectl delete namespace "${OPERATOR_NAMESPACE}"
13 | fi
14 |
--------------------------------------------------------------------------------
/deploy/operator/clickhouse-operator-install-service.yaml:
--------------------------------------------------------------------------------
1 | # Possible Template Parameters:
2 | #
3 | # -
4 | #
5 | # Setup ClusterIP Service to provide monitoring metrics for Prometheus
6 | # Service would be created in kubectl-specified namespace
7 | # In order to get access outside of k8s it should be exposed as:
8 | # kubectl --namespace prometheus port-forward service/prometheus 9090
9 | # and point browser to localhost:9090
10 | kind: Service
11 | apiVersion: v1
12 | metadata:
13 | name: clickhouse-operator-metrics
14 | labels:
15 | app: clickhouse-operator
16 | spec:
17 | ports:
18 | - port: 8888
19 | name: clickhouse-operator-metrics
20 | selector:
21 | app: clickhouse-operator
22 |
--------------------------------------------------------------------------------
/deploy/operator/clickhouse-operator-install-template-service.yaml:
--------------------------------------------------------------------------------
1 | # Possible Template Parameters:
2 | #
3 | # $OPERATOR_NAMESPACE
4 | #
5 | # Setup ClusterIP Service to provide monitoring metrics for Prometheus
6 | # Service would be created in kubectl-specified namespace
7 | # In order to get access outside of k8s it should be exposed as:
8 | # kubectl --namespace prometheus port-forward service/prometheus 9090
9 | # and point browser to localhost:9090
10 | kind: Service
11 | apiVersion: v1
12 | metadata:
13 | name: clickhouse-operator-metrics
14 | namespace: $OPERATOR_NAMESPACE
15 | labels:
16 | app: clickhouse-operator
17 | spec:
18 | ports:
19 | - port: 8888
20 | name: clickhouse-operator-metrics
21 | selector:
22 | app: clickhouse-operator
23 |
--------------------------------------------------------------------------------
/deploy/operator/clickhouse-operator-install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | OPERATOR_NAMESPACE="${OPERATOR_NAMESPACE:-kube-system}"
4 | VALIDATE_YAML="${VALIDATE_YAML:-true}"
5 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6 |
7 | echo "Setup ClickHouse Operator into ${OPERATOR_NAMESPACE} namespace"
8 |
9 | echo "1. Build manifest"
10 | OPERATOR_NAMESPACE="${OPERATOR_NAMESPACE}" ${CUR_DIR}/build-clickhouse-operator-install-yaml.sh
11 |
12 | # Let's setup all clickhouse-operator-related stuff into dedicated namespace
13 | if [[ "${OPERATOR_NAMESPACE}" == "kube-system" ]]; then
14 | echo "2. No need to create kube-system namespace"
15 | elif kubectl get namespace "${OPERATOR_NAMESPACE}" >/dev/null 2>&1; then
16 | echo "2. Namespace ${OPERATOR_NAMESPACE} already exists, install operator into it"
17 | else
18 | echo "2. Create namespace ${OPERATOR_NAMESPACE} and install operator into it"
19 | kubectl create namespace "${OPERATOR_NAMESPACE}"
20 | fi
21 |
22 | # Setup into dedicated namespace
23 | echo "3. Install operator into ${OPERATOR_NAMESPACE} namespace"
24 | kubectl apply --validate=${VALIDATE_YAML} --namespace="${OPERATOR_NAMESPACE}" -f "${CUR_DIR}/clickhouse-operator-install-bundle.yaml"
25 |
--------------------------------------------------------------------------------
/deploy/prometheus/.gitignore:
--------------------------------------------------------------------------------
1 | prometheus-sensitive-data.sh
2 |
--------------------------------------------------------------------------------
/deploy/prometheus/delete-prometheus.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | PROMETHEUS_NAMESPACE="${PROMETHEUS_NAMESPACE:-prometheus}"
4 |
5 | echo "Delete Prometheus namespace ${PROMETHEUS_NAMESPACE}"
6 |
7 | kubectl delete namespace "${PROMETHEUS_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/deploy/prometheus/prometheus-sensitive-data.example.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # look at https://api.slack.com/incoming-webhooks how to enable external webhooks in Slack API
3 | export SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXXX/YYYYY/ZZZZZ
4 | export SLACK_CHANNEL="#alerts-channel-name"
5 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/01-service-client-access.yaml:
--------------------------------------------------------------------------------
1 | # Setup Service to provide access to Zookeeper for clients
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | # DNS would be like zookeeper.zoons
6 | name: zookeeper
7 | labels:
8 | app: zookeeper
9 | spec:
10 | ports:
11 | - port: 2181
12 | name: client
13 | - port: 7000
14 | name: prometheus
15 | selector:
16 | app: zookeeper
17 | what: node
18 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/02-headless-service.yaml:
--------------------------------------------------------------------------------
1 | # Setup Headless Service for StatefulSet
2 | apiVersion: v1
3 | kind: Service
4 | metadata:
5 | # DNS would be like zookeeper-0.zookeepers.etc
6 | name: zookeepers
7 | labels:
8 | app: zookeeper
9 | spec:
10 | ports:
11 | - port: 2888
12 | name: server
13 | - port: 3888
14 | name: leader-election
15 | clusterIP: None
16 | selector:
17 | app: zookeeper
18 | what: node
19 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/03-pod-disruption-budget.yaml:
--------------------------------------------------------------------------------
1 | # Setup max number of unavailable pods in StatefulSet
2 | apiVersion: policy/v1beta1
3 | kind: PodDisruptionBudget
4 | metadata:
5 | name: zookeeper-pod-disruption-budget
6 | spec:
7 | selector:
8 | matchLabels:
9 | app: zookeeper
10 | maxUnavailable: 1
11 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/04-storageclass-zookeeper.yaml:
--------------------------------------------------------------------------------
1 | # Specify StorageClass in case there is no default storage class provided
2 |
3 | #apiVersion: storage.k8s.io/v1
4 | #kind: StorageClass
5 | #metadata:
6 | # name: storageclass-zookeeper
7 | #provisioner: kubernetes.io/no-provisioner
8 | ## Choose desired 'volumeBindingMode'
9 | ##volumeBindingMode: WaitForFirstConsumer
10 | #volumeBindingMode: Immediate
11 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/zookeeper-create-universal.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # This file is not supposed to be run directly
4 | # It must be sourced from task "create" files
5 |
6 | if [[ -z "${ZK_NAMESPACE}" ]]; then
7 | echo "Please specify \$ZK_NAMESPACE"
8 | exit -1
9 | fi
10 |
11 | if [[ -z "${YAML_FILES_LIST}" ]]; then
12 | echo "Please specify \$YAML_FILES_LIST"
13 | exit -1
14 | fi
15 |
16 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
17 |
18 | kubectl create namespace ${ZK_NAMESPACE}
19 | for FILE in ${YAML_FILES_LIST}; do
20 | kubectl -n "${ZK_NAMESPACE}" apply -f "${CUR_DIR}/${FILE}"
21 | done
22 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/zookeeper-persistent-volume-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoons}"
4 | YAML_FILES_LIST="\
5 | 01-service-client-access.yaml \
6 | 02-headless-service.yaml \
7 | 03-pod-disruption-budget.yaml \
8 | 04-storageclass-zookeeper.yaml \
9 | 05-stateful-set-persistent-volume.yaml\
10 | "
11 |
12 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
13 |
14 | source "${CUR_DIR}/zookeeper-create-universal.sh"
15 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/zookeeper-persistent-volume-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoons}"
4 |
5 | kubectl delete namespace ${ZK_NAMESPACE}
6 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/zookeeper-volume-emptyDir-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoons}"
4 | YAML_FILES_LIST="\
5 | 01-service-client-access.yaml \
6 | 02-headless-service.yaml \
7 | 03-pod-disruption-budget.yaml \
8 | 04-storageclass-zookeeper.yaml \
9 | 05-stateful-set-volume-emptyDir.yaml\
10 | "
11 |
12 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
13 |
14 | source "${CUR_DIR}/zookeeper-create-universal.sh"
15 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/zookeeper-volume-emptyDir-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoons}"
4 |
5 | kubectl delete namespace ${ZK_NAMESPACE}
6 |
--------------------------------------------------------------------------------
/deploy/zookeeper/advanced/zookeeper-watch.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoons}"
4 |
5 | kubectl -n "${ZK_NAMESPACE}" get all,pv,pvc -o wide
6 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-persistent-volume/README.md:
--------------------------------------------------------------------------------
1 | Please note that zookeeper-1-node.yaml and zookeeper-3-node.yaml are configured with following requests:
2 |
3 | * cpu: 1
4 | * memory: 4Gi
5 | * storage: 50Gi, with default storage class
6 |
7 | This is ok for most of cases, but you may need to change it for heavily loaded apps.
8 |
9 | Use zookeeper-1-node-1GB-for-tests-only.yaml for testing, it only requests:
10 |
11 | * cpu: 0.5
12 | * memory: 1Gi
13 | * storage: 1Gi, with default storage class
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-persistent-volume/zookeeper-1-node-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo1ns}"
4 |
5 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6 |
7 | kubectl create namespace "${ZK_NAMESPACE}"
8 | kubectl --namespace="${ZK_NAMESPACE}" apply -f "${CUR_DIR}/zookeeper-1-node.yaml"
9 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-persistent-volume/zookeeper-1-node-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo1ns}"
4 |
5 | echo "Delete Zookeeper namespace ${ZK_NAMESPACE}"
6 |
7 | kubectl delete namespace "${ZK_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-persistent-volume/zookeeper-3-nodes-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo3ns}"
4 |
5 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6 |
7 | kubectl create namespace "${ZK_NAMESPACE}"
8 | kubectl --namespace="${ZK_NAMESPACE}" apply -f "${CUR_DIR}/zookeeper-3-nodes.yaml"
9 |
10 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-persistent-volume/zookeeper-3-nodes-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo3ns}"
4 |
5 | echo "Delete Zookeeper namespace ${ZK_NAMESPACE}"
6 |
7 | kubectl delete namespace "${ZK_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-volume-emptyDir/zookeeper-1-node-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo1ns}"
4 |
5 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6 |
7 | kubectl create namespace "${ZK_NAMESPACE}"
8 | kubectl --namespace="${ZK_NAMESPACE}" apply -f "${CUR_DIR}/zookeeper-1-node.yaml"
9 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-volume-emptyDir/zookeeper-1-node-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo1ns}"
4 |
5 | echo "Delete Zookeeper namespace ${ZK_NAMESPACE}"
6 |
7 | kubectl delete namespace "${ZK_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-volume-emptyDir/zookeeper-3-nodes-create.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo3ns}"
4 |
5 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6 |
7 | kubectl create namespace "${ZK_NAMESPACE}"
8 | kubectl --namespace="${ZK_NAMESPACE}" apply -f "${CUR_DIR}/zookeeper-3-nodes.yaml"
9 |
10 |
--------------------------------------------------------------------------------
/deploy/zookeeper/quick-start-volume-emptyDir/zookeeper-3-nodes-delete.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZK_NAMESPACE="${ZK_NAMESPACE:-zoo3ns}"
4 |
5 | echo "Delete Zookeeper namespace ${ZK_NAMESPACE}"
6 |
7 | kubectl delete namespace "${ZK_NAMESPACE}"
8 |
--------------------------------------------------------------------------------
/dev/RnD/StatefulSet/sts.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1
2 | kind: StatefulSet
3 | metadata:
4 | name: web
5 | spec:
6 | serviceName: "nginx"
7 | replicas: 1
8 | selector:
9 | matchLabels:
10 | app: nginx
11 |
12 | template:
13 | metadata:
14 | labels:
15 | app: nginx
16 | spec:
17 | containers:
18 | - name: nginx
19 |
20 | # image: k8s.gcr.io/nginx-slim:0.8
21 | # image: nginx
22 | # image: nginx:1.17.8
23 | # image: nginx:1.16.1
24 | # image: bash
25 | image: mysql
26 |
27 | resources:
28 | requests:
29 | memory: "64Mi"
30 | cpu: "250m"
31 | limits:
32 | memory: "128Mi"
33 | cpu: "500m"
34 |
35 | ports:
36 | - containerPort: 80
37 | name: web
38 | volumeMounts:
39 | - name: www
40 | mountPath: /usr/share/nginx/html
41 |
42 | volumeClaimTemplates:
43 | - metadata:
44 | name: www
45 | spec:
46 | accessModes: [ "ReadWriteOnce" ]
47 | resources:
48 | requests:
49 | storage: 1Gi
50 | # storage: 10Gi
51 |
52 |
--------------------------------------------------------------------------------
/dev/RnD/chopsim/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 | "io/ioutil"
7 | "log"
8 | "os"
9 |
10 | "github.com/radondb/clickhouse-operator/dev/RnD/chopsim/parser"
11 | "gopkg.in/yaml.v2"
12 | )
13 |
14 | type dataYAML struct{}
15 |
16 | func (d dataYAML) Marshal(buffer *bytes.Buffer, object interface{}) {
17 | b, err := yaml.Marshal(object)
18 | if err != nil {
19 | log.Fatal("Unable to marshal manifest data -> ", err)
20 | }
21 | buffer.Write(b)
22 | }
23 |
24 | func main() {
25 | data, err := ioutil.ReadAll(os.Stdin)
26 | if err != nil {
27 | log.Fatal("Unable to read data from the standard input -> ", err)
28 | }
29 | chi := &parser.ClickHouseInstallation{}
30 | if err := yaml.Unmarshal(data, chi); err != nil {
31 | log.Fatal("Unable to unmarshal manifest data -> ", err)
32 | }
33 | d := dataYAML{}
34 | fmt.Println(parser.GenerateArtifacts(chi, d))
35 | }
36 |
--------------------------------------------------------------------------------
/dev/RnD/diff/main.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package main
16 |
17 | import (
18 | "fmt"
19 | "github.com/r3labs/diff"
20 | )
21 |
22 | type order struct {
23 | ID string `diff:"id"`
24 | Items []int `diff:"items"`
25 | }
26 |
27 | func main() {
28 |
29 | a, b := ex4()
30 |
31 | fmt.Printf("test diff\n")
32 | changelog, err := diff.Diff(a, b)
33 |
34 | if err != nil {
35 | fmt.Printf("Error %v\n", err)
36 | }
37 |
38 | fmt.Printf("cl: %v", changelog)
39 | }
40 |
41 | func ex4() ([]int, []int) {
42 | a := []int{1, 1}
43 | b := []int{1}
44 |
45 | return a, b
46 | }
47 |
48 | func ex3() ([]int, []int) {
49 | a := []int{1, 2, 3, 4}
50 | b := []int{1, 2, 3}
51 |
52 | return a, b
53 | }
54 |
--------------------------------------------------------------------------------
/dev/RnD/glog/test.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "flag"
5 |
6 | "github.com/golang/glog"
7 | )
8 |
9 | func i() {
10 | glog.Info("----")
11 | glog.Info("v: ", flag.Lookup("v").Value)
12 | glog.Info("logtostderr: ", flag.Lookup("logtostderr").Value)
13 | glog.Info("alsologtostderr: ", flag.Lookup("alsologtostderr").Value)
14 | glog.Info("----")
15 | }
16 |
17 | func main() {
18 | flag.Parse()
19 | glog.Info("hi_a")
20 | i()
21 | // flag.Lookup("logtostderr").Value.Set("true")
22 | flag.Set("logtostderr", "true")
23 | glog.Info("hi_b")
24 | i()
25 |
26 | //flag.Lookup("log_dir").Value.Set("/path/to/log/dir")
27 |
28 | glog.Info("Try V() with default v")
29 | glog.V(0).Info("v0a")
30 | glog.V(1).Info("v1a")
31 | glog.V(4).Info("v4a")
32 | glog.V(5).Info("v5a")
33 | glog.V(6).Info("v6a")
34 | v := "5"
35 | glog.Info("Try V() = ", v)
36 | //flag.Lookup("v").Value.Set(v)
37 | flag.Set("v", v)
38 | glog.V(0).Info("v0b")
39 | glog.V(1).Info("v1b")
40 | glog.V(4).Info("v4b")
41 | glog.V(5).Info("v5b")
42 | glog.V(6).Info("v6b")
43 | i()
44 | //etc.
45 | }
46 |
47 | // >>> hi_b
48 | // >>> v4b
49 |
--------------------------------------------------------------------------------
/dev/community-operators-crd-diff.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Source configuration
4 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
5 | source "${CUR_DIR}/go_build_config.sh"
6 |
7 | # Where community-operators sources are located
8 | CO_PATH=~/dev/community-operators/operators/clickhouse/${VERSION}
9 |
10 | # Ask to prepare copy of required files
11 | echo "Please ensure new version ${VERSION} is already available by the following path:"
12 | echo "${CO_PATH}"
13 | echo "Copy files from previous version and edit them accordingly."
14 | read -n 1 -r -s -p $'Press enter to continue...\n'
15 |
16 | if [[ ! -d "${CO_PATH}" ]]; then
17 | echo "No ${CO_PATH} available! Abort."
18 | exit 1
19 | fi
20 |
21 | # Compare
22 | meld "${MANIFESTS_ROOT}"/dev/clickhouse-operator-install-yaml-template-01-section-crd-01-chi.yaml "${CO_PATH}"/clickhouseinstallations.clickhouse.radondb.com.crd.yaml
23 | meld "${MANIFESTS_ROOT}"/dev/clickhouse-operator-install-yaml-template-01-section-crd-02-chit.yaml "${CO_PATH}"/clickhouseinstallationtemplates.clickhouse.radondb.com.crd.yaml
24 | meld "${MANIFESTS_ROOT}"/dev/clickhouse-operator-install-yaml-template-01-section-crd-03-chopconf.yaml "${CO_PATH}"/clickhouseoperatorconfigurations.clickhouse.radondb.com.crd.yaml
25 |
--------------------------------------------------------------------------------
/dev/find_unformatted_sources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Find unformatted .go sources
4 |
5 | # Exit immediately when a command fails
6 | set -o errexit
7 | # Error on unset variables
8 | set -o nounset
9 | # Only exit with zero if all commands of the pipeline exit successfully
10 | set -o pipefail
11 |
12 | # Source configuration
13 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
14 | source "${CUR_DIR}/go_build_config.sh"
15 |
16 | # Prepare list of all .go files in the project, but exclude all files from /vendor/ folder
17 | GO_FILES_LIST=$(find "${SRC_ROOT}" -name \*.go -not -path "${SRC_ROOT}/vendor/*" -print)
18 | # Prepare unformatted files list
19 | UNFORMATTED_FILES_LIST=$(gofmt -l ${GO_FILES_LIST})
20 |
21 | if [[ ${UNFORMATTED_FILES_LIST} ]]; then
22 | for FILE in ${UNFORMATTED_FILES_LIST}; do
23 | echo "${FILE}"
24 | done
25 | exit 1
26 | fi
27 |
28 | exit 0
29 |
--------------------------------------------------------------------------------
/dev/format_unformatted_sources.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Find and format unformatted .go sources
4 |
5 | # Exit immediately when a command fails
6 | set -o errexit
7 | # Error on unset variables
8 | set -o nounset
9 | # Only exit with zero if all commands of the pipeline exit successfully
10 | set -o pipefail
11 |
12 | # Source configuration
13 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
14 | source "${CUR_DIR}/go_build_config.sh"
15 |
16 | # Iterate over list of unformatted files and format each of them
17 | "${CUR_DIR}/find_unformatted_sources.sh" | while read -r FILE; do
18 | go fmt "${FILE}"
19 | done
20 |
--------------------------------------------------------------------------------
/dev/go_build_all.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build clickhouse-operator
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 | PROJECT_ROOT="$(realpath "${CUR_DIR}/..")"
9 |
10 | "${PROJECT_ROOT}"/dockerfile/build-docker-files.sh
11 | "${CUR_DIR}"/go_build_metrics_exporter.sh
12 | "${CUR_DIR}"/go_build_operator.sh
13 | "${CUR_DIR}"/run_gocard.sh
14 | "${CUR_DIR}"/run_gosec.sh
15 |
--------------------------------------------------------------------------------
/dev/go_build_config.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build configuration options
4 |
5 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
6 | SRC_ROOT="$(realpath "${CUR_DIR}/..")"
7 |
8 | MANIFESTS_ROOT="${SRC_ROOT}/deploy"
9 | CMD_ROOT="${SRC_ROOT}/cmd"
10 | PKG_ROOT="${SRC_ROOT}/pkg"
11 |
12 | REPO="github.com/radondb/radondb-clickhouse-operator"
13 | # 0.9.3
14 | VERSION=$(cd "${SRC_ROOT}"; cat release)
15 | # 885c3f7
16 | GIT_SHA=$(cd "${CUR_DIR}"; git rev-parse --short HEAD)
17 | # 2020-03-07 14:54:56
18 | NOW=$(date "+%FT%T")
19 |
20 | # Operator binary name can be specified externally
21 | # Default - put 'clickhouse-operator' into cur dir
22 | OPERATOR_BIN="${OPERATOR_BIN:-${SRC_ROOT}/dev/bin/clickhouse-operator}"
23 |
24 | # Metrics exporter binary name can be specified externally
25 | # Default - put 'metrics-exporter' into cur dir
26 | METRICS_EXPORTER_BIN="${METRICS_EXPORTER_BIN:-${SRC_ROOT}/dev/bin/metrics-exporter}"
27 |
28 | MODULES_DIR=vendor
29 |
--------------------------------------------------------------------------------
/dev/go_build_metrics_exporter.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build metrics-exporter
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 | source "${CUR_DIR}/go_build_config.sh"
9 |
10 | # Build clickhouse-operator install .yaml manifest
11 | "${MANIFESTS_ROOT}/operator/build-clickhouse-operator-install-yaml.sh"
12 |
13 | # Prepare modules
14 | GO111MODULE=on go mod tidy
15 | GO111MODULE=on go mod "${MODULES_DIR}"
16 |
17 | OUTPUT_BINARY="${METRICS_EXPORTER_BIN}"
18 | MAIN_SRC_FILE="${SRC_ROOT}/cmd/metrics_exporter/main.go"
19 |
20 | GOOS=linux
21 | GOARCH=amd64
22 |
23 | if CGO_ENABLED=0 GO111MODULE=on GOOS="${GOOS}" GOARCH="${GOARCH}" go build \
24 | -mod="${MODULES_DIR}" \
25 | -a \
26 | -ldflags " \
27 | -X ${REPO}/pkg/version.Version=${VERSION} \
28 | -X ${REPO}/pkg/version.GitSHA=${GIT_SHA} \
29 | -X ${REPO}/pkg/version.BuiltAt=${NOW} \
30 | " \
31 | -o "${OUTPUT_BINARY}" \
32 | "${MAIN_SRC_FILE}"
33 | then
34 | echo "Build OK"
35 | else
36 | echo "WARNING! BUILD FAILED!"
37 | echo "Check logs for details"
38 | exit 1
39 | fi
40 |
--------------------------------------------------------------------------------
/dev/go_build_metrics_exporter_clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Delete metrics-exporter
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 | source "${CUR_DIR}/go_build_config.sh"
9 |
10 | OUTPUT_BINARY="${METRICS_EXPORTER_BIN}"
11 |
12 | rm -f "${OUTPUT_BINARY}"
13 |
--------------------------------------------------------------------------------
/dev/go_build_operator.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build clickhouse-operator
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 | source "${CUR_DIR}/go_build_config.sh"
9 |
10 | # Build clickhouse-operator install .yaml manifest
11 | "${MANIFESTS_ROOT}/operator/build-clickhouse-operator-install-yaml.sh"
12 |
13 | # Prepare modules
14 | GO111MODULE=on go mod tidy
15 | GO111MODULE=on go mod "${MODULES_DIR}"
16 |
17 | OUTPUT_BINARY="${OPERATOR_BIN}"
18 | MAIN_SRC_FILE="${SRC_ROOT}/cmd/operator/main.go"
19 |
20 | GOOS=linux
21 | GOARCH=amd64
22 |
23 | if CGO_ENABLED=0 GO111MODULE=on GOOS="${GOOS}" GOARCH="${GOARCH}" go build \
24 | -mod="${MODULES_DIR}" \
25 | -a \
26 | -ldflags " \
27 | -X ${REPO}/pkg/version.Version=${VERSION} \
28 | -X ${REPO}/pkg/version.GitSHA=${GIT_SHA} \
29 | -X ${REPO}/pkg/version.BuiltAt=${NOW} \
30 | " \
31 | -o "${OUTPUT_BINARY}" \
32 | "${MAIN_SRC_FILE}"
33 | then
34 | echo "Build OK"
35 | else
36 | echo "WARNING! BUILD FAILED!"
37 | echo "Check logs for details"
38 | exit 1
39 | fi
40 |
--------------------------------------------------------------------------------
/dev/go_build_operator_clean.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Delete clickhouse-operator
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 | source "${CUR_DIR}/go_build_config.sh"
9 |
10 | OUTPUT_BINARY="${OPERATOR_BIN}"
11 |
12 | rm -f "${OUTPUT_BINARY}"
13 |
--------------------------------------------------------------------------------
/dev/image_build_all_dev.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build clickhouse-operator
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 |
9 | "${CUR_DIR}"/image_build_metrics_exporter_dev.sh
10 | "${CUR_DIR}"/image_build_operator_dev.sh
11 |
--------------------------------------------------------------------------------
/dev/image_build_all_radondb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build clickhouse-operator
4 | # Do not forget to update version
5 |
6 | # Source configuration
7 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
8 |
9 | "${CUR_DIR}"/image_build_metrics_exporter_radondb.sh
10 | "${CUR_DIR}"/image_build_operator_radondb.sh
11 |
--------------------------------------------------------------------------------
/dev/image_build_metrics_exporter_dev.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Dev docker image builder
4 |
5 | # Source configuration
6 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
7 | source "${CUR_DIR}/go_build_config.sh"
8 |
9 | # Externally configurable build-dependent options
10 | TAG="${TAG:-radondb/chronus-metrics-operator:dev}"
11 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}"
12 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
13 | MINIKUBE="${MINIKUBE:-no}"
14 |
15 | TAG="${TAG}" \
16 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
17 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
18 | MINIKUBE="${MINIKUBE}" \
19 | "${CUR_DIR}/image_build_metrics_exporter_universal.sh"
20 |
--------------------------------------------------------------------------------
/dev/image_build_metrics_exporter_radondb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Production docker image builder
4 |
5 | # Source configuration
6 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
7 | source "${CUR_DIR}/go_build_config.sh"
8 |
9 | # Externally configurable build-dependent options
10 | PROJECT_ROOT="$(realpath "${CUR_DIR}/..")"
11 | TAG="radondb/chronus-metrics-operator:$(cat ${PROJECT_ROOT}/release)"
12 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}"
13 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
14 | MINIKUBE="${MINIKUBE:-no}"
15 |
16 | TAG="${TAG}" \
17 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
18 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
19 | MINIKUBE="${MINIKUBE}" \
20 | "${CUR_DIR}/image_build_metrics_exporter_universal.sh"
21 |
--------------------------------------------------------------------------------
/dev/image_build_metrics_exporter_universal.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Universal docker image builder
4 |
5 | # Externally configurable build-dependent options
6 | TAG="${TAG:-radondb/chronus-metrics-operator:dev}"
7 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}"
8 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
9 | MINIKUBE="${MINIKUBE:-no}"
10 |
11 | # Source-dependent options
12 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
13 | SRC_ROOT="$(realpath "${CUR_DIR}/..")"
14 | source "${CUR_DIR}/go_build_config.sh"
15 |
16 | DOCKERFILE_DIR="${SRC_ROOT}/dockerfile/metrics-exporter"
17 | DOCKERFILE="${DOCKERFILE_DIR}/Dockerfile"
18 |
19 | # Build clickhouse-operator install .yaml manifest
20 | "${MANIFESTS_ROOT}/operator/build-clickhouse-operator-install-yaml.sh"
21 |
22 | # Build image with Docker
23 | if [[ "${MINIKUBE}" == "yes" ]]; then
24 | # We'd like to build for minikube
25 | eval $(minikube docker-env)
26 | fi
27 |
28 | if docker build -t "${TAG}" -f "${DOCKERFILE}" "${SRC_ROOT}"; then
29 | # Image ready, time to publish it
30 | if [[ "${DOCKERHUB_PUBLISH}" == "yes" ]]; then
31 | if [[ ! -z "${DOCKERHUB_LOGIN}" ]]; then
32 | echo "Dockerhub login specified: '${DOCKERHUB_LOGIN}', perform login"
33 | docker login -u "${DOCKERHUB_LOGIN}"
34 | fi
35 | docker push "${TAG}"
36 | fi
37 | else
38 | echo "FAILED docker build! Abort."
39 | exit 1
40 | fi
41 |
--------------------------------------------------------------------------------
/dev/image_build_operator_dev.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Dev docker image builder
4 |
5 | # Source configuration
6 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
7 | source "${CUR_DIR}/go_build_config.sh"
8 |
9 | # Externally configurable build-dependent options
10 | TAG="${TAG:-radondb/chronus-operator:dev}"
11 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}"
12 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
13 | MINIKUBE="${MINIKUBE:-no}"
14 |
15 | TAG="${TAG}" \
16 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
17 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
18 | MINIKUBE="${MINIKUBE}" \
19 | "${CUR_DIR}/image_build_operator_universal.sh"
20 |
--------------------------------------------------------------------------------
/dev/image_build_operator_radondb.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Production docker image builder
4 |
5 | # Source configuration
6 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
7 | source "${CUR_DIR}/go_build_config.sh"
8 |
9 | # Externally configurable build-dependent options
10 | PROJECT_ROOT="$(realpath "${CUR_DIR}/..")"
11 | TAG="radondb/chronus-operator:$(cat ${PROJECT_ROOT}/release)"
12 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}"
13 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
14 | MINIKUBE="${MINIKUBE:-no}"
15 |
16 | TAG="${TAG}" \
17 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}" \
18 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH}" \
19 | MINIKUBE="${MINIKUBE}" \
20 | "${CUR_DIR}/image_build_operator_universal.sh"
21 |
--------------------------------------------------------------------------------
/dev/image_build_operator_universal.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Universal docker image builder
4 |
5 | # Externally configurable build-dependent options
6 | TAG="${TAG:-suhouzhen/chronus-operator:dev}"
7 | DOCKERHUB_LOGIN="${DOCKERHUB_LOGIN}"
8 | DOCKERHUB_PUBLISH="${DOCKERHUB_PUBLISH:-yes}"
9 | MINIKUBE="${MINIKUBE:-no}"
10 |
11 | # Source-dependent options
12 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
13 | SRC_ROOT="$(realpath "${CUR_DIR}/..")"
14 | source "${CUR_DIR}/go_build_config.sh"
15 |
16 | DOCKERFILE_DIR="${SRC_ROOT}/dockerfile/operator"
17 | DOCKERFILE="${DOCKERFILE_DIR}/Dockerfile"
18 |
19 | # Build clickhouse-operator install .yaml manifest
20 | "${MANIFESTS_ROOT}/operator/build-clickhouse-operator-install-yaml.sh"
21 |
22 | # Build image with Docker
23 | if [[ "${MINIKUBE}" == "yes" ]]; then
24 | # We'd like to build for minikube
25 | eval $(minikube docker-env)
26 | fi
27 |
28 | if docker build -t "${TAG}" -f "${DOCKERFILE}" "${SRC_ROOT}"; then
29 | # Image ready, time to publish it
30 | if [[ "${DOCKERHUB_PUBLISH}" == "yes" ]]; then
31 | if [[ ! -z "${DOCKERHUB_LOGIN}" ]]; then
32 | echo "Dockerhub login specified: '${DOCKERHUB_LOGIN}', perform login"
33 | docker login -u "${DOCKERHUB_LOGIN}"
34 | fi
35 | docker push "${TAG}"
36 | fi
37 | else
38 | echo "FAILED docker build! Abort."
39 | exit 1
40 | fi
41 |
--------------------------------------------------------------------------------
/dev/run_gocard.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Source configuration
4 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
5 | source "${CUR_DIR}/go_build_config.sh"
6 |
7 | goreportcard-cli -v -d "${CMD_ROOT}"
8 | goreportcard-cli -v -d "${PKG_ROOT}"
9 |
10 |
--------------------------------------------------------------------------------
/dev/run_vet.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # The WithCancel, WithDeadline, and WithTimeout functions take a Context (the parent)
4 | # and return a derived Context (the child) and a CancelFunc.
5 | # Calling the CancelFunc cancels the child and its children, removes the parent's reference to the child,
6 | # and stops any associated timers.
7 | #
8 | # Failing to call the CancelFunc leaks the child and its children until the parent is canceled or the timer fires.
9 | # The go vet tool checks that CancelFuncs are used on all control-flow paths.
10 |
--------------------------------------------------------------------------------
/dockerfile/actions.secret:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/dockerfile/actions.secret
--------------------------------------------------------------------------------
/dockerfile/build-docker-files.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Build docker files
4 |
5 | # Paths
6 | CUR_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
7 | PROJECT_ROOT="$(realpath "${CUR_DIR}/..")"
8 | OPERATOR_DOCKERFILE_TEMPLATE="${PROJECT_ROOT}/dockerfile/operator/template/Dockerfile"
9 | OPERATOR_DOCKERFILE="${PROJECT_ROOT}/dockerfile/operator/Dockerfile"
10 | METRICS_EXPORTER_DOCKERFILE_TEMPLATE="${PROJECT_ROOT}/dockerfile/metrics-exporter/template/Dockerfile"
11 | METRICS_EXPORTER_DOCKERFILE="${PROJECT_ROOT}/dockerfile/metrics-exporter/Dockerfile"
12 |
13 | # Versions
14 | VERSION=$(cat ${PROJECT_ROOT}/release)
15 | RELEASE="1"
16 | OPERATOR_VERSION="${OPERATOR_VERSION:-$VERSION}"
17 | METRICS_EXPORTER_VERSION="${METRICS_EXPORTER_VERSION:-$VERSION}"
18 |
19 | # Run generator
20 |
21 | #
22 | # Build dockerfiles
23 | #
24 |
25 | cat "${OPERATOR_DOCKERFILE_TEMPLATE}" | \
26 | VERSION="${VERSION}" \
27 | RELEASE="${RELEASE}" \
28 | OPERATOR_VERSION="${OPERATOR_VERSION}" \
29 | METRICS_EXPORTER_VERSION="${METRICS_EXPORTER_VERSION}" \
30 | envsubst \
31 | > "${OPERATOR_DOCKERFILE}"
32 |
33 | cat "${METRICS_EXPORTER_DOCKERFILE_TEMPLATE}" | \
34 | VERSION="${VERSION}" \
35 | RELEASE="${RELEASE}" \
36 | OPERATOR_VERSION="${OPERATOR_VERSION}" \
37 | METRICS_EXPORTER_VERSION="${METRICS_EXPORTER_VERSION}" \
38 | envsubst \
39 | > "${METRICS_EXPORTER_DOCKERFILE}"
40 |
--------------------------------------------------------------------------------
/docs/architecture.md:
--------------------------------------------------------------------------------
1 | # Architecture
2 |
3 |
4 | Like a Deployment , a StatefulSet manages Pods that are based on an **identical** container spec.
5 | Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods.
6 | These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling.
7 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/02-incorrect-image-update-01-initial-position.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-image-2"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: update
9 | templates:
10 | podTemplate: clickhouse:19.1.10
11 | layout:
12 | shards:
13 | - replicas:
14 | - port: 9000
15 | - port: 9000
16 | - port: 9000
17 |
18 | templates:
19 | podTemplates:
20 | - name: clickhouse:19.1.10
21 | spec:
22 | containers:
23 | - name: clickhouse-pod
24 | image: yandex/clickhouse-server:19.1.10
25 | ports:
26 | - name: http
27 | containerPort: 8123
28 | - name: client
29 | containerPort: 9000
30 | - name: interserver
31 | containerPort: 9009
32 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/02-incorrect-image-update-02-apply-incorrect-update.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-image-2"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: update
9 | templates:
10 | podTemplate: clickhouse:19.1.10
11 | layout:
12 | shards:
13 | - replicas:
14 | - port: 9000
15 | - port: 9000
16 | - port: 9000
17 | templates:
18 | podTemplate: clickhouse:19.1.100
19 |
20 | templates:
21 | podTemplates:
22 | # Incorrect image
23 | - name: clickhouse:19.1.100
24 | spec:
25 | containers:
26 | - name: clickhouse-pod
27 | image: yandex/clickhouse-server:19.1.100
28 | ports:
29 | - name: http
30 | containerPort: 8123
31 | - name: client
32 | containerPort: 9000
33 | - name: interserver
34 | containerPort: 9009
35 |
36 | - name: clickhouse:19.1.10
37 | spec:
38 | containers:
39 | - name: clickhouse-pod
40 | image: yandex/clickhouse-server:19.1.10
41 | ports:
42 | - name: http
43 | containerPort: 8123
44 | - name: client
45 | containerPort: 9000
46 | - name: interserver
47 | containerPort: 9009
48 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/02-incorrect-image-update-03-revert-and-apply.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-image-2"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: update
9 | templates:
10 | podTemplate: clickhouse:19.3.7
11 | layout:
12 | shards:
13 | - replicas:
14 | - port: 9000
15 | - port: 9000
16 | - port: 9000
17 |
18 | templates:
19 | podTemplates:
20 | - name: clickhouse:19.3.7
21 | spec:
22 | containers:
23 | - name: clickhouse-pod
24 | image: yandex/clickhouse-server:19.3.7
25 | ports:
26 | - name: http
27 | containerPort: 8123
28 | - name: client
29 | containerPort: 9000
30 | - name: interserver
31 | containerPort: 9009
32 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/03-incorrect-settings-create.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-set-1"
5 | spec:
6 | configuration:
7 | users:
8 | test/password: qwerty
9 | test/networks/ip:
10 | - "::1"
11 | - "127.0.0.1"
12 | test/profile: test_profile
13 | test/quota: test_quota
14 | test/allow_databases/database:
15 | - "dbname1"
16 | - "dbname2"
17 | - "dbname3"
18 | admin/password_sha256_hex: 8bd66e4932b4968ec111da24d7e42d399a05cb90bf96f587c3fa191c56c401f8
19 | admin/networks/ip: 0.0.0.0/0
20 | admin/profile: default
21 | admin/quota: default
22 | readonly/profile: readonly
23 | readonly/quota: default
24 | support/password: qwerty
25 | support_readonly/profile: readonly
26 | profiles:
27 | test_profile/max_memory_usage: "1000000000"
28 | test_profile/readonly: "1"
29 | readonly/readonly: "1"
30 | quotas:
31 | test_quota/interval/duration: "3600"
32 | settings:
33 | compression/case/method: zstd
34 | clusters:
35 | - name: "standard"
36 | layout:
37 | shardsCount: 1
38 | replicasCount: 1
39 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/04-incorrect-settings-update-01-initial-position.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-set-2"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "standard"
9 | layout:
10 | shardsCount: 1
11 | replicasCount: 1
12 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/04-incorrect-settings-update-02-apply-incorrect-update.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-set-2"
5 | spec:
6 | configuration:
7 | users:
8 | test/password: qwerty
9 | test/networks/ip:
10 | - "::1"
11 | - "127.0.0.1"
12 | test/profile: test_profile
13 | test/quota: test_quota
14 | test/allow_databases/database:
15 | - "dbname1"
16 | - "dbname2"
17 | - "dbname3"
18 | admin/password_sha256_hex: 8bd66e4932b4968ec111da24d7e42d399a05cb90bf96f587c3fa191c56c401f8
19 | admin/networks/ip: 0.0.0.0/0
20 | admin/profile: default
21 | admin/quota: default
22 | readonly/profile: readonly
23 | readonly/quota: default
24 | profiles:
25 | test_profile/max_memory_usage: "1000000000"
26 | test_profile/readonly: "1"
27 | readonly/readonly: "1"
28 | quotas:
29 | test_quota/interval/duration: "3600"
30 | settings:
31 | compression/case/method: zstd
32 | clusters:
33 | - name: "standard"
34 | layout:
35 | shardsCount: 1
36 | replicasCount: 1
37 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/04-incorrect-settings-update-03-revert-and-apply.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "incorrect-set-2"
5 | spec:
6 | configuration:
7 | users:
8 | test/password: qwerty
9 | test/networks/ip:
10 | - "::/0"
11 | test/profile: test_profile
12 | test/quota: test_quota
13 | test/allow_databases/database:
14 | - "dbname1"
15 | - "dbname2"
16 | - "dbname3"
17 | profiles:
18 | test_profile/max_memory_usage: "1000000000"
19 | test_profile/readonly: "1"
20 | quotas:
21 | test_quota/interval/duration: "3600"
22 | settings:
23 | compression/case/method: zstd
24 | clusters:
25 | - name: "standard"
26 | layout:
27 | shardsCount: 1
28 | replicasCount: 1
29 |
--------------------------------------------------------------------------------
/docs/chi-examples-withstand-errors/05-incorrect-pod-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: "incorrect-pod-1"
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: clickhouse-pod-template
9 | spec:
10 | containers:
11 | - name: clickhouse-pod
12 | image: yandex/clickhouse-server:19.3.4
13 | ports:
14 | - name: http
15 | containerPort: 8123
16 | - name: client
17 | containerPort: 9000
18 | - name: interserver
19 | containerPort: 9009
20 | # Specify extremely limited memory resources
21 | # ClickHouse would be killed by OOM and Pod passes through 'OOMKilled' state into 'CrashLoopBackOff'
22 | resources:
23 | requests:
24 | memory: 32Mi
25 | limits:
26 | memory: 32Mi
27 | configuration:
28 | clusters:
29 | - name: incorrect-pod
30 | layout:
31 | shardsCount: 3
32 | replicasCount: 1
33 | templates:
34 | podTemplate: clickhouse-pod-template
35 |
--------------------------------------------------------------------------------
/docs/chi-examples/01-simple-layout-01-1shard-1repl.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "simple-01"
5 | # labels:
6 | # l1: v1
7 | # l2: v2
8 |
9 |
--------------------------------------------------------------------------------
/docs/chi-examples/01-simple-layout-02-1shard-2repl.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "simple-02"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "shard1-repl1"
9 | layout:
10 | shardsCount: 1
11 | replicasCount: 2
12 |
--------------------------------------------------------------------------------
/docs/chi-examples/01-simple-layout-03-multiple-clusters.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "simple-03"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "replicas"
9 | layout:
10 | shardsCount: 3
11 | replicasCount: 2
12 | - name: "shards"
13 | layout:
14 | shardsCount: 2
15 | - name: "shards-replicas"
16 | layout:
17 | replicasCount: 2
18 |
--------------------------------------------------------------------------------
/docs/chi-examples/02-templates-01-pod-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "template-pod"
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: pod-template
9 | configuration:
10 | settings:
11 | http_port: 8124
12 | tcp_port: 9001
13 | interserver_http_port: 9010
14 | templates:
15 | podTemplates:
16 | - name: pod-template
17 | metadata:
18 | labels:
19 | custom.label: "label.value"
20 | annotations:
21 | custom.annotation: "annotation.value"
22 | spec:
23 | containers:
24 | - name: clickhouse
25 | image: yandex/clickhouse-server:20.7
26 | ports:
27 | - name: http
28 | containerPort: 8124
29 | - name: tcp
30 | containerPort: 9001
31 | - name: interserver
32 | containerPort: 9010
33 |
--------------------------------------------------------------------------------
/docs/chi-examples/02-templates-02-volume-claim-template-assume-default.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "template-override"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "c1"
9 | templates:
10 | volumeClaimTemplates:
11 | - name: default-volumeclaim-template
12 | spec:
13 | resources:
14 | requests:
15 | storage: 4Gi
16 |
--------------------------------------------------------------------------------
/docs/chi-examples/02-templates-03-service-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "template-service"
5 | spec:
6 | defaults:
7 | templates:
8 | serviceTemplate: svc-template
9 | configuration:
10 | settings:
11 | http_port: 8124
12 | tcp_port: 9001
13 | interserver_http_port: 9010
14 | templates:
15 | serviceTemplates:
16 | - name: svc-template
17 | generateName: chendpoint-{chi}
18 | metadata:
19 | labels:
20 | custom.label: "custom.value"
21 | annotations:
22 | cloud.google.com/load-balancer-type: "Internal"
23 | service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
24 | service.beta.kubernetes.io/azure-load-balancer-internal: "true"
25 | service.beta.kubernetes.io/openstack-internal-load-balancer: "true"
26 | service.beta.kubernetes.io/cce-load-balancer-internal-vpc: "true"
27 | spec:
28 | ports:
29 | - name: http
30 | port: 8123
31 | - name: tcp
32 | port: 9000
33 | type: LoadBalancer
34 |
--------------------------------------------------------------------------------
/docs/chi-examples/02-templates-05-useTemplates-multiple.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Check docs/config-examples/templates/
3 | #
4 | apiVersion: "clickhouse.radondb.com/v1"
5 | kind: "ClickHouseInstallation"
6 | metadata:
7 | name: "use-templates-all"
8 | spec:
9 | useTemplates:
10 | - name: "101-default-data-volumeclaimtemplate"
11 | - name: "102-default-log-volumeclaimtemplate"
12 | - name: "103-default-pod-template"
13 | - name: "104-default-pod-template"
14 | - name: "105-default-templates"
15 | configuration:
16 | clusters:
17 | - name: "c1"
18 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-01-default-volume.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "pv-simple"
5 | spec:
6 | defaults:
7 | templates:
8 | dataVolumeClaimTemplate: data-volume-template
9 | logVolumeClaimTemplate: log-volume-template
10 | configuration:
11 | clusters:
12 | - name: "simple"
13 | layout:
14 | shardsCount: 1
15 | replicasCount: 1
16 | templates:
17 | volumeClaimTemplates:
18 | - name: data-volume-template
19 | spec:
20 | accessModes:
21 | - ReadWriteOnce
22 | resources:
23 | requests:
24 | storage: 1Gi
25 | - name: log-volume-template
26 | spec:
27 | accessModes:
28 | - ReadWriteOnce
29 | resources:
30 | requests:
31 | storage: 100Mi
32 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-02-pod-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "pv-log"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "deployment-pv"
9 | # Templates are specified for this cluster explicitly
10 | templates:
11 | podTemplate: pod-template-with-volumes
12 | layout:
13 | shardsCount: 2
14 | replicasCount: 2
15 |
16 | templates:
17 | podTemplates:
18 | - name: pod-template-with-volumes
19 | spec:
20 | containers:
21 | - name: clickhouse
22 | image: yandex/clickhouse-server:20.7
23 | volumeMounts:
24 | - name: data-storage-vc-template
25 | mountPath: /var/lib/clickhouse
26 | - name: log-storage-vc-template
27 | mountPath: /var/log/clickhouse-server
28 |
29 | volumeClaimTemplates:
30 | - name: data-storage-vc-template
31 | spec:
32 | accessModes:
33 | - ReadWriteOnce
34 | resources:
35 | requests:
36 | storage: 3Gi
37 | - name: log-storage-vc-template
38 | spec:
39 | accessModes:
40 | - ReadWriteOnce
41 | resources:
42 | requests:
43 | storage: 2Gi
44 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-04-encrypted-volume.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # AWS encrypted disk example
3 | #
4 | apiVersion: storage.k8s.io/v1
5 | kind: StorageClass
6 | metadata:
7 | name: gp2-encrypted
8 | provisioner: kubernetes.io/aws-ebs
9 | parameters:
10 | encrypted: 'true'
11 | fsType: ext4
12 | type: gp2
13 | reclaimPolicy: Delete
14 | volumeBindingMode: WaitForFirstConsumer
15 | allowVolumeExpansion: true
16 |
17 | ---
18 | apiVersion: "clickhouse.radondb.com/v1"
19 | kind: "ClickHouseInstallation"
20 | metadata:
21 | name: "pv-enc"
22 | spec:
23 | defaults:
24 | templates:
25 | dataVolumeClaimTemplate: data-volumeclaim-template
26 | configuration:
27 | clusters:
28 | - name: "pv-enc"
29 | layout:
30 | shardsCount: 1
31 | replicasCount: 1
32 | templates:
33 | volumeClaimTemplates:
34 | - name: data-volumeclaim-template
35 | spec:
36 | storageClassName: gp2-encrypted
37 | accessModes:
38 | - ReadWriteOnce
39 | resources:
40 | requests:
41 | storage: 3Gi
42 |
43 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-05-resizeable-volume-1.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # AWS resizable disk example
3 | #
4 | apiVersion: storage.k8s.io/v1
5 | kind: StorageClass
6 | metadata:
7 | name: gp2-resizable
8 | provisioner: kubernetes.io/aws-ebs
9 | parameters:
10 | type: gp2
11 | reclaimPolicy: Delete
12 | #volumeBindingMode: Immediate
13 | allowVolumeExpansion: true
14 | ---
15 | apiVersion: "clickhouse.radondb.com/v1"
16 | kind: "ClickHouseInstallation"
17 | metadata:
18 | name: "pv-resize"
19 | spec:
20 | defaults:
21 | templates:
22 | dataVolumeClaimTemplate: data-volumeclaim-template
23 | configuration:
24 | clusters:
25 | - name: "pv-resize"
26 | layout:
27 | shardsCount: 1
28 | replicasCount: 1
29 | templates:
30 | volumeClaimTemplates:
31 | - name: data-volumeclaim-template
32 | spec:
33 | storageClassName: gp2-resizable
34 | accessModes:
35 | - ReadWriteOnce
36 | resources:
37 | requests:
38 | storage: 3Gi
39 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-05-resizeable-volume-2.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # AWS resizable disk example
3 | #
4 | apiVersion: storage.k8s.io/v1
5 | kind: StorageClass
6 | metadata:
7 | name: gp2-resizable
8 | provisioner: kubernetes.io/aws-ebs
9 | parameters:
10 | type: gp2
11 | reclaimPolicy: Delete
12 | #volumeBindingMode: Immediate
13 | allowVolumeExpansion: true
14 | ---
15 | apiVersion: "clickhouse.radondb.com/v1"
16 | kind: "ClickHouseInstallation"
17 | metadata:
18 | name: "pv-resize"
19 | spec:
20 | defaults:
21 | templates:
22 | dataVolumeClaimTemplate: data-volumeclaim-template
23 | configuration:
24 | clusters:
25 | - name: "pv-resize"
26 | layout:
27 | shardsCount: 1
28 | replicasCount: 1
29 | templates:
30 | volumeClaimTemplates:
31 | - name: data-volumeclaim-template
32 | spec:
33 | storageClassName: gp2-resizable
34 | accessModes:
35 | - ReadWriteOnce
36 | resources:
37 | requests:
38 | storage: 50Gi
39 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-06-add-log-volume-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "pv-add-log"
5 | spec:
6 | defaults:
7 | templates:
8 | dataVolumeClaimTemplate: data-volume-template
9 | configuration:
10 | clusters:
11 | - name: "pv-add-log"
12 | layout:
13 | shardsCount: 1
14 | replicasCount: 1
15 | templates:
16 | volumeClaimTemplates:
17 | - name: data-volume-template
18 | spec:
19 | accessModes:
20 | - ReadWriteOnce
21 | resources:
22 | requests:
23 | storage: 1Gi
24 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-06-add-log-volume-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "pv-add-log"
5 | spec:
6 | defaults:
7 | templates:
8 | dataVolumeClaimTemplate: data-volume-template
9 | logVolumeClaimTemplate: log-volume-template
10 | configuration:
11 | clusters:
12 | - name: "pv-add-log"
13 | layout:
14 | shardsCount: 1
15 | replicasCount: 1
16 | templates:
17 | volumeClaimTemplates:
18 | - name: data-volume-template
19 | spec:
20 | accessModes:
21 | - ReadWriteOnce
22 | resources:
23 | requests:
24 | storage: 1Gi
25 | - name: log-volume-template
26 | spec:
27 | accessModes:
28 | - ReadWriteOnce
29 | resources:
30 | requests:
31 | storage: 3Gi
32 |
--------------------------------------------------------------------------------
/docs/chi-examples/03-persistent-volume-07-multiple-resizable-volumes-1.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # AWS resizable disk example
3 | #
4 | apiVersion: storage.k8s.io/v1
5 | kind: StorageClass
6 | metadata:
7 | name: gp2-resizable
8 | provisioner: kubernetes.io/aws-ebs
9 | parameters:
10 | type: gp2
11 | reclaimPolicy: Delete
12 | #volumeBindingMode: Immediate
13 | allowVolumeExpansion: true
14 | ---
15 | apiVersion: "clickhouse.radondb.com/v1"
16 | kind: "ClickHouseInstallation"
17 | metadata:
18 | name: "pv-multi-resize"
19 | spec:
20 | configuration:
21 | clusters:
22 | - name: "pv-multi-resize"
23 | templates:
24 | podTemplate: pod-template-with-volumes
25 | layout:
26 | shardsCount: 1
27 | replicasCount: 1
28 |
29 | templates:
30 | podTemplates:
31 | - name: pod-template-with-volumes
32 | spec:
33 | containers:
34 | - name: clickhouse
35 | image: yandex/clickhouse-server:20.7
36 | volumeMounts:
37 | - name: data-storage-vc-template-1
38 | mountPath: /data/clickhouse-01
39 |
40 | volumeClaimTemplates:
41 | - name: data-storage-vc-template-1
42 | spec:
43 | storageClassName: gp2-resizable
44 | accessModes:
45 | - ReadWriteOnce
46 | resources:
47 | requests:
48 | storage: 1Gi
49 |
--------------------------------------------------------------------------------
/docs/chi-examples/04-replication-zookeeper-01-minimal.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "repl-01"
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | clusters:
11 | - name: replcluster
12 | layout:
13 | shardsCount: 3
14 | replicasCount: 2
15 |
--------------------------------------------------------------------------------
/docs/chi-examples/04-replication-zookeeper-02-detailed.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "repl-02"
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper-0.zookeepers.zoo3ns
10 | port: 2181
11 | - host: zookeeper-1.zookeepers.zoo3ns
12 | port: 2181
13 | - host: zookeeper-2.zookeepers.zoo3ns
14 | port: 2181
15 | session_timeout_ms: 30000
16 | operation_timeout_ms: 10000
17 | root: /path/to/zookeeper/node
18 | identity: user:password
19 | clusters:
20 | - name: replcluster
21 | layout:
22 | shardsCount: 3
23 | replicasCount: 2
24 |
--------------------------------------------------------------------------------
/docs/chi-examples/04-replication-zookeeper-03-minimal-AWS-persistent-volume.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "repl-03"
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | port: 2181
11 | clusters:
12 | - name: replcluster
13 | templates:
14 | podTemplate: clickhouse-with-volume-template
15 | layout:
16 | shardsCount: 1
17 | replicasCount: 2
18 | templates:
19 | podTemplates:
20 | - name: clickhouse-with-volume-template
21 | spec:
22 | containers:
23 | - name: clickhouse-pod
24 | image: yandex/clickhouse-server:20.7
25 | volumeMounts:
26 | - name: clickhouse-storage-template
27 | mountPath: /var/lib/clickhouse
28 | volumeClaimTemplates:
29 | - name: clickhouse-storage-template
30 | spec:
31 | # no storageClassName - means use default storageClassName
32 | #storageClassName: default
33 | accessModes:
34 | - ReadWriteOnce
35 | resources:
36 | requests:
37 | storage: 50Gi
38 |
--------------------------------------------------------------------------------
/docs/chi-examples/04-replication-zookeeper-04-medium-AWS-persistent-volume.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "repl-04"
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper-0.zookeepers.zoo3ns
10 | port: 2181
11 | - host: zookeeper-1.zookeepers.zoo3ns
12 | port: 2181
13 | - host: zookeeper-2.zookeepers.zoo3ns
14 | port: 2181
15 | clusters:
16 | - name: replcluster
17 | templates:
18 | podTemplate: clickhouse-with-volume-template
19 | layout:
20 | shardsCount: 3
21 | replicasCount: 2
22 | templates:
23 | podTemplates:
24 | - name: clickhouse-with-volume-template
25 | spec:
26 | containers:
27 | - name: clickhouse-pod
28 | image: yandex/clickhouse-server:20.7
29 | volumeMounts:
30 | - name: clickhouse-storage-template
31 | mountPath: /var/lib/clickhouse
32 | volumeClaimTemplates:
33 | - name: clickhouse-storage-template
34 | spec:
35 | # no storageClassName - means use default storageClassName
36 | #storageClassName: default
37 | accessModes:
38 | - ReadWriteOnce
39 | resources:
40 | requests:
41 | storage: 900Mi
42 |
--------------------------------------------------------------------------------
/docs/chi-examples/04-replication-zookeeper-05-simple-PV.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 |
4 | metadata:
5 | name: "repl-05"
6 |
7 | spec:
8 | defaults:
9 | templates:
10 | dataVolumeClaimTemplate: default
11 | podTemplate: clickhouse:19.6
12 |
13 | configuration:
14 | zookeeper:
15 | nodes:
16 | - host: zookeeper.zoo1ns
17 | clusters:
18 | - name: replicated
19 | layout:
20 | shardsCount: 2
21 | replicasCount: 2
22 |
23 | templates:
24 | volumeClaimTemplates:
25 | - name: default
26 | spec:
27 | accessModes:
28 | - ReadWriteOnce
29 | resources:
30 | requests:
31 | storage: 500Mi
32 | podTemplates:
33 | - name: clickhouse:19.6
34 | spec:
35 | containers:
36 | - name: clickhouse-pod
37 | image: yandex/clickhouse-server:20.7
38 |
--------------------------------------------------------------------------------
/docs/chi-examples/04-replication-zookeeper-06-on-cluster.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 |
4 | metadata:
5 | name: "repl-06"
6 |
7 | spec:
8 | configuration:
9 | zookeeper:
10 | nodes:
11 | - host: zookeeper-0.zookeepers.zoo1ns
12 | clusters:
13 | - name: replcluster1
14 | layout:
15 | replicasCount: 2
16 | - name: replcluster2
17 | zookeeper:
18 | nodes:
19 | - host: zookeeper-0.zookeepers.zoo3ns
20 | - host: zookeeper-1.zookeepers.zoo3ns
21 | - host: zookeeper-2.zookeepers.zoo3ns
22 | layout:
23 | replicasCount: 2
24 |
--------------------------------------------------------------------------------
/docs/chi-examples/05-settings-02-dictionary.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 |
4 | metadata:
5 | name: "settings-02"
6 |
7 | spec:
8 | configuration:
9 | settings:
10 | dictionaries_config: config.d/*.dict
11 | files:
12 | dict_one.dict: |
13 |
14 |
15 | one
16 |
17 |
18 | localhost
19 | 9000
20 | default
21 |
22 | system
23 |
24 |
25 |
26 | 60
27 |
28 |
29 |
30 | dummy
31 |
32 |
33 | one
34 | dummy
35 | UInt8
36 | 0
37 |
38 |
39 |
40 |
41 | clusters:
42 | - name: standard
43 | layout:
44 | shardsCount: 1
--------------------------------------------------------------------------------
/docs/chi-examples/05-settings-03-1-initial-position.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: "settings-03"
5 | spec:
6 | configuration:
7 | users:
8 | user1/networks/ip: "::/0"
9 | user1/password: qwerty
10 | user1/profile: default
11 | # user2/networks/ip: "::/0"
12 | # user2/password: qwerty
13 | # user2/profile: default
14 | clusters:
15 | - name: cls1
16 | layout:
17 | shardsCount: 1
18 | replicasCount: 1
19 |
20 |
--------------------------------------------------------------------------------
/docs/chi-examples/05-settings-03-2-user2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: "settings-03"
5 | spec:
6 | configuration:
7 | users:
8 | # user1/networks/ip: "::/0"
9 | # user1/password: qwerty
10 | # user1/profile: default
11 | user2/networks/ip: "::/0"
12 | user2/password: qwerty
13 | user2/profile: default
14 | clusters:
15 | - name: cls1
16 | layout:
17 | shardsCount: 1
18 | replicasCount: 1
19 |
20 |
--------------------------------------------------------------------------------
/docs/chi-examples/05-settings-06-tilde.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "settings-tilde"
5 | spec:
6 | configuration:
7 | users:
8 | # test user has 'password' specified, while admin user has 'password_sha256_hex' specified
9 | test/password: qwerty
10 | test/networks/ip:
11 | - "127.0.0.1/32"
12 | - "192.168.74.1/24"
13 | - ~
14 | clusters:
15 | - name: "standard"
16 | layout:
17 | shardsCount: 1
18 | replicasCount: 1
19 |
--------------------------------------------------------------------------------
/docs/chi-examples/06-advanced-layout-01-shards.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "adv-layout-shard"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: adv
9 | layout:
10 | shards:
11 | - replicas:
12 | - templates:
13 | podTemplate: clickhouse:20.5
14 | httpPort: 8000
15 | tcpPort: 8001
16 | interserverHTTPPort: 8002
17 | - templates:
18 | podTemplate: clickhouse:20.6
19 | httpPort: 9000
20 | tcpPort: 9001
21 | interserverHTTPPort: 9002
22 | - templates:
23 | podTemplate: clickhouse:20.7
24 | httpPort: 10000
25 | tcpPort: 10001
26 | interserverHTTPPort: 10002
27 |
28 | templates:
29 | podTemplates:
30 |
31 | - name: clickhouse:20.5
32 | spec:
33 | containers:
34 | - name: clickhouse-pod
35 | image: yandex/clickhouse-server:20.5
36 |
37 | - name: clickhouse:20.6
38 | spec:
39 | containers:
40 | - name: clickhouse-pod
41 | image: yandex/clickhouse-server:20.6
42 |
43 |
44 | - name: clickhouse:20.7
45 | spec:
46 | containers:
47 | - name: clickhouse-pod
48 | image: yandex/clickhouse-server:20.7
49 |
--------------------------------------------------------------------------------
/docs/chi-examples/06-advanced-layout-02-replicas.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "adv-layout-repl"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: adv
9 | layout:
10 | shardsCount: 4
11 | replicas:
12 | - templates:
13 | podTemplate: clickhouse:20.5
14 | httpPort: 8000
15 | tcpPort: 8001
16 | interserverHTTPPort: 8002
17 | - templates:
18 | podTemplate: clickhouse:20.6
19 | httpPort: 9000
20 | tcpPort: 9001
21 | interserverHTTPPort: 9002
22 | - templates:
23 | podTemplate: clickhouse:20.7
24 | httpPort: 10000
25 | tcpPort: 10001
26 | interserverHTTPPort: 10002
27 |
28 | templates:
29 | podTemplates:
30 |
31 | - name: clickhouse:20.5
32 | spec:
33 | containers:
34 | - name: clickhouse-pod
35 | image: yandex/clickhouse-server:20.5
36 |
37 | - name: clickhouse:20.6
38 | spec:
39 | containers:
40 | - name: clickhouse-pod
41 | image: yandex/clickhouse-server:20.6
42 |
43 |
44 | - name: clickhouse:20.7
45 | spec:
46 | containers:
47 | - name: clickhouse-pod
48 | image: yandex/clickhouse-server:20.7
49 |
--------------------------------------------------------------------------------
/docs/chi-examples/07-rolling-update-stateless-01-initial-position.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "update-01"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "sharded"
9 | layout:
10 | shardsCount: 4
11 |
--------------------------------------------------------------------------------
/docs/chi-examples/07-rolling-update-stateless-02-apply-update.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "update-01"
5 | spec:
6 | configuration:
7 | zookeeper: # Add Zookeeper
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | clusters:
11 | - name: "sharded"
12 | layout:
13 | shardsCount: 4
14 | replicasCount: 2 # Enable replication
15 |
--------------------------------------------------------------------------------
/docs/chi-examples/08-clickhouse-version-update-01-initial-position.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "version-update"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: update
9 | templates:
10 | podTemplate: clickhouse:20.6
11 | layout:
12 | shards:
13 | - replicas:
14 | - tcpPort: 9000
15 | - tcpPort: 9000
16 | - tcpPort: 9000
17 |
18 | templates:
19 | podTemplates:
20 | - name: clickhouse:20.6
21 | spec:
22 | containers:
23 | - name: clickhouse-pod
24 | image: yandex/clickhouse-server:20.6
25 |
--------------------------------------------------------------------------------
/docs/chi-examples/08-clickhouse-version-update-02-apply-update-one.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "version-update"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: update
9 | templates:
10 | podTemplate: clickhouse:20.6
11 | layout:
12 | shards:
13 | - replicas:
14 | - tcpPort: 9000
15 | - tcpPort: 9000
16 | - tcpPort: 9000
17 | templates:
18 | podTemplate: clickhouse:20.7
19 |
20 | templates:
21 | podTemplates:
22 | - name: clickhouse:20.6
23 | spec:
24 | containers:
25 | - name: clickhouse-pod
26 | image: yandex/clickhouse-server:20.6
27 |
28 | - name: clickhouse:20.7
29 | spec:
30 | containers:
31 | - name: clickhouse-pod
32 | image: yandex/clickhouse-server:20.7
33 |
--------------------------------------------------------------------------------
/docs/chi-examples/08-clickhouse-version-update-03-apply-update-all.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "version-update"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: update
9 | templates:
10 | podTemplate: clickhouse:20.7
11 | layout:
12 | shards:
13 | - replicas:
14 | - tcpPort: 9000
15 | - tcpPort: 9000
16 | - tcpPort: 9000
17 |
18 | templates:
19 | podTemplates:
20 | - name: clickhouse:20.7
21 | spec:
22 | containers:
23 | - name: clickhouse-pod
24 | image: yandex/clickhouse-server:20.7
25 |
--------------------------------------------------------------------------------
/docs/chi-examples/09-rolling-update-emptydir-01-initial-position.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "update-emptydir"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "sharded"
9 | templates:
10 | podTemplate: clickhouse-with-empty-dir-volume-template
11 | layout:
12 | shardsCount: 2
13 | templates:
14 | podTemplates:
15 | - name: clickhouse-with-empty-dir-volume-template
16 | spec:
17 | containers:
18 | - name: clickhouse-pod
19 | image: yandex/clickhouse-server:20.7
20 | volumeMounts:
21 | - name: clickhouse-storage
22 | mountPath: /var/lib/clickhouse
23 | volumes:
24 | - name: clickhouse-storage
25 | emptyDir:
26 | medium: "" # accepted values: empty str (means node's default medium) or "Memory"
27 | sizeLimit: 1Gi
28 |
--------------------------------------------------------------------------------
/docs/chi-examples/09-rolling-update-emptydir-02-apply-update.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "update-emptydir"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "sharded"
9 | templates:
10 | podTemplate: clickhouse-with-empty-dir-volume-template
11 | layout:
12 | shardsCount: 4
13 | templates:
14 | podTemplates:
15 | - name: clickhouse-with-empty-dir-volume-template
16 | spec:
17 | containers:
18 | - name: clickhouse-pod
19 | image: yandex/clickhouse-server:20.7
20 | volumeMounts:
21 | - name: clickhouse-storage
22 | mountPath: /var/lib/clickhouse
23 | volumes:
24 | - name: clickhouse-storage
25 | emptyDir:
26 | medium: "" # accepted values: empty str (means node's default medium) or "Memory"
27 | sizeLimit: 1Gi
28 |
--------------------------------------------------------------------------------
/docs/chi-examples/10-zones-01-simple-02-aws-pod-per-host.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # AWS-specific labels, applicable in 'nodeAffinity' statements
3 | #
4 | # beta.kubernetes.io/arch=amd64
5 | # beta.kubernetes.io/instance-type=t2.medium
6 | # beta.kubernetes.io/os=linux
7 | #
8 | # failure-domain.beta.kubernetes.io/region=us-east-1
9 | # failure-domain.beta.kubernetes.io/zone=us-east-1a
10 | #
11 | # kubernetes.io/hostname=ip-172-20-37-97.ec2.internal
12 | # kubernetes.io/role=node
13 | # node-role.kubernetes.io/node=
14 | #
15 | # kops.k8s.io/instancegroup=nodes2
16 | #
17 | apiVersion: "clickhouse.radondb.com/v1"
18 | kind: "ClickHouseInstallation"
19 | metadata:
20 | name: "zones-pod-host"
21 | spec:
22 | defaults:
23 | templates:
24 | podTemplate: clickhouse-per-host-in-zone-us-east-1a
25 | configuration:
26 | clusters:
27 | - name: zoned-cluster
28 | layout:
29 | shardsCount: 3
30 |
31 | templates:
32 | podTemplates:
33 | # Specify Pod Templates with affinity
34 | - name: clickhouse-per-host-in-zone-us-east-1a
35 | zone:
36 | values:
37 | - "us-east-1a"
38 | podDistribution:
39 | - type: "ClickHouseAntiAffinity"
40 | spec:
41 | containers:
42 | - name: clickhouse-pod
43 | image: yandex/clickhouse-server:20.7
44 |
--------------------------------------------------------------------------------
/docs/chi-examples/12-troubleshooting-01.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "troubleshoot-01"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: "t1"
9 | templates:
10 | podTemplate: pod-template
11 | layout:
12 | shardsCount: 1
13 | replicasCount: 1
14 |
15 | templates:
16 | podTemplates:
17 | - name: pod-template
18 | spec:
19 | containers:
20 | - name: clickhouse
21 | image: yandex/clickhouse-server:20.7
22 | command:
23 | - "/bin/bash"
24 | - "-c"
25 | - "/entrypoint.sh; while true; do sleep 3600; done"
26 |
--------------------------------------------------------------------------------
/docs/chi-examples/13-distribution-01-distribution-scope.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "ch1"
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: default
9 | templates:
10 | podTemplates:
11 | - name: default
12 | podDistribution:
13 | - type: ClickHouseAntiAffinity
14 | scope: ClickHouseInstallation
15 | configuration:
16 | clusters:
17 | - name: "c1"
18 | layout:
19 | shardsCount: 3
20 | ---
21 | apiVersion: "clickhouse.radondb.com/v1"
22 | kind: "ClickHouseInstallation"
23 | metadata:
24 | name: "ch2"
25 | spec:
26 | defaults:
27 | templates:
28 | podTemplate: default
29 | templates:
30 | podTemplates:
31 | - name: default
32 | podDistribution:
33 | - type: ClickHouseAntiAffinity
34 | scope: ClickHouseInstallation
35 | configuration:
36 | clusters:
37 | - name: "c1"
38 | layout:
39 | shardsCount: 3
40 |
--------------------------------------------------------------------------------
/docs/chi-examples/13-distribution-02-3x3-circular-replication.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "dist-simple-a"
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: dist-template
9 | configuration:
10 | clusters:
11 | - name: "dc1"
12 | layout:
13 | shardsCount: 3
14 | replicasCount: 3
15 | templates:
16 | podTemplates:
17 | - name: dist-template
18 | podDistribution:
19 | - type: CircularReplication
20 | spec:
21 | containers:
22 | - name: clickhouse
23 | image: yandex/clickhouse-server:20.7
24 | ---
25 | apiVersion: "clickhouse.radondb.com/v1"
26 | kind: "ClickHouseInstallation"
27 | metadata:
28 | name: "dist-simple-b"
29 | spec:
30 | defaults:
31 | templates:
32 | podTemplate: dist-template
33 | configuration:
34 | clusters:
35 | - name: "dc1"
36 | layout:
37 | shardsCount: 3
38 | replicasCount: 3
39 | templates:
40 | podTemplates:
41 | - name: dist-template
42 | podDistribution:
43 | - type: CircularReplication
44 | spec:
45 | containers:
46 | - name: clickhouse
47 | image: yandex/clickhouse-server:20.7
48 |
--------------------------------------------------------------------------------
/docs/chi-examples/13-distribution-03-3x3-distribution-detailed.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "dist_exp"
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: dist-template
9 | configuration:
10 | clusters:
11 | - name: "dist_exp"
12 | layout:
13 | shardsCount: 3
14 | replicasCount: 3
15 | templates:
16 | podTemplates:
17 | - name: dist-template
18 | podDistribution:
19 | - type: ShardAntiAffinity
20 | - type: ReplicaAntiAffinity
21 | - type: MaxNumberPerNode
22 | number: 3
23 | - type: NamespaceAffinity
24 | - type: ClickHouseInstallationAffinity
25 | - type: ClusterAffinity
26 | - type: PreviousTailAffinity
27 | spec:
28 | containers:
29 | - name: clickhouse
30 | image: yandex/clickhouse-server:20.7
31 |
--------------------------------------------------------------------------------
/docs/chi-examples/15-hostNetwork-01-simple.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "hostnet1"
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: pod-distribution
9 |
10 | configuration:
11 | clusters:
12 | - name: "hnet1"
13 | layout:
14 | shardsCount: 2
15 | replicasCount: 3
16 |
17 | templates:
18 | podTemplates:
19 | - name: pod-distribution
20 | podDistribution:
21 | - type: CircularReplication
22 | spec:
23 | hostNetwork: true
24 | dnsPolicy: ClusterFirstWithHostNet
25 | containers:
26 | - name: clickhouse
27 | image: yandex/clickhouse-server:20.7
28 |
--------------------------------------------------------------------------------
/docs/chi-examples/15-hostNetwork-02-simple-port-distribution.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "hostnet2"
5 | spec:
6 | defaults:
7 | templates:
8 | hostTemplate: port-distribution
9 | podTemplate: pod-distribution
10 |
11 | configuration:
12 | clusters:
13 | - name: "hnet2"
14 | layout:
15 | shardsCount: 3
16 | replicasCount: 3
17 |
18 | templates:
19 | hostTemplates:
20 | - name: port-distribution
21 | portDistribution:
22 | - type: ClusterScopeIndex
23 | spec:
24 | tcpPort: 10000
25 | httpPort: 11000
26 | interserverHTTPPort: 12000
27 |
28 | podTemplates:
29 | - name: pod-distribution
30 | podDistribution:
31 | - type: CircularReplication
32 | spec:
33 | hostNetwork: true
34 | dnsPolicy: ClusterFirstWithHostNet
35 | containers:
36 | - name: clickhouse
37 | image: yandex/clickhouse-server:20.7
38 |
--------------------------------------------------------------------------------
/docs/chi-examples/15-hostNetwork-03-expanded-port-distribution.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "hostnet3"
5 | spec:
6 | defaults:
7 | templates:
8 | hostTemplate: port-distribution
9 | podTemplate: pod-distribution
10 |
11 | configuration:
12 | clusters:
13 | - name: "hnet3"
14 | layout:
15 | shardsCount: 3
16 | replicasCount: 3
17 |
18 | templates:
19 | hostTemplates:
20 | - name: port-distribution
21 | portDistribution:
22 | - type: ClusterScopeIndex
23 | spec:
24 | tcpPort: 10000
25 | httpPort: 11000
26 | interserverHTTPPort: 12000
27 |
28 | podTemplates:
29 | - name: pod-distribution
30 | podDistribution:
31 | - type: ShardAntiAffinity
32 | - type: ReplicaAntiAffinity
33 | - type: MaxNumberPerNode
34 | number: 3
35 | - type: NamespaceAffinity
36 | - type: ClickHouseInstallationAffinity
37 | - type: ClusterAffinity
38 | - type: PreviousTailAffinity
39 | spec:
40 | hostNetwork: true
41 | dnsPolicy: ClusterFirstWithHostNet
42 | containers:
43 | - name: clickhouse
44 | image: yandex/clickhouse-server:20.7
45 |
--------------------------------------------------------------------------------
/docs/chi-examples/15-hostNetwork-04-simple-fixed-replicas.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "hostnet4"
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: pod-distribution
9 |
10 | configuration:
11 | users:
12 | default/networks/ip:
13 | - "::/0"
14 | clusters:
15 | - name: "hnet4"
16 | layout:
17 | shardsCount: 3
18 | replicas:
19 | - templates:
20 | hostTemplate: replica-0
21 | - templates:
22 | hostTemplate: replica-1
23 | - templates:
24 | hostTemplate: replica-2
25 |
26 | templates:
27 | hostTemplates:
28 | - name: replica-0
29 | spec:
30 | tcpPort: 9000
31 | httpPort: 8123
32 | interserverHTTPPort: 9009
33 | - name: replica-1
34 | spec:
35 | tcpPort: 9001
36 | httpPort: 8124
37 | interserverHTTPPort: 9010
38 | - name: replica-2
39 | spec:
40 | tcpPort: 9002
41 | httpPort: 8125
42 | interserverHTTPPort: 9011
43 |
44 | podTemplates:
45 | - name: pod-distribution
46 | podDistribution:
47 | - type: CircularReplication
48 | spec:
49 | hostNetwork: true
50 | dnsPolicy: ClusterFirstWithHostNet
51 | containers:
52 | - name: clickhouse
53 | image: yandex/clickhouse-server:20.7
54 |
--------------------------------------------------------------------------------
/docs/chi-examples/16-custom-labels-and-annotations-01.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "labels-annot"
5 | labels:
6 | label1: label1_value
7 | label2: label2_value
8 | annotations:
9 | annotation1: annotation1_value
10 | annotation2: annotation2_value
11 | spec:
12 | configuration:
13 | clusters:
14 | - name: "cluster"
15 | layout:
16 | shardsCount: 1
17 | replicasCount: 2
18 |
--------------------------------------------------------------------------------
/docs/chi-examples/17-monitoring-cluster-01.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "monitoring-demo"
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | port: 2181
11 | clusters:
12 | - name: replcluster
13 | templates:
14 | podTemplate: clickhouse-with-volume-template
15 | layout:
16 | shardsCount: 2
17 | replicasCount: 2
18 | templates:
19 | podTemplates:
20 | - name: clickhouse-with-volume-template
21 | spec:
22 | containers:
23 | - name: clickhouse-pod
24 | image: yandex/clickhouse-server:20.7
25 | volumeMounts:
26 | - name: clickhouse-storage-template
27 | mountPath: /var/lib/clickhouse
28 | volumeClaimTemplates:
29 | - name: clickhouse-storage-template
30 | spec:
31 | accessModes:
32 | - ReadWriteOnce
33 | resources:
34 | requests:
35 | storage: 10Gi
36 |
--------------------------------------------------------------------------------
/docs/chi-examples/18-namespace-domain-pattern.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "namespace-domain-pattern"
5 | spec:
6 | namespaceDomainPattern: "%s.svc"
7 | configuration:
8 | clusters:
9 | - name: "shard1-repl2"
10 | layout:
11 | shardsCount: 1
12 | replicasCount: 2
13 |
--------------------------------------------------------------------------------
/docs/chi-examples/19-pod-generate-name.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "pod-generate-name"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: shard1-repl1
9 | templates:
10 | podTemplate: clickhouse-pod-template
11 | layout:
12 | shardsCount: 1
13 | replicasCount: 1
14 | templates:
15 | podTemplates:
16 | - name: clickhouse-pod-template
17 | generateName: "chi-{chi}-{cluster}-{host}"
18 | spec:
19 | containers:
20 | - name: clickhouse-pod
21 | image: yandex/clickhouse-server:20.7
22 | volumeMounts:
23 | - name: clickhouse-storage-template
24 | mountPath: /var/lib/clickhouse
25 |
--------------------------------------------------------------------------------
/docs/chi-examples/50-chi-template-01.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "simple-template-01"
5 | spec:
6 | defaults:
7 | templates:
8 | dataVolumeClaimTemplate: data-volumeclaim-template
9 | logVolumeClaimTemplate: log-volumeclaim-template
10 | templates:
11 | volumeClaimTemplates:
12 | - name: data-volumeclaim-template
13 | spec:
14 | accessModes:
15 | - ReadWriteOnce
16 | resources:
17 | requests:
18 | storage: 2Gi
19 | - name: log-volumeclaim-template
20 | spec:
21 | accessModes:
22 | - ReadWriteOnce
23 | resources:
24 | requests:
25 | storage: 1Gi
26 | templating:
27 | policy: Auto
28 |
--------------------------------------------------------------------------------
/docs/chi-examples/98-quota-01.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ResourceQuota
3 | metadata:
4 | name: test-quotas
5 | namespace: dev
6 | spec:
7 | hard:
8 | pods: 10
9 | services: 10
10 | replicationcontrollers: 10
11 |
12 |
--------------------------------------------------------------------------------
/docs/chi-examples/evolution/01-persistent-volume.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: evolution
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: cluster
9 | # Templates are specified for this cluster explicitly
10 | templates:
11 | podTemplate: pod-template-with-volume
12 | layout:
13 | shardsCount: 1
14 | replicasCount: 1
15 |
16 | templates:
17 | podTemplates:
18 | - name: pod-template-with-volume
19 | spec:
20 | containers:
21 | - name: clickhouse
22 | image: yandex/clickhouse-server:19.3.7
23 | volumeMounts:
24 | - name: storage-vc-template
25 | mountPath: /var/lib/clickhouse
26 |
27 | volumeClaimTemplates:
28 | - name: storage-vc-template
29 | spec:
30 | accessModes:
31 | - ReadWriteOnce
32 | resources:
33 | requests:
34 | storage: 10Gi
35 |
--------------------------------------------------------------------------------
/docs/chi-examples/evolution/02-introduce-replication.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: evolution
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | clusters:
11 | - name: cluster
12 | # Templates are specified for this cluster explicitly
13 | templates:
14 | podTemplate: pod-template-with-volume
15 | layout:
16 | shardsCount: 1
17 | replicasCount: 2
18 |
19 | templates:
20 | podTemplates:
21 | - name: pod-template-with-volume
22 | spec:
23 | containers:
24 | - name: clickhouse
25 | image: yandex/clickhouse-server:19.3.7
26 | volumeMounts:
27 | - name: storage-vc-template
28 | mountPath: /var/lib/clickhouse
29 |
30 | volumeClaimTemplates:
31 | - name: storage-vc-template
32 | spec:
33 | accessModes:
34 | - ReadWriteOnce
35 | resources:
36 | requests:
37 | storage: 10Gi
38 |
--------------------------------------------------------------------------------
/docs/chi-examples/evolution/03-introduce-more-shards-and-zones.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: evolution
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | clusters:
11 | - name: cluster
12 | # Templates are specified for this cluster explicitly
13 | templates:
14 | podTemplate: pod-template-with-volume
15 | layout:
16 | shardsCount: 2
17 | replicasCount: 2
18 |
19 | templates:
20 | podTemplates:
21 | - name: pod-template-with-volume
22 | zone:
23 | key: "clickhouse"
24 | values:
25 | - "allow"
26 | podDistribution:
27 | - type: ClickHouseAntiAffinity
28 | spec:
29 | containers:
30 | - name: clickhouse
31 | image: yandex/clickhouse-server:19.3.7
32 | volumeMounts:
33 | - name: storage-vc-template
34 | mountPath: /var/lib/clickhouse
35 |
36 | volumeClaimTemplates:
37 | - name: storage-vc-template
38 | spec:
39 | accessModes:
40 | - ReadWriteOnce
41 | resources:
42 | requests:
43 | storage: 10Gi
44 |
--------------------------------------------------------------------------------
/docs/chi-examples/evolution/05-update-propagate-update.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: evolution
5 | spec:
6 | configuration:
7 | zookeeper:
8 | nodes:
9 | - host: zookeeper.zoo1ns
10 | clusters:
11 | - name: cluster
12 | # Templates are specified for this cluster explicitly
13 | templates:
14 | podTemplate: pod-template-with-volume
15 | layout:
16 | shardsCount: 2
17 | replicasCount: 2
18 |
19 | templates:
20 | podTemplates:
21 | - name: pod-template-with-volume
22 | zone:
23 | key: "clickhouse"
24 | values:
25 | - "allow"
26 | podDistribution:
27 | - type: ClickHouseAntiAffinity
28 | spec:
29 | containers:
30 | - name: clickhouse
31 | image: yandex/clickhouse-server:19.4.3.11
32 | volumeMounts:
33 | - name: storage-vc-template
34 | mountPath: /var/lib/clickhouse
35 |
36 | volumeClaimTemplates:
37 | - name: storage-vc-template
38 | spec:
39 | accessModes:
40 | - ReadWriteOnce
41 | resources:
42 | requests:
43 | storage: 10Gi
44 |
--------------------------------------------------------------------------------
/docs/chi-examples/label_nodes.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | LABELS=(\
4 | "clickhouse=allow" \
5 | "CHOP=test" \
6 | )
7 |
8 | # Get all nodes with output header
9 | # Skip master node
10 | # Skip output header
11 | # Extract node names
12 | # Label each node
13 | kubectl get nodes | \
14 | grep -v master | \
15 | tail -n +2 | \
16 | awk '{print $1}' | \
17 | while read -r LINE; do
18 | # Label each node
19 | NODE="${LINE}"
20 | for LABEL in ${LABELS[@]}; do
21 | #kubectl label nodes [--overwrite=true] =
22 | kubectl label nodes "${NODE}" "${LABEL}"
23 | done
24 | done
25 |
--------------------------------------------------------------------------------
/docs/config-examples/templates/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/docs/config-examples/templates/.gitkeep
--------------------------------------------------------------------------------
/docs/config-examples/templates/101-templates.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "101-default-data-volumeclaimtemplate"
5 | spec:
6 | templates:
7 | volumeClaimTemplates:
8 | - name: default-data-volumeclaim-template
9 | spec:
10 | accessModes:
11 | - ReadWriteOnce
12 | resources:
13 | requests:
14 | storage: 3Gi
15 |
--------------------------------------------------------------------------------
/docs/config-examples/templates/102-templates.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "102-default-log-volumeclaimtemplate"
5 | spec:
6 | templates:
7 | volumeClaimTemplates:
8 | - name: default-log-volumeclaim-template
9 | spec:
10 | accessModes:
11 | - ReadWriteOnce
12 | resources:
13 | requests:
14 | storage: 2Gi
15 |
--------------------------------------------------------------------------------
/docs/config-examples/templates/103-templates.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "103-default-pod-template"
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: default-pod-template
9 | spec:
10 | containers:
11 | - name: clickhouse-pod
12 | image: yandex/clickhouse-server:19.3.7
13 | ports:
14 | - name: http
15 | containerPort: 8123
16 | - name: client
17 | containerPort: 9000
18 | - name: interserver
19 | containerPort: 9009
20 |
--------------------------------------------------------------------------------
/docs/config-examples/templates/104-templates.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "104-default-pod-template"
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: default-pod-template
9 | distribution: "OnePerHost"
10 |
--------------------------------------------------------------------------------
/docs/config-examples/templates/105-templates.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "105-default-templates"
5 | spec:
6 | defaults:
7 | templates:
8 | dataVolumeClaimTemplate: default-data-volumeclaim-template
9 | logVolumeClaimTemplate: default-log-volumeclaim-template
10 | podTemplate: default-pod-template
11 |
--------------------------------------------------------------------------------
/docs/k8s_cluster_access.md:
--------------------------------------------------------------------------------
1 | # Task: get access to Kubernetes cluster
2 |
3 | ## Access k8s cluster on AWS
4 |
5 | ### Create new context
6 | ```bash
7 | kubectl config set-context altinity.k8s.local
8 | ```
9 |
10 | ### Access k8s service locally
11 | We can access any service inside k8s cluster on `localhost` via port-forwarding feature.
12 | Example: forwarding Graphana dashboard to `localhost:3090`
13 | ```bash
14 | kubectl --namespace=grafana port-forward service/grafana-service 3090:3000
15 | ```
16 | Point browser to `http://localhost:3090` in order to access Grafana
17 |
18 | ### Update k8s config
19 | Add new `cluster` section to kubernetes config. It is usually located at `~/.kube/config`
20 | ```txt
21 | apiVersion: v1
22 | clusters:
23 | - cluster:
24 | certificate-authority-data: # AWS key
25 | server: # k8s API server URL like https://k8s.api.server.URL.on.Amazon.goes.here.amazonaws.com
26 | name: altinity.k8s.local
27 | contexts:
28 | - context:
29 | cluster: altinity.k8s.local
30 | user: altinity.k8s.local
31 | name: altinity.k8s.local
32 | current-context: altinity.k8s.local
33 | kind: Config
34 | preferences: {}
35 | users:
36 | - name: altinity.k8s.local
37 | user:
38 | client-certificate-data: # AWS key
39 | client-key-data: # AWS key
40 | password: # password here
41 | username: admin
42 | - name: altinity.k8s.local-basic-auth
43 | user:
44 | password: # password here
45 | username: admin
46 | ```
47 |
--------------------------------------------------------------------------------
/docs/monitoring_setup.md:
--------------------------------------------------------------------------------
1 |
2 | In order to setup monitoring, we need to:
3 |
4 | 1. [Setup Prometheus][prometheus_setup] in order to pool data from ClickHouse into Prometheus
5 | 1. and after that - [setup grafana][grafana_setup] in order to display data accumulated in Prometheus
6 |
7 | [prometheus_setup]: ./prometheus_setup.md
8 | [grafana_setup]: ./grafana_setup.md
9 |
--------------------------------------------------------------------------------
/docs/operator_build_from_sources.md:
--------------------------------------------------------------------------------
1 | # ClickHouse Operator Build From Sources
2 |
3 | ## Requirements
4 |
5 | 1. `go-lang` compiler
6 | 2. `mod` Package Manager
7 | 3. Get the sources from our repository using `go` git wrapper `go get github.com/altinity/clickhouse-operator`
8 |
9 | ## Binary Build Procedure
10 |
11 | 1. Switch working dir to `src/github.com/altinity/clickhouse-operator`
12 | 2. Make sure all packages are linked properly by using `mod` package manager: `go mod tidy`
13 | 3. Build the sources `go build -o ./clickhouse-operator cmd/operator/main.go`. This will create `clickhouse-operator` binary which could be only used inside kubernetes environment.
14 |
15 | ## Docker Image Build and Usage Procedure
16 |
17 | This process does not require `go-lang` compiler nor `dep` package manager. Instead it requires `kubernetes` and `docker`.
18 |
19 | 1. Switch working dir to `src/github.com/altinity/clickhouse-operator`
20 | 2. Build docker image with `docker`: `docker build -t altinity/clickhouse-operator ./`
21 | 3. Register freshly build `docker` image inside `kubernetes` environment like so: `docker save altinity/clickhouse-operator | (eval $(minikube docker-env) && docker load)`
22 | 4. Install `clickhouse-operator` as described here: [Install ClickHouse Operator][install]
23 |
24 | [install]: ./operator_installation_details.md
--------------------------------------------------------------------------------
/docs/pull_request_template.md:
--------------------------------------------------------------------------------
1 | Thanks for taking the time to contribute to `clickhouse-operator`!
2 |
3 | Please, read carefully [instructions on how to make a Pull Request](https://github.com/Altinity/clickhouse-operator/blob/master/CONTRIBUTING.md#intro).
4 |
5 | This will help a lot for maintainers to adopt your Pull Request.
6 |
7 | ## Important items to consider before making a Pull Request
8 | Please check items PR complies to:
9 | * [ ] All commits in the PR are squashed. [More info](https://github.com/Altinity/clickhouse-operator/blob/master/CONTRIBUTING.md#how-to-make-pr)
10 | * [ ] The PR is made into dedicated `next-release` branch, **not into** `master` branch1. [More info](https://github.com/Altinity/clickhouse-operator/blob/master/CONTRIBUTING.md#how-to-make-pr)
11 | * [ ] The PR is signed. [More info](https://github.com/Altinity/clickhouse-operator/blob/master/CONTRIBUTING.md#sign-your-work)
12 |
13 |
14 | --
15 |
16 | 1 If you feel your PR does not affect any Go-code or any testable functionality (for example, PR contains docs only or supplementary materials), PR can be made into `master` branch, but it has to be confirmed by project's maintainer.
17 |
--------------------------------------------------------------------------------
/docs/reconciler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/radondb/radondb-clickhouse-operator/62897be85437bec21e7bf6bb17176085af381d6e/docs/reconciler.png
--------------------------------------------------------------------------------
/docs/schema_migration.md:
--------------------------------------------------------------------------------
1 | # Schema maintenance
2 |
3 | `clickhouse-operator` automates schema management when cluster is scaled up or down
4 |
5 | # Schema auto-creation
6 |
7 | After cluster is scaled up and new ClickHouse instances are ready, `clickhouse-operator` automatically creates schema.
8 |
9 | If shard is added:
10 | * Other shards in the cluster are analyzed for distributed and corresponding local tables
11 | * Databases for local and distributed tables are created
12 | * Local tables are created
13 | * Distributed tables are created
14 |
15 | If replica is added:
16 | * Other replicas **at the same shard** are analyzed for replicated tables
17 | * Databases for replicated tables are created
18 | * Replicated tables are created
19 | * Then the same logic as to adding shard applies
20 |
21 | # Schema auto-deletion
22 |
23 | If cluster is scaled down and some shards or replicas are deleted, `clickhouse-operator` drops replicated table to make sure nothing is left in ZooKeeper.
24 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/radondb/clickhouse-operator
2 |
3 | go 1.13
4 |
5 | require (
6 | github.com/MakeNowJust/heredoc v1.0.0
7 | github.com/altinity/queue v0.0.0-20210114142043-ddb7da66064f
8 | github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
9 | github.com/d4l3k/messagediff v1.2.1 // indirect
10 | github.com/gogo/protobuf v1.3.2 // indirect
11 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
12 | github.com/google/uuid v1.3.0
13 | github.com/imdario/mergo v0.3.11
14 | github.com/juliangruber/go-intersect v1.0.0
15 | github.com/kubernetes-sigs/yaml v1.1.0
16 | github.com/mailru/go-clickhouse v1.6.0
17 | github.com/prometheus/client_golang v1.7.1
18 | github.com/r3labs/diff v0.0.0-20191120142937-b4ed99a31f5a
19 | github.com/sanity-io/litter v1.3.0
20 | github.com/securego/gosec/v2 v2.8.1
21 | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect
22 | golang.org/x/tools v0.1.5 // indirect
23 | gopkg.in/d4l3k/messagediff.v1 v1.2.1
24 | gopkg.in/yaml.v2 v2.4.0
25 | k8s.io/api v0.20.5
26 | k8s.io/apimachinery v0.20.5
27 | k8s.io/client-go v0.0.0-00010101000000-000000000000
28 | k8s.io/code-generator v0.0.0-00010101000000-000000000000
29 | )
30 |
31 | replace (
32 | k8s.io/api => k8s.io/api v0.20.5
33 | k8s.io/apimachinery => k8s.io/apimachinery v0.20.5
34 | k8s.io/client-go => k8s.io/client-go v0.20.5
35 | k8s.io/code-generator => k8s.io/code-generator v0.20.5
36 | )
37 |
--------------------------------------------------------------------------------
/hack/tools.go:
--------------------------------------------------------------------------------
1 | // +build tools
2 |
3 | // This package imports things required by build scripts, to force `go mod` to see them as dependencies
4 | package tools
5 |
6 | import (
7 | _ "github.com/securego/gosec/v2/cmd/gosec"
8 | _ "k8s.io/code-generator"
9 | )
10 |
--------------------------------------------------------------------------------
/pkg/apis/clickhouse.radondb.com/register.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package clickhouseradondbcom
16 |
17 | const (
18 | // GroupName is the group name of the ClickHouse Operator API.
19 | GroupName = "clickhouse.radondb.com"
20 | )
21 |
--------------------------------------------------------------------------------
/pkg/apis/clickhouse.radondb.com/v1/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | // +k8s:deepcopy-gen=package,register
16 | // +groupName=clickhouse.radondb.com
17 |
18 | // Package v1 defines version 1 of the API used with ClickHouse Installation Custom Resources.
19 | package v1
20 |
--------------------------------------------------------------------------------
/pkg/apis/clickhouse.radondb.com/v1/type_zookeeper_node.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package v1
16 |
17 | // Equal checks whether zookeepr node is equal to another
18 | func (zkNode *ChiZookeeperNode) Equal(to *ChiZookeeperNode) bool {
19 | if to == nil {
20 | return false
21 | }
22 |
23 | return (zkNode.Host == to.Host) && (zkNode.Port == to.Port)
24 | }
25 |
--------------------------------------------------------------------------------
/pkg/apis/metrics/rest_client.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package metrics
16 |
17 | // InformMetricsExporterAboutWatchedCHI informs exporter about new watched CHI
18 | func InformMetricsExporterAboutWatchedCHI(namespace, chiName string, hostnames []string) error {
19 | chi := &WatchedCHI{
20 | Namespace: namespace,
21 | Name: chiName,
22 | Hostnames: hostnames,
23 | }
24 | return makeRESTCall(chi, "POST")
25 | }
26 |
27 | // InformMetricsExporterToDeleteWatchedCHI informs exporter to delete/forget watched CHI
28 | func InformMetricsExporterToDeleteWatchedCHI(namespace, chiName string) error {
29 | chi := &WatchedCHI{
30 | Namespace: namespace,
31 | Name: chiName,
32 | Hostnames: []string{},
33 | }
34 | return makeRESTCall(chi, "DELETE")
35 | }
36 |
--------------------------------------------------------------------------------
/pkg/apis/metrics/type_ch_access_info.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package metrics
16 |
17 | // CHAccessInfo specifies ClickHouse access info
18 | type CHAccessInfo struct {
19 | Username string
20 | Password string
21 | Port int
22 | }
23 |
24 | // NewCHAccessInfo creates new CHAccessInfo from specified access info
25 | func NewCHAccessInfo(username, password string, port int) *CHAccessInfo {
26 | return &CHAccessInfo{
27 | Username: username,
28 | Password: password,
29 | Port: port,
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/pkg/client/clientset/versioned/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Code generated by client-gen. DO NOT EDIT.
18 |
19 | // This package has the automatically generated clientset.
20 | package versioned
21 |
--------------------------------------------------------------------------------
/pkg/client/clientset/versioned/fake/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Code generated by client-gen. DO NOT EDIT.
18 |
19 | // This package has the automatically generated fake clientset.
20 | package fake
21 |
--------------------------------------------------------------------------------
/pkg/client/clientset/versioned/scheme/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Code generated by client-gen. DO NOT EDIT.
18 |
19 | // This package contains the scheme of the automatically generated clientset.
20 | package scheme
21 |
--------------------------------------------------------------------------------
/pkg/client/clientset/versioned/typed/clickhouse.radondb.com/v1/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Code generated by client-gen. DO NOT EDIT.
18 |
19 | // This package has the automatically generated typed clients.
20 | package v1
21 |
--------------------------------------------------------------------------------
/pkg/client/clientset/versioned/typed/clickhouse.radondb.com/v1/fake/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Code generated by client-gen. DO NOT EDIT.
18 |
19 | // Package fake has the automatically generated clients.
20 | package fake
21 |
--------------------------------------------------------------------------------
/pkg/client/clientset/versioned/typed/clickhouse.radondb.com/v1/generated_expansion.go:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright The Kubernetes Authors.
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 |
17 | // Code generated by client-gen. DO NOT EDIT.
18 |
19 | package v1
20 |
21 | type ClickHouseInstallationExpansion interface{}
22 |
23 | type ClickHouseInstallationTemplateExpansion interface{}
24 |
25 | type ClickHouseOperatorConfigurationExpansion interface{}
26 |
--------------------------------------------------------------------------------
/pkg/controller/chi/context.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package chi
16 |
17 | import (
18 | "context"
19 | )
20 |
21 | // newContext
22 | func newContext() context.Context {
23 | return context.TODO()
24 | }
25 |
--------------------------------------------------------------------------------
/pkg/model/clickhouse/connection_params.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package clickhouse
16 |
17 | // ConnectionParams represents connection parameters
18 | type ConnectionParams struct {
19 | *EndpointCredentials
20 | *Timeouts
21 | }
22 |
23 | // NewConnectionParams creates new ConnectionParams
24 | func NewConnectionParams(hostname, username, password string, port int) *ConnectionParams {
25 | return &ConnectionParams{
26 | NewEndpointCredentials(hostname, username, password, port),
27 | NewTimeouts(),
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/pkg/model/clickhouse/endpoint_credentials_cluster.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package clickhouse
16 |
17 | // ClusterEndpointCredentials specifies cluster endpoint credentials
18 | type ClusterEndpointCredentials struct {
19 | Username string
20 | Password string
21 | Port int
22 | }
23 |
--------------------------------------------------------------------------------
/pkg/model/const.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package model
16 |
17 | const (
18 | // Default value for ClusterIP service
19 | templateDefaultsServiceClusterIP = "None"
20 | )
21 |
22 | const (
23 | // .spec.useTemplate.useType
24 | useTypeMerge = "merge"
25 | )
26 |
--------------------------------------------------------------------------------
/pkg/util/dump.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package util
16 |
17 | import dumper "github.com/sanity-io/litter"
18 |
19 | // Dump dumps object into string with repeatable order
20 | func Dump(obj interface{}) string {
21 | d := dumper.Options{
22 | Separator: " ",
23 | }
24 | return d.Sdump(obj)
25 | }
26 |
--------------------------------------------------------------------------------
/pkg/util/duration.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package util
16 |
17 | import "time"
18 |
19 | // ReasonableDuration finds first duration > 0 or returns 0 in case no durations provided
20 | func ReasonableDuration(durations ...time.Duration) time.Duration {
21 | if len(durations) == 0 {
22 | return 0
23 | }
24 | for _, duration := range durations {
25 | if duration > 0 {
26 | return duration
27 | }
28 | }
29 | return 0
30 | }
31 |
--------------------------------------------------------------------------------
/pkg/util/fingerprint.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package util
16 |
17 | // Fingerprint creates object's fingerprint
18 | func Fingerprint(obj interface{}) string {
19 | return HashIntoString(serializeRepeatable(obj))
20 | }
21 |
--------------------------------------------------------------------------------
/pkg/util/k8s.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package util
16 |
17 | import "k8s.io/apimachinery/pkg/apis/meta/v1"
18 |
19 | // NamespaceName returns namespace and anme from the meta
20 | func NamespaceName(meta v1.ObjectMeta) (string, string) {
21 | return meta.Namespace, meta.Name
22 | }
23 |
24 | // NamespaceNameString returns namespace and name as one string
25 | func NamespaceNameString(meta v1.ObjectMeta) string {
26 | return meta.Namespace + "/" + meta.Name
27 | }
28 |
29 | // IsAnnotationToBeSkipped checks whether an annotation should be skipped
30 | func IsAnnotationToBeSkipped(annotation string) bool {
31 | switch annotation {
32 | case "kubectl.kubernetes.io/last-applied-configuration":
33 | return true
34 | }
35 | return false
36 | }
37 |
--------------------------------------------------------------------------------
/pkg/util/print.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package util
16 |
17 | import (
18 | "fmt"
19 | "io"
20 | "strconv"
21 | )
22 |
23 | // Iline writes indented line with \n into provided io.Writer
24 | func Iline(w io.Writer, indent int, format string, a ...interface{}) {
25 | if indent > 0 {
26 | // Prepare indentation template %16s
27 | template := "%" + strconv.Itoa(indent) + "s"
28 | Fprintf(w, template, " ")
29 | }
30 | Fprintf(w, format, a...)
31 | Fprintf(w, "\n")
32 | }
33 |
34 | // Fprintf suppresses warning for unused returns of fmt.Fprintf()
35 | func Fprintf(w io.Writer, format string, a ...interface{}) {
36 | _, _ = fmt.Fprintf(w, format, a...)
37 | }
38 |
--------------------------------------------------------------------------------
/pkg/util/runtime/runtime.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package runtime
16 |
17 | import (
18 | "path"
19 | "runtime"
20 | "strings"
21 | )
22 |
23 | // Caller returns triplet: file name, line number, function name of a caller
24 | func Caller(skip string) (string, int, string) {
25 | pc := make([]uintptr, 7)
26 | n := runtime.Callers(2, pc)
27 | frames := runtime.CallersFrames(pc[:n])
28 | for {
29 | frame, more := frames.Next()
30 | // frame.File = /tmp/sandbox469341579/prog.go
31 | // frame.Line = 28
32 | // frame.Function = main.Announcer.Info
33 |
34 | // file = prog.go
35 | file := path.Base(frame.File)
36 | // function = Info
37 | function := path.Base(strings.Replace(frame.Function, ".", "/", -1))
38 |
39 | if file != skip {
40 | return file, frame.Line, function
41 | }
42 |
43 | if !more {
44 | break
45 | }
46 | }
47 | return "", 0, ""
48 | }
49 |
--------------------------------------------------------------------------------
/pkg/version/version.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 Altinity Ltd and/or its affiliates. All rights reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | package version
16 |
17 | // Version represents the software version
18 | var Version = "dev-version"
19 |
20 | // GitSHA represents the Git commit hash in short format
21 | var GitSHA string
22 |
23 | // BuiltAt represents date + time when binary was built
24 | var BuiltAt string
25 |
--------------------------------------------------------------------------------
/release:
--------------------------------------------------------------------------------
1 | 2.1.1
2 |
--------------------------------------------------------------------------------
/tests/configs/test-001.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: test-001
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: single
9 |
--------------------------------------------------------------------------------
/tests/configs/test-002-tpl.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-002-tpl"
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | - name: clickhouse-log-volume-mount
9 | - name: one-per-host-distribution
10 | configuration:
11 | clusters:
12 | - name: single
13 |
--------------------------------------------------------------------------------
/tests/configs/test-003-complex-layout.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-003-complex-layout"
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | clusters:
10 | - name: clickhouse
11 | layout:
12 | shards:
13 | - name: shard0
14 | replicas:
15 | - name: replica0-0
16 | settings:
17 | display_name: replica0
18 | - name: replica0-1
19 | settings:
20 | display_name: replica1
21 | - name: shard1
22 | replicas:
23 | - name: replica1-0
24 | - name: replica1-1
25 |
--------------------------------------------------------------------------------
/tests/configs/test-004-tpl.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "clickhouse-old-volume-mount"
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | clusters:
10 | - name: single
11 | defaults:
12 | templates:
13 | volumeClaimTemplate: default
14 | templates:
15 | volumeClaimTemplates:
16 | - name: default
17 | spec:
18 | accessModes:
19 | - ReadWriteOnce
20 | resources:
21 | requests:
22 | storage: 100Mi
--------------------------------------------------------------------------------
/tests/configs/test-006-ch-upgrade-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-006
5 | spec:
6 | reconciling:
7 | policy: "wait"
8 | templates:
9 | podTemplates:
10 | - name: clickhouse-old
11 | spec:
12 | containers:
13 | - name: clickhouse-pod
14 | image: yandex/clickhouse-server:20.8.6.6
15 | defaults:
16 | templates:
17 | podTemplate: clickhouse-old
18 | configuration:
19 | clusters:
20 | - name: shards
21 | layout:
22 | replicasCount: 2
23 |
--------------------------------------------------------------------------------
/tests/configs/test-006-ch-upgrade-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-006
5 | spec:
6 | reconciling:
7 | policy: "wait"
8 | templates:
9 | podTemplates:
10 | - name: clickhouse-new
11 | spec:
12 | containers:
13 | - name: clickhouse-pod
14 | image: yandex/clickhouse-server:21.1.7.1
15 | defaults:
16 | templates:
17 | podTemplate: clickhouse-new
18 | configuration:
19 | clusters:
20 | - name: shards
21 | layout:
22 | replicasCount: 2
23 |
--------------------------------------------------------------------------------
/tests/configs/test-006-ch-upgrade-3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-006
5 | spec:
6 | reconciling:
7 | policy: "wait"
8 | templates:
9 | podTemplates:
10 | - name: clickhouse-new
11 | spec:
12 | containers:
13 | - name: clickhouse-pod
14 | image: yandex/clickhouse-server:20.8.6.6
15 | defaults:
16 | templates:
17 | podTemplate: clickhouse-new
18 | configuration:
19 | clusters:
20 | - name: shards
21 | layout:
22 | replicasCount: 2
23 |
--------------------------------------------------------------------------------
/tests/configs/test-007-custom-ports.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-007-custom-ports"
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | clusters:
10 | - name: single
11 | settings:
12 | http_port: 8124
13 | tcp_port: 9001
14 | interserver_http_port: 9010
--------------------------------------------------------------------------------
/tests/configs/test-008-operator-restart-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-008-1"
5 | labels:
6 | test: test
7 | spec:
8 | useTemplates:
9 | - name: clickhouse-version
10 | configuration:
11 | clusters:
12 | - name: test-008-1
13 | layout:
14 | shardsCount: 1
15 | defaults:
16 | templates:
17 | volumeClaimTemplate: default
18 | podTemplate: default
19 | templates:
20 | volumeClaimTemplates:
21 | - name: default
22 | spec:
23 | accessModes:
24 | - ReadWriteOnce
25 | resources:
26 | requests:
27 | storage: 100Mi
28 |
--------------------------------------------------------------------------------
/tests/configs/test-009-operator-upgrade-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-009-1"
5 | labels:
6 | test: test
7 | spec:
8 | useTemplates:
9 | - name: clickhouse-version
10 | configuration:
11 | clusters:
12 | - name: test-009-1
13 | layout:
14 | shardsCount: 1
15 | defaults:
16 | templates:
17 | volumeClaimTemplate: default
18 | podTemplate: default
19 | templates:
20 | volumeClaimTemplates:
21 | - name: default
22 | spec:
23 | accessModes:
24 | - ReadWriteOnce
25 | resources:
26 | requests:
27 | storage: 100Mi
28 |
--------------------------------------------------------------------------------
/tests/configs/test-010-zkroot.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 |
4 | metadata:
5 | name: test-010-zkroot
6 |
7 | spec:
8 | useTemplates:
9 | - name: clickhouse-version
10 | defaults:
11 | templates:
12 | logVolumeClaimTemplate: default
13 | configuration:
14 | zookeeper: # Add Zookeeper
15 | nodes:
16 | - host: zookeeper
17 | # port: 2181
18 | root: "/clickhouse/test-010-zkroot"
19 | session_timeout_ms: 30000
20 | operation_timeout_ms: 10000
21 | clusters:
22 | - name: default
23 | layout:
24 | shardsCount: 1
25 | replicasCount: 1
26 | templates:
27 | volumeClaimTemplates:
28 | - name: default
29 | spec:
30 | accessModes:
31 | - ReadWriteOnce
32 | resources:
33 | requests:
34 | storage: 100Mi
35 |
--------------------------------------------------------------------------------
/tests/configs/test-011-insecured-cluster.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-011-insecured-cluster
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | clusters:
10 | - name: default
11 | layout:
12 | shardsCount: 1
13 | replicasCount: 1
14 |
--------------------------------------------------------------------------------
/tests/configs/test-011-secured-cluster.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-011-secured-cluster
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | users:
10 | # default user should be security to localhost and interhost connections
11 | # operator creates host_regxp expression for that
12 | # default/networks/host_regexp: \.chi-test-011-secure-user-[^.]+-\d+-\d+\.test.svc.cluster.local$
13 | user1/password: topsecret
14 | user1/networks/ip: "::/0"
15 | # user2 should get default password automatically
16 | user2/networks/ip: "::/0"
17 | # user3 should get sha256 correctly
18 | user3/password: abcd
19 | user3/password_sha256_hex: 716b36073a90c6fe1d445ac1af85f4777c5b7a155cea359961826a030513e448
20 | # restricted user with row-level security
21 | restricted/password: secret
22 | restricted/databases/system/numbers/filter: "number=1000"
23 | clusters:
24 | - name: default
25 | layout:
26 | shardsCount: 2
27 | replicasCount: 1
28 |
--------------------------------------------------------------------------------
/tests/configs/test-011-secured-default-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-011-secured-default
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | settings:
10 | logger/level: information # We need to change settings in order to make sure all settings are propagated
11 | users:
12 | default/password_sha256_hex: 716b36073a90c6fe1d445ac1af85f4777c5b7a155cea359961826a030513e448
13 | test/password: abcd
14 | clusters:
15 | - name: default
16 | layout:
17 | shardsCount: 1
18 | replicasCount: 1
19 |
--------------------------------------------------------------------------------
/tests/configs/test-011-secured-default-3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-011-secured-default
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | settings:
10 | logger/level: trace # We need to change settings in order to make sure all settings are propagated
11 | users:
12 | default/profile: readonly
13 | clusters:
14 | - name: default
15 | layout:
16 | shardsCount: 1
17 | replicasCount: 1
18 |
--------------------------------------------------------------------------------
/tests/configs/test-011-secured-default.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-011-secured-default
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | users:
10 | default/password_sha256_hex: 716b36073a90c6fe1d445ac1af85f4777c5b7a155cea359961826a030513e448
11 | clusters:
12 | - name: default
13 | layout:
14 | shardsCount: 1
15 | replicasCount: 1
16 |
--------------------------------------------------------------------------------
/tests/configs/test-012-service-template-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-012
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-version
11 | defaults:
12 | templates:
13 | serviceTemplate: service-template
14 | replicaServiceTemplate: replica-service-template
15 | configuration:
16 | clusters:
17 | - name: default
18 | templates:
19 | clusterServiceTemplate: cluster-service-template
20 | layout:
21 | shardsCount: 1
22 | replicasCount: 1
23 | templates:
24 | serviceTemplates:
25 | - name: service-template
26 | generateName: "service-{chi}"
27 | spec:
28 | ports:
29 | - name: http
30 | port: 8123
31 | - name: tcp
32 | port: 9000
33 | type: LoadBalancer
34 | externalTrafficPolicy: Local
35 | - name: cluster-service-template
36 | generateName: "service-{cluster}"
37 | spec:
38 | ports:
39 | - name: http
40 | port: 8123
41 | - name: tcp
42 | port: 9000
43 | type: ClusterIP
44 | clusterIP: None
45 | - name: replica-service-template
46 | generateName: "service-{chi}-{shard}-{replica}"
47 | spec:
48 | ports:
49 | - name: http
50 | port: 8123
51 | - name: tcp
52 | port: 9000
53 | type: ClusterIP
54 | clusterIP: None
--------------------------------------------------------------------------------
/tests/configs/test-012-service-template.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-012
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-version
11 | defaults:
12 | templates:
13 | serviceTemplate: service-template
14 | replicaServiceTemplate: replica-service-template
15 | configuration:
16 | clusters:
17 | - name: default
18 | templates:
19 | clusterServiceTemplate: cluster-service-template
20 | layout:
21 | shardsCount: 2
22 | replicasCount: 1
23 | templates:
24 | serviceTemplates:
25 | - name: service-template
26 | generateName: "service-{chi}"
27 | spec:
28 | ports:
29 | - name: http
30 | port: 8123
31 | - name: tcp
32 | port: 9000
33 | type: LoadBalancer
34 | externalTrafficPolicy: Local
35 | - name: cluster-service-template
36 | generateName: "service-{cluster}"
37 | spec:
38 | ports:
39 | - name: http
40 | port: 8123
41 | - name: tcp
42 | port: 9000
43 | type: ClusterIP
44 | clusterIP: None
45 | - name: replica-service-template
46 | generateName: "service-{chi}-{shard}-{replica}"
47 | spec:
48 | ports:
49 | - name: http
50 | port: 8123
51 | - name: tcp
52 | port: 9000
53 | type: ClusterIP
54 | clusterIP: None
--------------------------------------------------------------------------------
/tests/configs/test-013-add-shards-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: test-013-add-shards
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | clusters:
10 | - name: default
11 | layout:
12 | shardsCount: 1
13 | replicasCount: 1
14 |
15 |
--------------------------------------------------------------------------------
/tests/configs/test-013-add-shards-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: test-013-add-shards
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | clusters:
10 | - name: default
11 | layout:
12 | shardsCount: 3
13 | replicasCount: 1
14 |
15 |
--------------------------------------------------------------------------------
/tests/configs/test-014-replication-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-014-replication
7 |
8 | spec:
9 | reconciling:
10 | policy: wait
11 | useTemplates:
12 | - name: clickhouse-version
13 | - name: persistent-volume
14 | configuration:
15 | zookeeper:
16 | nodes:
17 | - host: zookeeper
18 | port: 2181
19 | session_timeout_ms: 5000
20 | operation_timeout_ms: 5000
21 | clusters:
22 | - name: default
23 | layout:
24 | replicasCount: 2
25 |
--------------------------------------------------------------------------------
/tests/configs/test-014-replication-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-014-replication
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-version
11 | - name: persistent-volume
12 | configuration:
13 | zookeeper:
14 | nodes:
15 | - host: zookeeper
16 | port: 2181
17 | session_timeout_ms: 5000
18 | operation_timeout_ms: 5000
19 | clusters:
20 | - name: default
21 | layout:
22 | replicasCount: 5
23 |
24 |
--------------------------------------------------------------------------------
/tests/configs/test-015-host-network.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: test-015-host-network
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | defaults:
9 | templates:
10 | podTemplate: pod-distribution
11 |
12 | configuration:
13 | clusters:
14 | - name: default
15 | layout:
16 | shardsCount: 1
17 | replicas:
18 | - templates:
19 | hostTemplate: replica-0
20 | - templates:
21 | hostTemplate: replica-1
22 |
23 | templates:
24 | hostTemplates:
25 | - name: replica-0
26 | spec:
27 | tcpPort: 10000
28 | httpPort: 10001
29 | interserverHTTPPort: 10002
30 | - name: replica-1
31 | spec:
32 | tcpPort: 11000
33 | httpPort: 11001
34 | interserverHTTPPort: 11002
35 |
36 | podTemplates:
37 | - name: pod-distribution
38 | # podDistribution:
39 | # - type: CircularReplication
40 | spec:
41 | hostNetwork: true
42 | containers:
43 | - name: clickhouse-pod
44 | image: yandex/clickhouse-server:latest
45 |
46 |
47 | # dnsPolicy: ClusterFirstWithHostNet
48 |
49 |
--------------------------------------------------------------------------------
/tests/configs/test-017-multi-version.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-017-multi-version
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: v20.3
9 | spec:
10 | containers:
11 | - name: clickhouse-pod
12 | image: yandex/clickhouse-server:20.3.19.4
13 | - name: v20.8
14 | spec:
15 | containers:
16 | - name: clickhouse-pod
17 | image: yandex/clickhouse-server:21.1.7.1
18 | configuration:
19 | clusters:
20 | - name: default
21 | layout:
22 | shards:
23 | - templates:
24 | podTemplate: v20.3
25 | - templates:
26 | podTemplate: v20.8
27 | files:
28 | users.d/remove_database_ordinary.xml: |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/tests/configs/test-018-configmap-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-018-configmap
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | settings:
10 | display_name: "old_display_name"
11 | macros/test: "old_test"
12 | clusters:
13 | - name: default
14 |
--------------------------------------------------------------------------------
/tests/configs/test-018-configmap-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-018-configmap
5 | spec:
6 | useTemplates:
7 | - name: clickhouse-version
8 | configuration:
9 | settings:
10 | display_name: "new_display_name"
11 | macros/test: "new_test"
12 | clusters:
13 | - name: default
14 |
--------------------------------------------------------------------------------
/tests/configs/test-019-retain-volume-1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-019-retain-volume"
5 | labels:
6 | test: test
7 | spec:
8 |
9 | useTemplates:
10 | - name: clickhouse-version
11 | configuration:
12 | zookeeper:
13 | nodes:
14 | - host: zookeeper
15 | port: 2181
16 | clusters:
17 | - name: simple
18 | layout:
19 | replicasCount: 1
20 | defaults:
21 | templates:
22 | volumeClaimTemplate: default
23 | podTemplate: default
24 | templates:
25 | volumeClaimTemplates:
26 | - name: default
27 | reclaimPolicy: Retain
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 100Mi
34 |
--------------------------------------------------------------------------------
/tests/configs/test-019-retain-volume-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-019-retain-volume"
5 | labels:
6 | test: test
7 | spec:
8 | stop: "yes"
9 | useTemplates:
10 | - name: clickhouse-version
11 | configuration:
12 | zookeeper:
13 | nodes:
14 | - host: zookeeper
15 | port: 2181
16 | clusters:
17 | - name: simple
18 | layout:
19 | replicasCount: 1
20 | defaults:
21 | templates:
22 | volumeClaimTemplate: default
23 | podTemplate: default
24 | templates:
25 | volumeClaimTemplates:
26 | - name: default
27 | reclaimPolicy: Retain
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 100Mi
34 |
--------------------------------------------------------------------------------
/tests/configs/test-019-retain-volume-3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-019-retain-volume"
5 | labels:
6 | test: test
7 | spec:
8 |
9 | useTemplates:
10 | - name: clickhouse-version
11 | configuration:
12 | zookeeper:
13 | nodes:
14 | - host: zookeeper
15 | port: 2181
16 | clusters:
17 | - name: simple
18 | layout:
19 | replicasCount: 2
20 | defaults:
21 | templates:
22 | volumeClaimTemplate: default
23 | podTemplate: default
24 | templates:
25 | volumeClaimTemplates:
26 | - name: default
27 | reclaimPolicy: Retain
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 100Mi
34 |
--------------------------------------------------------------------------------
/tests/configs/test-019-retain-volume-4.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-019-retain-volume"
5 | labels:
6 | test: test
7 | spec:
8 |
9 | useTemplates:
10 | - name: clickhouse-version
11 | configuration:
12 | zookeeper:
13 | nodes:
14 | - host: zookeeper
15 | port: 2181
16 | clusters:
17 | - name: simple
18 | layout:
19 | replicasCount: 2
20 | defaults:
21 | templates:
22 | volumeClaimTemplate: default
23 | podTemplate: default
24 | templates:
25 | volumeClaimTemplates:
26 | - name: default
27 | reclaimPolicy: Delete
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 100Mi
34 |
--------------------------------------------------------------------------------
/tests/configs/test-020-multi-volume.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-020-multi-volume"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: simple
9 | layout:
10 | shardsCount: 1
11 | settings:
12 | storage_configuration/disks/disk2/path: /var/lib/clickhouse2/
13 | storage_configuration/policies/default/volumes/default/disk: default
14 | storage_configuration/policies/default/volumes/disk2/disk: disk2
15 | defaults:
16 | templates:
17 | podTemplate: multi-volume
18 | templates:
19 | volumeClaimTemplates:
20 | - name: disk1
21 | spec:
22 | accessModes:
23 | - ReadWriteOnce
24 | resources:
25 | requests:
26 | storage: 100Mi
27 | - name: disk2
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 50Mi
34 | podTemplates:
35 | - name: multi-volume
36 | spec:
37 | containers:
38 | - name: clickhouse-pod
39 | image: yandex/clickhouse-server:21.1.7.1
40 | volumeMounts:
41 | - name: disk1
42 | mountPath: /var/lib/clickhouse
43 | - name: disk2
44 | mountPath: /var/lib/clickhouse2
45 | command:
46 | - /bin/bash
47 | - '-c'
48 | - chown clickhouse /var/lib/clickhouse2 && /entrypoint.sh
49 |
--------------------------------------------------------------------------------
/tests/configs/test-021-rescale-volume-01.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-021-rescale-volume"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: simple
9 | layout:
10 | shardsCount: 1
11 | defaults:
12 | templates:
13 | podTemplate: multi-volume
14 | templates:
15 | volumeClaimTemplates:
16 | - name: disk1
17 | spec:
18 | accessModes:
19 | - ReadWriteOnce
20 | resources:
21 | requests:
22 | storage: 1Gi
23 | podTemplates:
24 | - name: multi-volume
25 | spec:
26 | containers:
27 | - name: clickhouse-pod
28 | image: yandex/clickhouse-server:21.1.7.1
29 | volumeMounts:
30 | - name: disk1
31 | mountPath: /var/lib/clickhouse
32 |
--------------------------------------------------------------------------------
/tests/configs/test-021-rescale-volume-02-enlarge-disk.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-021-rescale-volume"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: simple
9 | layout:
10 | shardsCount: 1
11 | defaults:
12 | templates:
13 | podTemplate: multi-volume
14 | templates:
15 | volumeClaimTemplates:
16 | - name: disk1
17 | spec:
18 | accessModes:
19 | - ReadWriteOnce
20 | resources:
21 | requests:
22 | storage: 2Gi
23 | podTemplates:
24 | - name: multi-volume
25 | spec:
26 | containers:
27 | - name: clickhouse-pod
28 | image: yandex/clickhouse-server:21.1.7.1
29 | volumeMounts:
30 | - name: disk1
31 | mountPath: /var/lib/clickhouse
32 |
--------------------------------------------------------------------------------
/tests/configs/test-021-rescale-volume-03-add-disk.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-021-rescale-volume"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: simple
9 | layout:
10 | shardsCount: 1
11 | settings:
12 | storage_configuration/disks/disk2/path: /var/lib/clickhouse2/
13 | storage_configuration/policies/default/volumes/default/disk: default
14 | storage_configuration/policies/default/volumes/disk2/disk: disk2
15 | defaults:
16 | templates:
17 | podTemplate: multi-volume
18 | templates:
19 | volumeClaimTemplates:
20 | - name: disk1
21 | spec:
22 | accessModes:
23 | - ReadWriteOnce
24 | resources:
25 | requests:
26 | storage: 2Gi
27 | - name: disk2
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 1Gi
34 | podTemplates:
35 | - name: multi-volume
36 | spec:
37 | containers:
38 | - name: clickhouse-pod
39 | image: yandex/clickhouse-server:21.1.7.1
40 | volumeMounts:
41 | - name: disk1
42 | mountPath: /var/lib/clickhouse
43 | - name: disk2
44 | mountPath: /var/lib/clickhouse2
45 | command:
46 | - /bin/bash
47 | - '-c'
48 | - chown clickhouse /var/lib/clickhouse2 && /entrypoint.sh
49 |
--------------------------------------------------------------------------------
/tests/configs/test-021-rescale-volume-04-decrease-disk.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-021-rescale-volume"
5 | spec:
6 | configuration:
7 | clusters:
8 | - name: simple
9 | layout:
10 | shardsCount: 1
11 | settings:
12 | storage_configuration/disks/disk2/path: /var/lib/clickhouse2/
13 | storage_configuration/policies/default/volumes/default/disk: default
14 | storage_configuration/policies/default/volumes/disk2/disk: disk2
15 | defaults:
16 | templates:
17 | podTemplate: multi-volume
18 | templates:
19 | volumeClaimTemplates:
20 | - name: disk1
21 | spec:
22 | accessModes:
23 | - ReadWriteOnce
24 | resources:
25 | requests:
26 | storage: 1Gi
27 | - name: disk2
28 | spec:
29 | accessModes:
30 | - ReadWriteOnce
31 | resources:
32 | requests:
33 | storage: 1Gi
34 | podTemplates:
35 | - name: multi-volume
36 | spec:
37 | containers:
38 | - name: clickhouse-pod
39 | image: yandex/clickhouse-server:21.1.9.41
40 | volumeMounts:
41 | - name: disk1
42 | mountPath: /var/lib/clickhouse
43 | - name: disk2
44 | mountPath: /var/lib/clickhouse2
45 | command:
46 | - /bin/bash
47 | - '-c'
48 | - chown clickhouse /var/lib/clickhouse2 && /entrypoint.sh
49 |
--------------------------------------------------------------------------------
/tests/configs/test-022-broken-image.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-022-broken-image
5 | spec:
6 | defaults:
7 | templates:
8 | podTemplate: v20.3
9 | templates:
10 | podTemplates:
11 | - name: v20.3
12 | spec:
13 | containers:
14 | - name: clickhouse-pod
15 | image: yandex/clickhouse-server:20.3.13.127-broken
16 | configuration:
17 | clusters:
18 | - name: default
--------------------------------------------------------------------------------
/tests/configs/test-024-template-annotations.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-024
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: default-pod-template
9 | metadata:
10 | annotations:
11 | test: "test"
12 | spec:
13 | containers:
14 | - name: clickhouse-pod
15 | image: yandex/clickhouse-server:21.1.7.1
16 | volumeClaimTemplates:
17 | - name: default-volumeclaim-template
18 | reclaimPolicy: Delete
19 | metadata:
20 | annotations:
21 | test: "test"
22 | spec:
23 | accessModes:
24 | - ReadWriteOnce
25 | resources:
26 | requests:
27 | storage: 1Gi
28 | serviceTemplates:
29 | - name: default-service-template
30 | generateName: clickhouse-{chi}
31 | metadata:
32 | annotations:
33 | test: "test"
34 | spec:
35 | ports:
36 | - name: http
37 | port: 8123
38 | - name: tcp
39 | port: 9000
40 | type: ClusterIP
41 | clusterIP: None
42 | defaults:
43 | templates:
44 | podTemplate: default-pod-template
45 | volumeClaimTemplate: default-volumeclaim-template
46 | serviceTemplate: default-service-template
47 | configuration:
48 | clusters:
49 | - name: default
--------------------------------------------------------------------------------
/tests/configs/test-025-rescaling-2.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-025-rescaling
7 |
8 | spec:
9 | defaults:
10 | templates:
11 | podTemplate: default
12 | useTemplates:
13 | - name: persistent-volume
14 | configuration:
15 | zookeeper:
16 | nodes:
17 | - host: zookeeper
18 | port: 2181
19 | clusters:
20 | - name: default
21 | layout:
22 | shardsCount: 1
23 | replicasCount: 2
24 | templates:
25 | podTemplates:
26 | - name: default
27 | spec:
28 | containers:
29 | - name: clickhouse-pod
30 | image: yandex/clickhouse-server:21.1.7.1
31 | command:
32 | - "/bin/bash"
33 | - "-c"
34 | - "sleep 15 && /entrypoint.sh"
--------------------------------------------------------------------------------
/tests/configs/test-025-rescaling.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-025-rescaling
7 |
8 | spec:
9 | defaults:
10 | templates:
11 | podTemplate: default
12 | useTemplates:
13 | - name: persistent-volume
14 | configuration:
15 | zookeeper:
16 | nodes:
17 | - host: zookeeper
18 | port: 2181
19 | clusters:
20 | - name: default
21 | layout:
22 | shardsCount: 1
23 | replicasCount: 1
24 | templates:
25 | podTemplates:
26 | - name: default
27 | spec:
28 | containers:
29 | - name: clickhouse-pod
30 | image: yandex/clickhouse-server:21.1.7.1
31 | command:
32 | - "/bin/bash"
33 | - "-c"
34 | - "sleep 15 && /entrypoint.sh"
--------------------------------------------------------------------------------
/tests/configs/test-027-troubleshooting-1-bad-config.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-027-trouble"
5 | spec:
6 |
7 | useTemplates:
8 | - name: clickhouse-version
9 | configuration:
10 | clusters:
11 | - name: default
12 | settings:
13 | merge_tree/some_trash: 1
14 |
--------------------------------------------------------------------------------
/tests/configs/test-027-troubleshooting-2-troubleshoot.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-027-trouble"
5 | spec:
6 | troubleshoot: "1"
7 | useTemplates:
8 | - name: clickhouse-version
9 | configuration:
10 | clusters:
11 | - name: default
12 | settings:
13 | merge_tree/some_trash: 1
14 |
--------------------------------------------------------------------------------
/tests/configs/test-027-troubleshooting-3-fixed-config.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallation"
3 | metadata:
4 | name: "test-027-trouble"
5 | spec:
6 |
7 | useTemplates:
8 | - name: clickhouse-version
9 | configuration:
10 | clusters:
11 | - name: default
12 |
--------------------------------------------------------------------------------
/tests/configs/test-029-distribution.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: clickhouse.radondb.com/v1
2 | kind: ClickHouseInstallation
3 | metadata:
4 | name: test-029-distribution
5 | spec:
6 | templates:
7 | podTemplates:
8 | - name: template-1
9 | spec:
10 | containers:
11 | - name: clickhouse-pod
12 | image: yandex/clickhouse-server:21.8
13 | podDistribution:
14 | - scope: ClickHouseInstallation
15 | type: ClickHouseAntiAffinity
16 | - name: template-2
17 | spec:
18 | containers:
19 | - name: clickhouse-pod
20 | image: yandex/clickhouse-server:21.8
21 | podDistribution:
22 | - scope: ClickHouseInstallation
23 | type: ReplicaAntiAffinity
24 | topologyKey: "kubernetes.io/os"
25 | configuration:
26 | clusters:
27 | - name: t1
28 | layout:
29 | shardsCount: 1
30 | replicas:
31 | - templates:
32 | podTemplate: template-1
33 | - templates:
34 | podTemplate: template-2
--------------------------------------------------------------------------------
/tests/configs/test-ch-001-insert-quorum.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-ch-001-insert-quorum
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-version
11 | configuration:
12 | zookeeper:
13 | nodes:
14 | - host: zookeeper
15 | port: 2181
16 | profiles:
17 | default/insert_quorum: 2
18 | default/insert_quorum_timeout: 5000
19 | default/parallel_view_processing: 1
20 | default/send_timeout: 3
21 | default/receive_timeout: 3
22 | clusters:
23 | - name: default
24 | layout:
25 | shardsCount: 1
26 | replicasCount: 2
27 |
28 |
--------------------------------------------------------------------------------
/tests/configs/test-ch-002-row-level.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-ch-002-row-level
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-version
11 | configuration:
12 | zookeeper:
13 | nodes:
14 | - host: zookeeper
15 | port: 2181
16 | users:
17 | user1/databases/default/test/filter: team='team1'
18 | user2/databases/default/test/filter: team='team2'
19 | user3/databases/default/test/filter: team='team3'
20 | user4/databases/default/test/filter: team='team4'
21 | user1/password: ""
22 | user2/password: ""
23 | user3/password: ""
24 | user4/password: ""
25 | clusters:
26 | - name: default
27 | layout:
28 | shardsCount: 1
29 | replicasCount: 1
30 |
31 |
--------------------------------------------------------------------------------
/tests/configs/test-cluster-for-alerts-changed-settings.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-cluster-for-alerts
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-version
11 | - name: persistent-volume
12 | configuration:
13 | settings:
14 | mysql_port: 3307
15 | profiles:
16 | clickhouse_operator/use_uncompressed_cache: 1
17 | default/use_uncompressed_cache: 1
18 | zookeeper:
19 | nodes:
20 | - host: zookeeper
21 | port: 2181
22 | session_timeout_ms: 5000
23 | operation_timeout_ms: 5000
24 | clusters:
25 | - name: default
26 | layout:
27 | shardsCount: 1
28 | replicasCount: 2
29 |
--------------------------------------------------------------------------------
/tests/configs/test-cluster-for-alerts.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-cluster-for-alerts
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-alerts-latest-version
11 | - name: persistent-volume
12 | configuration:
13 | settings:
14 | mysql_port: 3306
15 | # to allow scrape metrics via embedded prometheus protocol
16 | prometheus/endpoint: /metrics
17 | prometheus/port: 8888
18 | prometheus/metrics: true
19 | prometheus/events: true
20 | prometheus/asynchronous_metrics: true
21 |
22 | zookeeper:
23 | nodes:
24 | - host: zookeeper
25 | port: 2181
26 | session_timeout_ms: 5000
27 | operation_timeout_ms: 5000
28 | clusters:
29 | - name: default
30 | layout:
31 | shardsCount: 1
32 | replicasCount: 2
33 |
--------------------------------------------------------------------------------
/tests/configs/test-cluster-for-backups-fake.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-cluster-for-backups
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-backups-fake-backup
11 | - name: persistent-volume
12 | configuration:
13 | settings:
14 | mysql_port: 3306
15 | # to allow scrape metrics via embedded prometheus protocol
16 | prometheus/endpoint: /metrics
17 | prometheus/port: 8888
18 | prometheus/metrics: true
19 | prometheus/events: true
20 | prometheus/asynchronous_metrics: true
21 |
22 | zookeeper:
23 | nodes:
24 | - host: zookeeper
25 | port: 2181
26 | session_timeout_ms: 5000
27 | operation_timeout_ms: 5000
28 | clusters:
29 | - name: default
30 | layout:
31 | shardsCount: 1
32 | replicasCount: 2
33 |
--------------------------------------------------------------------------------
/tests/configs/test-cluster-for-backups.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-cluster-for-backups
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-backups-latest-version
11 | - name: persistent-volume
12 | configuration:
13 | settings:
14 | mysql_port: 3306
15 | # to allow scrape metrics via embedded prometheus protocol
16 | prometheus/endpoint: /metrics
17 | prometheus/port: 8888
18 | prometheus/metrics: true
19 | prometheus/events: true
20 | prometheus/asynchronous_metrics: true
21 |
22 | zookeeper:
23 | nodes:
24 | - host: zookeeper
25 | port: 2181
26 | session_timeout_ms: 5000
27 | operation_timeout_ms: 5000
28 | clusters:
29 | - name: default
30 | layout:
31 | shardsCount: 1
32 | replicasCount: 2
33 |
--------------------------------------------------------------------------------
/tests/configs/test-cluster-for-zookeeper.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 |
3 | kind: "ClickHouseInstallation"
4 |
5 | metadata:
6 | name: test-cluster-for-zk
7 |
8 | spec:
9 | useTemplates:
10 | - name: clickhouse-latest-version
11 | - name: persistent-volume
12 | configuration:
13 | zookeeper:
14 | nodes:
15 | - host: zookeeper
16 | port: 2181
17 | clusters:
18 | - name: default
19 | layout:
20 | shardsCount: 1
21 | replicasCount: 2
22 |
--------------------------------------------------------------------------------
/tests/manifest.py:
--------------------------------------------------------------------------------
1 | import yaml
2 |
3 |
4 | def get_chi_name(chi_manifest_filename):
5 | return yaml.safe_load(open(chi_manifest_filename, "r"))["metadata"]["name"]
6 |
7 |
8 | def get_chit_data(chi_manifest_filename):
9 | return yaml.safe_load(open(chi_manifest_filename, "r"))
10 |
11 |
--------------------------------------------------------------------------------
/tests/requirements.txt:
--------------------------------------------------------------------------------
1 | testflows==1.7.4
2 | urllib3
3 | PyYAML
4 | docker-compose>=1.29.1
5 | docker>=5.0.0
6 | dicttoxml
7 | setuptools
8 |
--------------------------------------------------------------------------------
/tests/run_tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | pip3 install -r requirements.txt
4 |
5 | export OPERATOR_NAMESPACE=test
6 | #python3 -m test --only=operator/*
7 | python3 -m test --only=operator/* -o short
8 |
--------------------------------------------------------------------------------
/tests/run_tests_cycle.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | start=`date`
4 | runs=1
5 | echo "start run $runs"
6 | while ./run_tests.sh; do
7 | runs=$((runs+1))
8 | echo "---------------------"
9 | echo "---------------------"
10 | echo "---------------------"
11 | echo "---------------------"
12 | echo "start run $runs"
13 | done
14 | end=`date`
15 |
16 | echo "====================="
17 | echo "====================="
18 | echo "====================="
19 | echo "successful runs $((runs-1))"
20 | echo "start $start"
21 | echo "end $end"
22 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-19.11.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:19.11.12.69
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.1.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.1
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.3
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.4.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.4
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.5.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.5
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.6.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.6
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.7.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.7
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-20.8.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:20.8
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-21.3.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:21.3
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-21.8.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:21.8
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-alerts.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-alerts-latest-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: clickhouse-alerts
10 | templates:
11 | podTemplates:
12 | - name: clickhouse-alerts
13 | metadata:
14 | annotations:
15 | prometheus.io/port: '8888'
16 | prometheus.io/scrape: 'true'
17 | spec:
18 | containers:
19 | - name: clickhouse-pod
20 | image: yandex/clickhouse-server:latest
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-auto.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-stable
6 | spec:
7 | templating:
8 | policy: auto
9 | defaults:
10 | templates:
11 | podTemplate: default
12 | templates:
13 | podTemplates:
14 | - name: default
15 | spec:
16 | containers:
17 | - name: clickhouse-pod
18 | image: yandex/clickhouse-server:21.1.7.1
19 | # command:
20 | # - "/bin/bash"
21 | # - "-c"
22 | # - "/entrypoint.sh; while true; do sleep 600; done"
23 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-latest.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-latest-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:latest
17 |
--------------------------------------------------------------------------------
/tests/templates/tpl-clickhouse-stable.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: clickhouse-version
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | spec:
14 | containers:
15 | - name: clickhouse-pod
16 | image: yandex/clickhouse-server:21.8.5.7
17 | # command:
18 | # - "/bin/bash"
19 | # - "-c"
20 | # - "/entrypoint.sh; while true; do sleep 600; done"
21 |
--------------------------------------------------------------------------------
/tests/templates/tpl-log-volume.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "clickhouse-log-volume-mount"
5 | spec:
6 | defaults:
7 | templates:
8 | logVolumeClaimTemplate: logs10m
9 | templates:
10 | volumeClaimTemplates:
11 | - name: logs10m
12 | spec:
13 | accessModes:
14 | - ReadWriteOnce
15 | resources:
16 | requests:
17 | storage: 10Mi
--------------------------------------------------------------------------------
/tests/templates/tpl-one-per-host.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: one-per-host-distribution
6 | spec:
7 | defaults:
8 | templates:
9 | podTemplate: default
10 | templates:
11 | podTemplates:
12 | - name: default
13 | podDistribution:
14 | - type: ClickHouseAntiAffinity
15 | scope: ClickHouseInstallation
16 |
--------------------------------------------------------------------------------
/tests/templates/tpl-persistent-volume-100Mi.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 | metadata:
4 | name: "persistent-volume"
5 | spec:
6 | defaults:
7 | templates:
8 | volumeClaimTemplate: default
9 | templates:
10 | volumeClaimTemplates:
11 | - name: default
12 | spec:
13 | accessModes:
14 | - ReadWriteOnce
15 | resources:
16 | requests:
17 | storage: 100Mi
18 | limits:
19 | storage: 100Mi
--------------------------------------------------------------------------------
/tests/templates/tpl-text-log.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: "clickhouse.radondb.com/v1"
2 | kind: "ClickHouseInstallationTemplate"
3 |
4 | metadata:
5 | name: text-log
6 |
7 | spec:
8 | configuration:
9 | settings:
10 | logger/level: debug
11 | text_log/database: system
12 | text_log/table: text_log
13 | text_log/flush_interval_milliseconds: 7500
14 |
--------------------------------------------------------------------------------