kube_cluster 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5439cb8e1c5dcc7f1cb319b5523241aaa2a2fbc94e52e03e3316a7c383f435fd
4
- data.tar.gz: 8052cb7358d8b8846d3503dcc586c36b1dae29cc5ab8d4638bcbaf83de29b9a7
3
+ metadata.gz: '0768b58c75b80c58ddbe6bbae20aab3e57cad3a607058d7c2ebe64662d601f14'
4
+ data.tar.gz: b6260994b93ce8c91c897d6e44fb771fb2df82eebab158353485a8423ba9a61a
5
5
  SHA512:
6
- metadata.gz: f11d2e8c01f906b1b1f7999db505c3791fcf91496890c3b8a39d1f9660ea04d3d26812942a479a51572f3c27aff1ec8db22e92fe2c059aba5bb7787c8c410cd2
7
- data.tar.gz: f39b6d6878548cdea033d94978f487777b8f7537807e0884463df15d7edf2c47ba472556bff0ac245b1ed547e10ffa6eb88347528609039cd0af454f1177afd4
6
+ metadata.gz: 0d10e0cda8c7483ca5190dc2351cf12a4a9ea856a61498cc1b210c1ff431d0e20c1fbe1908520f05c799329e1304d10ec1cdb0dcc7a80cd550ad8d0fc1ea695d
7
+ data.tar.gz: ba7e0fcd06465f26a7d6197f41c4de71e713ebb06bde325433ac3dc41390ae7e95571e04cad35110f5cf4e17613262dae9189c8da3d35de4683b55537983ef7c
data/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.0] - 2026-07-13
9
+
10
+ ### Added
11
+ - `Standard::CloudNativePg::PostgresCluster` — the standard single-node
12
+ PostgreSQL cluster (custom image, HA replication slots, logical WAL,
13
+ barman-cloud WAL archiving) preconfigured; deployment-specific spec (managed
14
+ roles, etc.) via the block.
15
+
16
+ ## [1.2.1] - 2026-07-13
17
+
18
+ ### Added
19
+ - `Standard::CloudNativePg::Cluster` — a thin CloudNativePG `Cluster` CR wrapper
20
+ (sets `metadata.name`/`metadata.namespace`; the large, deployment-specific spec
21
+ is supplied via the block).
22
+
8
23
  ## [1.1.0] - 2026-07-13
9
24
 
10
25
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kube_cluster (1.1.0)
4
+ kube_cluster (1.3.0)
5
5
  activesupport (~> 8.0)
6
6
  kube_kubectl (~> 2.0)
7
7
  kube_schema (~> 1.9.2)
data/flake.nix CHANGED
@@ -22,6 +22,7 @@
22
22
  ];
23
23
 
