diff --git a/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/health.lua b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/health.lua new file mode 100644 index 0000000000..a17e977f5b --- /dev/null +++ b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/health.lua @@ -0,0 +1,17 @@ +local hs = {} +if obj.status ~= nil and obj.status.status ~= nil then + if obj.status.status == "Completed" then + hs.status = "Healthy" + hs.message = "ClickHouseKeeper installation completed successfully" + elseif obj.status.status == "InProgress" then + hs.status = "Progressing" + hs.message = "ClickHouseKeeper installation in progress" + else + hs.status = "Degraded" + hs.message = "ClickHouseKeeper status: " .. obj.status.status + end +else + hs.status = "Progressing" + hs.message = "ClickHouseKeeper status not yet available" +end +return hs \ No newline at end of file diff --git a/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/health_test.yaml b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/health_test.yaml new file mode 100644 index 0000000000..0be716a1d1 --- /dev/null +++ b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/health_test.yaml @@ -0,0 +1,17 @@ +tests: +- healthStatus: + status: Healthy + message: ClickHouseKeeper installation completed successfully + inputPath: testdata/healthy_completed.yaml +- healthStatus: + status: Progressing + message: ClickHouseKeeper installation in progress + inputPath: testdata/progressing_inprogress.yaml +- healthStatus: + status: Degraded + message: "ClickHouseKeeper status: Failed" + inputPath: testdata/degraded_failed.yaml +- healthStatus: + status: Progressing + message: ClickHouseKeeper status not yet available + inputPath: testdata/progressing_nostatus.yaml diff --git a/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/degraded_failed.yaml b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/degraded_failed.yaml new file mode 100644 index 0000000000..196d72c0bf --- /dev/null +++ b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/degraded_failed.yaml @@ -0,0 +1,22 @@ +apiVersion: clickhouse-keeper.altinity.com/v1 +kind: ClickHouseKeeperInstallation +metadata: + name: test-clickhouse-keeper + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9181 + template: + spec: + containers: + - name: clickhouse-keeper + image: clickhouse/clickhouse-keeper:latest +status: + status: Failed \ No newline at end of file diff --git a/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/healthy_completed.yaml b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/healthy_completed.yaml new file mode 100644 index 0000000000..c2a0c3198b --- /dev/null +++ b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/healthy_completed.yaml @@ -0,0 +1,22 @@ +apiVersion: clickhouse-keeper.altinity.com/v1 +kind: ClickHouseKeeperInstallation +metadata: + name: test-clickhouse-keeper + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9181 + template: + spec: + containers: + - name: clickhouse-keeper + image: clickhouse/clickhouse-keeper:latest +status: + status: Completed \ No newline at end of file diff --git a/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/progressing_inprogress.yaml b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/progressing_inprogress.yaml new file mode 100644 index 0000000000..eecac3af45 --- /dev/null +++ b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/progressing_inprogress.yaml @@ -0,0 +1,22 @@ +apiVersion: clickhouse-keeper.altinity.com/v1 +kind: ClickHouseKeeperInstallation +metadata: + name: test-clickhouse-keeper + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9181 + template: + spec: + containers: + - name: clickhouse-keeper + image: clickhouse/clickhouse-keeper:latest +status: + status: InProgress \ No newline at end of file diff --git a/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/progressing_nostatus.yaml b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/progressing_nostatus.yaml new file mode 100644 index 0000000000..48802e942a --- /dev/null +++ b/resource_customizations/clickhouse-keeper.altinity.com/ClickHouseKeeperInstallation/testdata/progressing_nostatus.yaml @@ -0,0 +1,20 @@ +apiVersion: clickhouse-keeper.altinity.com/v1 +kind: ClickHouseKeeperInstallation +metadata: + name: test-clickhouse-keeper + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9181 + template: + spec: + containers: + - name: clickhouse-keeper + image: clickhouse/clickhouse-keeper:latest \ No newline at end of file diff --git a/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/health.lua b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/health.lua new file mode 100644 index 0000000000..62835de866 --- /dev/null +++ b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/health.lua @@ -0,0 +1,17 @@ +local hs = {} +if obj.status ~= nil and obj.status.status ~= nil then + if obj.status.status == "Completed" then + hs.status = "Healthy" + hs.message = "ClickHouse installation completed successfully" + elseif obj.status.status == "InProgress" then + hs.status = "Progressing" + hs.message = "ClickHouse installation in progress" + else + hs.status = "Degraded" + hs.message = "ClickHouse status: " .. obj.status.status + end +else + hs.status = "Progressing" + hs.message = "ClickHouse status not yet available" +end +return hs \ No newline at end of file diff --git a/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/health_test.yaml b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/health_test.yaml new file mode 100644 index 0000000000..d69fc4ffa3 --- /dev/null +++ b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/health_test.yaml @@ -0,0 +1,17 @@ +tests: +- healthStatus: + status: Healthy + message: ClickHouse installation completed successfully + inputPath: testdata/healthy_completed.yaml +- healthStatus: + status: Progressing + message: ClickHouse installation in progress + inputPath: testdata/progressing_inprogress.yaml +- healthStatus: + status: Degraded + message: "ClickHouse status: Failed" + inputPath: testdata/degraded_failed.yaml +- healthStatus: + status: Progressing + message: ClickHouse status not yet available + inputPath: testdata/progressing_nostatus.yaml diff --git a/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/degraded_failed.yaml b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/degraded_failed.yaml new file mode 100644 index 0000000000..d64930a626 --- /dev/null +++ b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/degraded_failed.yaml @@ -0,0 +1,22 @@ +apiVersion: clickhouse.altinity.com/v1 +kind: ClickHouseInstallation +metadata: + name: test-clickhouse + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9000 + template: + spec: + containers: + - name: clickhouse + image: clickhouse/clickhouse-server:latest +status: + status: Failed diff --git a/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/healthy_completed.yaml b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/healthy_completed.yaml new file mode 100644 index 0000000000..425f72edb8 --- /dev/null +++ b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/healthy_completed.yaml @@ -0,0 +1,22 @@ +apiVersion: clickhouse.altinity.com/v1 +kind: ClickHouseInstallation +metadata: + name: test-clickhouse + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9000 + template: + spec: + containers: + - name: clickhouse + image: clickhouse/clickhouse-server:latest +status: + status: Completed diff --git a/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/progressing_inprogress.yaml b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/progressing_inprogress.yaml new file mode 100644 index 0000000000..0734e6eb6d --- /dev/null +++ b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/progressing_inprogress.yaml @@ -0,0 +1,22 @@ +apiVersion: clickhouse.altinity.com/v1 +kind: ClickHouseInstallation +metadata: + name: test-clickhouse + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9000 + template: + spec: + containers: + - name: clickhouse + image: clickhouse/clickhouse-server:latest +status: + status: InProgress \ No newline at end of file diff --git a/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/progressing_nostatus.yaml b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/progressing_nostatus.yaml new file mode 100644 index 0000000000..2b80530669 --- /dev/null +++ b/resource_customizations/clickhouse.altinity.com/ClickHouseInstallation/testdata/progressing_nostatus.yaml @@ -0,0 +1,20 @@ +apiVersion: clickhouse.altinity.com/v1 +kind: ClickHouseInstallation +metadata: + name: test-clickhouse + namespace: default +spec: + configuration: + clusters: + - name: cluster + layout: + shards: + - name: shard + replicas: + - name: replica + port: 9000 + template: + spec: + containers: + - name: clickhouse + image: clickhouse/clickhouse-server:latest \ No newline at end of file