Skip to content

Commit 97e96bf

Browse files
committed
Implement product image selection (#282)
# Description test: https://ci.stackable.tech/view/02%20Operator%20Tests%20(custom)/job/hbase-operator-it-custom/63/ Co-authored-by: maltesander <malte.sander.it@gmail.com>
1 parent 936e548 commit 97e96bf

20 files changed

Lines changed: 225 additions & 62 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
- Updated stackable image versions ([#275]).
88
- `operator-rs` `0.24.0` -> `0.27.1` ([#277]).
9+
- [BREAKING] Use Product image selection instead of version. `spec.version` has been replaced by `spec.image` ([#282]).
910

1011
[#275]: https://github.com/stackabletech/hbase-operator/pull/275
1112
[#277]: https://github.com/stackabletech/hbase-operator/pull/277
13+
[#282]: https://github.com/stackabletech/hbase-operator/pull/282
1214

1315
## [0.5.0] - 2022-11-07
1416

deploy/crd/hbasecluster.crd.yaml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,51 @@ spec:
155155
type: object
156156
type: object
157157
hdfsConfigMapName:
158+
description: HDFS cluster connection details from discovery config map
158159
type: string
160+
image:
161+
anyOf:
162+
- required:
163+
- custom
164+
- productVersion
165+
- required:
166+
- productVersion
167+
- stackableVersion
168+
description: Desired HBase image
169+
properties:
170+
custom:
171+
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
172+
type: string
173+
productVersion:
174+
description: Version of the product, e.g. `1.4.1`.
175+
type: string
176+
pullPolicy:
177+
default: IfNotPresent
178+
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
179+
enum:
180+
- IfNotPresent
181+
- Always
182+
- Never
183+
type: string
184+
pullSecrets:
185+
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
186+
items:
187+
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
188+
properties:
189+
name:
190+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
191+
type: string
192+
type: object
193+
nullable: true
194+
type: array
195+
repo:
196+
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
197+
nullable: true
198+
type: string
199+
stackableVersion:
200+
description: Stackable version of the product, e.g. 2.1.0
201+
type: string
202+
type: object
159203
masters:
160204
nullable: true
161205
properties:
@@ -1195,14 +1239,12 @@ spec:
11951239
description: Emergency stop button, if `true` then all pods are stopped without affecting configuration (as setting `replicas` to `0` would)
11961240
nullable: true
11971241
type: boolean
1198-
version:
1199-
description: Desired HBase version
1200-
nullable: true
1201-
type: string
12021242
zookeeperConfigMapName:
1243+
description: ZooKeeper cluster connection details from discovery config map
12031244
type: string
12041245
required:
12051246
- hdfsConfigMapName
1247+
- image
12061248
- zookeeperConfigMapName
12071249
type: object
12081250
status:

deploy/helm/hbase-operator/crds/crds.yaml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,51 @@ spec:
157157
type: object
158158
type: object
159159
hdfsConfigMapName:
160+
description: HDFS cluster connection details from discovery config map
160161
type: string
162+
image:
163+
anyOf:
164+
- required:
165+
- custom
166+
- productVersion
167+
- required:
168+
- productVersion
169+
- stackableVersion
170+
description: Desired HBase image
171+
properties:
172+
custom:
173+
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
174+
type: string
175+
productVersion:
176+
description: Version of the product, e.g. `1.4.1`.
177+
type: string
178+
pullPolicy:
179+
default: IfNotPresent
180+
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
181+
enum:
182+
- IfNotPresent
183+
- Always
184+
- Never
185+
type: string
186+
pullSecrets:
187+
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
188+
items:
189+
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
190+
properties:
191+
name:
192+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
193+
type: string
194+
type: object
195+
nullable: true
196+
type: array
197+
repo:
198+
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
199+
nullable: true
200+
type: string
201+
stackableVersion:
202+
description: Stackable version of the product, e.g. 2.1.0
203+
type: string
204+
type: object
161205
masters:
162206
nullable: true
163207
properties:
@@ -1197,14 +1241,12 @@ spec:
11971241
description: Emergency stop button, if `true` then all pods are stopped without affecting configuration (as setting `replicas` to `0` would)
11981242
nullable: true
11991243
type: boolean
1200-
version:
1201-
description: Desired HBase version
1202-
nullable: true
1203-
type: string
12041244
zookeeperConfigMapName:
1245+
description: ZooKeeper cluster connection details from discovery config map
12051246
type: string
12061247
required:
12071248
- hdfsConfigMapName
1249+
- image
12081250
- zookeeperConfigMapName
12091251
type: object
12101252
status:

deploy/manifests/crds.yaml

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,51 @@ spec:
158158
type: object
159159
type: object
160160
hdfsConfigMapName:
161+
description: HDFS cluster connection details from discovery config map
161162
type: string
163+
image:
164+
anyOf:
165+
- required:
166+
- custom
167+
- productVersion
168+
- required:
169+
- productVersion
170+
- stackableVersion
171+
description: Desired HBase image
172+
properties:
173+
custom:
174+
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
175+
type: string
176+
productVersion:
177+
description: Version of the product, e.g. `1.4.1`.
178+
type: string
179+
pullPolicy:
180+
default: IfNotPresent
181+
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
182+
enum:
183+
- IfNotPresent
184+
- Always
185+
- Never
186+
type: string
187+
pullSecrets:
188+
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
189+
items:
190+
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
191+
properties:
192+
name:
193+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
194+
type: string
195+
type: object
196+
nullable: true
197+
type: array
198+
repo:
199+
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
200+
nullable: true
201+
type: string
202+
stackableVersion:
203+
description: Stackable version of the product, e.g. 2.1.0
204+
type: string
205+
type: object
162206
masters:
163207
nullable: true
164208
properties:
@@ -1198,14 +1242,12 @@ spec:
11981242
description: Emergency stop button, if `true` then all pods are stopped without affecting configuration (as setting `replicas` to `0` would)
11991243
nullable: true
12001244
type: boolean
1201-
version:
1202-
description: Desired HBase version
1203-
nullable: true
1204-
type: string
12051245
zookeeperConfigMapName:
1246+
description: ZooKeeper cluster connection details from discovery config map
12061247
type: string
12071248
required:
12081249
- hdfsConfigMapName
1250+
- image
12091251
- zookeeperConfigMapName
12101252
type: object
12111253
status:

docs/modules/ROOT/pages/usage.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ kind: HbaseCluster
1717
metadata:
1818
name: simple-hbase
1919
spec:
20-
version: 2.4.12-stackable0.3.0
20+
image:
21+
productVersion: 2.4.12
22+
stackableVersion: 0.3.0
2123
hdfsConfigMapName: simple-hdfs-namenode-default
2224
zookeeperConfigMapName: simple-hbase-znode
2325
config:

docs/modules/getting_started/examples/code/hbase.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ kind: HbaseCluster
44
metadata:
55
name: simple-hbase
66
spec:
7-
version: 2.4.12-stackable0.3.0
7+
image:
8+
productVersion: 2.4.12
9+
stackableVersion: 0.3.0
810
hdfsConfigMapName: simple-hdfs
911
zookeeperConfigMapName: simple-znode
1012
config:

docs/modules/getting_started/examples/code/hdfs.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ kind: HdfsCluster
44
metadata:
55
name: simple-hdfs
66
spec:
7-
version: 3.3.4-stackable0.2.0
7+
image:
8+
productVersion: 3.3.4
9+
stackableVersion: 0.2.0
810
zookeeperConfigMapName: simple-znode
911
dfsReplication: 3
1012
nameNodes:

docs/modules/getting_started/examples/code/zk.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ kind: ZookeeperCluster
44
metadata:
55
name: simple-zk
66
spec:
7-
version: 3.8.0-stackable0.8.0
7+
image:
8+
productVersion: 3.8.0
9+
stackableVersion: 0.8.0
810
servers:
911
roleGroups:
1012
default:

rust/crd/src/lib.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
use serde::{Deserialize, Serialize};
22
use snafu::{OptionExt, ResultExt, Snafu};
33
use stackable_operator::{
4-
commons::resources::{
5-
CpuLimitsFragment, MemoryLimitsFragment, NoRuntimeLimits, NoRuntimeLimitsFragment,
6-
Resources, ResourcesFragment,
4+
commons::{
5+
product_image_selection::ProductImage,
6+
resources::{
7+
CpuLimitsFragment, MemoryLimitsFragment, NoRuntimeLimits, NoRuntimeLimitsFragment,
8+
Resources, ResourcesFragment,
9+
},
710
},
811
config::{fragment, fragment::Fragment, fragment::ValidationError, merge::Merge},
912
k8s_openapi::apimachinery::pkg::api::resource::Quantity,
@@ -50,7 +53,7 @@ pub enum Error {
5053
FragmentValidationFailure { source: ValidationError },
5154
}
5255

53-
#[derive(Clone, CustomResource, Debug, Default, Deserialize, JsonSchema, PartialEq, Serialize)]
56+
#[derive(Clone, CustomResource, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
5457
#[kube(
5558
group = "hbase.stackable.tech",
5659
version = "v1alpha1",
@@ -70,10 +73,11 @@ pub struct HbaseClusterSpec {
7073
/// Emergency stop button, if `true` then all pods are stopped without affecting configuration (as setting `replicas` to `0` would)
7174
#[serde(default, skip_serializing_if = "Option::is_none")]
7275
pub stopped: Option<bool>,
73-
/// Desired HBase version
74-
#[serde(default, skip_serializing_if = "Option::is_none")]
75-
pub version: Option<String>,
76+
/// Desired HBase image
77+
pub image: ProductImage,
78+
/// ZooKeeper cluster connection details from discovery config map
7679
pub zookeeper_config_map_name: String,
80+
/// HDFS cluster connection details from discovery config map
7781
pub hdfs_config_map_name: String,
7882
#[serde(default, skip_serializing_if = "Option::is_none")]
7983
pub config: Option<HbaseConfig>,

rust/operator-binary/src/discovery.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
use crate::hbase_controller::{build_recommended_labels, hbase_version};
1+
use crate::hbase_controller::build_recommended_labels;
22
use stackable_hbase_crd::{HbaseCluster, HbaseRole, HBASE_SITE_XML, HBASE_ZOOKEEPER_QUORUM};
33
use stackable_operator::{
44
builder::{ConfigMapBuilder, ObjectMetaBuilder},
5-
error::{Error, OperatorResult},
5+
commons::product_image_selection::ResolvedProductImage,
6+
error::OperatorResult,
67
k8s_openapi::api::core::v1::ConfigMap,
78
};
89
use std::collections::HashMap;
@@ -11,6 +12,7 @@ use std::collections::HashMap;
1112
pub fn build_discovery_configmap(
1213
hbase: &HbaseCluster,
1314
zookeeper_connect_string: &str,
15+
resolved_product_image: &ResolvedProductImage,
1416
) -> OperatorResult<ConfigMap> {
1517
let hbase_site_data: HashMap<String, Option<String>> = [(
1618
HBASE_ZOOKEEPER_QUORUM.to_string(),
@@ -25,7 +27,7 @@ pub fn build_discovery_configmap(
2527
.ownerreference_from_resource(hbase, None, Some(true))?
2628
.with_recommended_labels(build_recommended_labels(
2729
hbase,
28-
hbase_version(hbase).map_err(|_| Error::MissingObjectKey { key: "version" })?,
30+
&resolved_product_image.app_version_label,
2931
&HbaseRole::RegionServer.to_string(),
3032
"discovery",
3133
))

0 commit comments

Comments
 (0)