24
24
  buildInputs = [
25
+ pkgs.trufflehog
25
26
  ruby
26
27
  pkgs.libyaml # psych gem
27
28
  pkgs.openssl # openssl gem
data/lefthook.yml CHANGED
@@ -1,9 +1,11 @@
1
1
  # Git hooks (managed by lefthook). Install with `bundle exec lefthook install`.
2
2
  #
3
- # Run the full test suite before every commit; a failing test blocks the
4
- # commit. Wrapped in `nix develop --command` because the hook fires outside the
5
- # flake devshell, so bundler/scampi wouldn't otherwise be on PATH.
3
+ # pre-commit: scan for secrets (trufflehog) and run the test suite (bin/test).
4
+ # Both are wrapped in `nix develop --command` because the hook fires outside the
5
+ # flake devshell, so trufflehog / bundler / scampi wouldn't otherwise be on PATH.
6
6
  pre-commit:
7
7
  commands:
8
+ secrets:
9
+ run: nix develop --command trufflehog git file://. --since-commit HEAD --only-verified --fail
8
10
  tests:
9
11
  run: nix develop --command bin/test
@@ -7,8 +7,17 @@ module Kube
7
7
  module Cluster
8
8
  module Standard
9
9
  module CloudNativePg
10
- #class Cluster < Kube::Cluster["Cluster"]
11
- #end
10
+ # A CloudNativePG Cluster CR. Thin wrapper: sets metadata, leaves the
11
+ # (large, deployment-specific) spec to the block.
12
+ class Cluster < Kube::Cluster["Cluster"]
13
+ def initialize(name: "postgres", namespace: nil, &block)
14
+ super() {
15
+ metadata.name = name
16
+ metadata.namespace = namespace if namespace
17
+ instance_exec(&block) if block
18
+ }
19
+ end
20
+ end
12
21
  end
13
22
  end
14
23
  end
@@ -16,12 +25,15 @@ end
16
25
 
17
26
  __END__
18
27
 
19
- #describe "CloudNativePg::Cluster" do
20
- # it "initializes without error" do
21
- # Kube::Cluster::Standard::CloudNativePg::Cluster
22
- # .new()
23
- # .to_yaml
24
- # .is_a?(String)
25
- # .should == true
26
- # end
27
- #end
28
+ describe "CloudNativePg::Cluster" do
29
+ it "initializes without error" do
30
+ Kube::Cluster::Standard::CloudNativePg::Cluster
31
+ .new(name: "postgres", namespace: "cloudnative-pg") {
32
+ spec.instances = 1
33
+ spec.storage = { size: "1Gi" }
34
+ }
35
+ .to_yaml
36
+ .is_a?(String)
37
+ .should == true
38
+ end
39
+ end
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "kube/cluster"
5
+ require "kube/cluster/standard/cloud_native_pg/cluster"
6
+
7
+ module Kube
8
+ module Cluster
9
+ module Standard
10
+ module CloudNativePg
11
+ # The standard single-node PostgreSQL cluster: custom image, HA
12
+ # replication slots, logical WAL, and barman-cloud WAL archiving.
13
+ # Deployment-specific additions (managed roles, extra spec) come via the
14
+ # block; databases are separate Database CRs.
15
+ class PostgresCluster < Cluster
16
+ def initialize(name: "postgres", namespace: nil, &block)
17
+ super(name: name, namespace: namespace) {
18
+ spec.affinity = { podAntiAffinityType: "preferred" }
19
+ spec.bootstrap = {
20
+ initdb: {
21
+ database: "app",
22
+ encoding: "UTF8",
23
+ localeCType: "C",
24
+ localeCollate: "C",
25
+ owner: "app",
26
+ },
27
+ }
28
+ spec.enablePDB = true
29
+ spec.enableSuperuserAccess = false
30
+ spec.failoverDelay = 0
31
+ spec.imageName = "ghcr.io/general-intelligence-systems/postgresql:17-custom"
32
+ spec.imagePullPolicy = "Always"
33
+ spec.instances = 1
34
+ spec.plugins = [{
35
+ name: "barman-cloud.cloudnative-pg.io",
36
+ isWALArchiver: true,
37
+ parameters: { barmanObjectName: "cnpg-backups" },
38
+ }]
39
+ spec.logLevel = "info"
40
+ spec.maxSyncReplicas = 0
41
+ spec.minSyncReplicas = 0
42
+ spec.monitoring = {
43
+ disableDefaultQueries: false,
44
+ enablePodMonitor: false,
45
+ }
46
+ spec.postgresGID = 26
47
+ spec.postgresUID = 26
48
+ spec.postgresql = {
49
+ parameters: {
50
+ archive_mode: "on",
51
+ archive_timeout: "5min",
52
+ dynamic_shared_memory_type: "posix",
53
+ full_page_writes: "on",
54
+ log_destination: "csvlog",
55
+ log_directory: "/controller/log",
56
+ log_filename: "postgres",
57
+ log_rotation_age: "0",
58
+ log_rotation_size: "0",
59
+ log_truncate_on_rotation: "false",
60
+ logging_collector: "on",
61
+ max_parallel_workers: "32",
62
+ max_replication_slots: "32",
63
+ max_worker_processes: "32",
64
+ shared_memory_type: "mmap",
65
+ shared_preload_libraries: "",
66
+ ssl_max_protocol_version: "TLSv1.3",
67
+ ssl_min_protocol_version: "TLSv1.3",
68
+ wal_keep_size: "512MB",
69
+ wal_level: "logical",
70
+ wal_log_hints: "on",
71
+ wal_receiver_timeout: "5s",
72
+ wal_sender_timeout: "5s",
73
+ },
74
+ syncReplicaElectionConstraint: {
75
+ enabled: false,
76
+ },
77
+ }
78
+ spec.primaryUpdateMethod = "restart"
79
+ spec.primaryUpdateStrategy = "unsupervised"
80
+ spec.probes = {
81
+ liveness: {
82
+ isolationCheck: {
83
+ connectionTimeout: 1000,
84
+ enabled: true,
85
+ requestTimeout: 1000,
86
+ },
87
+ },
88
+ }
89
+ spec.replicationSlots = {
90
+ highAvailability: {
91
+ enabled: true,
92
+ slotPrefix: "_cnpg_",
93
+ },
94
+ synchronizeReplicas: {
95
+ enabled: true,
96
+ },
97
+ updateInterval: 30,
98
+ }
99
+ spec.resources = {}
100
+ spec.smartShutdownTimeout = 180
101
+ spec.startDelay = 3600
102
+ spec.stopDelay = 1800
103
+ spec.storage = {
104
+ resizeInUseVolumes: true,
105
+ size: "5Gi",
106
+ }
107
+ spec.switchoverDelay = 3600
108
+
109
+ instance_exec(&block) if block
110
+ }
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ __END__
119
+
120
+ describe "CloudNativePg::PostgresCluster" do
121
+ it "initializes without error" do
122
+ Kube::Cluster::Standard::CloudNativePg::PostgresCluster
123
+ .new(namespace: "cloudnative-pg")
124
+ .to_yaml
125
+ .is_a?(String)
126
+ .should == true
127
+ end
128
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kube
4
4
  module Cluster
5
- VERSION = "1.1.0"
5
+ VERSION = "1.3.0"
6
6
  end
7
7
  end
data/lib/kube/cluster.rb CHANGED
@@ -109,6 +109,7 @@ Kube::Cluster.config do
109
109
  resolve "DecoratorController", to: "metacontroller.k8s.io/v1alpha1/DecoratorController"
110
110
 
111
111
  # CloudNativePG.
112
+ resolve "Cluster", to: "postgresql.cnpg.io/v1/Cluster"
112
113
  resolve "Database", to: "postgresql.cnpg.io/v1/Database"
113
114
 
114
115
  # External Secrets Operator.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K
@@ -219,6 +219,7 @@ files:
219
219
  - lib/kube/cluster/standard/cloud_native_pg/database_with_external_secret.rb
220
220
  - lib/kube/cluster/standard/cloud_native_pg/external_secret.rb
221
221
  - lib/kube/cluster/standard/cloud_native_pg/helm.rb
222
+ - lib/kube/cluster/standard/cloud_native_pg/postgres_cluster.rb
222
223
  - lib/kube/cluster/standard/config_map.rb
223
224
  - lib/kube/cluster/standard/cron_job.rb
224
225
  - lib/kube/cluster/standard/cron_job_with_service_account.rb