Skip to content

Commit 7842348

Browse files
Implement product image selection (#281)
# Description - [x] Implement product image selection - [x] Remove tools image usage Co-authored-by: maltesander <malte.sander.it@gmail.com>
1 parent 0ccbaa2 commit 7842348

File tree

16 files changed

+208
-64
lines changed

16 files changed

+208
-64
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ All notable changes to this project will be documented in this file.
66

77
### Changed
88

9+
- [BREAKING] Use Product image selection instead of version. `spec.version` has been replaced by `spec.image` ([#281]).
910
- Updated stackable image versions ([#271])
1011
- `operator-rs` `0.25.2` -> `0.27.1` ([#276])
1112

1213
[#271]: https://github.com/stackabletech/hdfs-operator/pull/271
1314
[#276]: https://github.com/stackabletech/hdfs-operator/pull/276
15+
[#281]: https://github.com/stackabletech/hdfs-operator/pull/281
1416

1517
## [0.6.0] - 2022-11-07
1618

deploy/crd/hdfscluster.crd.yaml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,48 @@ spec:
513513
minimum: 0.0
514514
nullable: true
515515
type: integer
516+
image:
517+
anyOf:
518+
- required:
519+
- custom
520+
- productVersion
521+
- required:
522+
- productVersion
523+
- stackableVersion
524+
properties:
525+
custom:
526+
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
527+
type: string
528+
productVersion:
529+
description: Version of the product, e.g. `1.4.1`.
530+
type: string
531+
pullPolicy:
532+
default: IfNotPresent
533+
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
534+
enum:
535+
- IfNotPresent
536+
- Always
537+
- Never
538+
type: string
539+
pullSecrets:
540+
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
541+
items:
542+
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
543+
properties:
544+
name:
545+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
546+
type: string
547+
type: object
548+
nullable: true
549+
type: array
550+
repo:
551+
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
552+
nullable: true
553+
type: string
554+
stackableVersion:
555+
description: Stackable version of the product, e.g. 2.1.0
556+
type: string
557+
type: object
516558
journalNodes:
517559
nullable: true
518560
properties:
@@ -1482,12 +1524,10 @@ spec:
14821524
required:
14831525
- roleGroups
14841526
type: object
1485-
version:
1486-
nullable: true
1487-
type: string
14881527
zookeeperConfigMapName:
14891528
type: string
14901529
required:
1530+
- image
14911531
- zookeeperConfigMapName
14921532
type: object
14931533
required:

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

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,48 @@ spec:
515515
minimum: 0.0
516516
nullable: true
517517
type: integer
518+
image:
519+
anyOf:
520+
- required:
521+
- custom
522+
- productVersion
523+
- required:
524+
- productVersion
525+
- stackableVersion
526+
properties:
527+
custom:
528+
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
529+
type: string
530+
productVersion:
531+
description: Version of the product, e.g. `1.4.1`.
532+
type: string
533+
pullPolicy:
534+
default: IfNotPresent
535+
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
536+
enum:
537+
- IfNotPresent
538+
- Always
539+
- Never
540+
type: string
541+
pullSecrets:
542+
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
543+
items:
544+
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
545+
properties:
546+
name:
547+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
548+
type: string
549+
type: object
550+
nullable: true
551+
type: array
552+
repo:
553+
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
554+
nullable: true
555+
type: string
556+
stackableVersion:
557+
description: Stackable version of the product, e.g. 2.1.0
558+
type: string
559+
type: object
518560
journalNodes:
519561
nullable: true
520562
properties:
@@ -1484,12 +1526,10 @@ spec:
14841526
required:
14851527
- roleGroups
14861528
type: object
1487-
version:
1488-
nullable: true
1489-
type: string
14901529
zookeeperConfigMapName:
14911530
type: string
14921531
required:
1532+
- image
14931533
- zookeeperConfigMapName
14941534
type: object
14951535
required:

deploy/manifests/crds.yaml

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,48 @@ spec:
516516
minimum: 0.0
517517
nullable: true
518518
type: integer
519+
image:
520+
anyOf:
521+
- required:
522+
- custom
523+
- productVersion
524+
- required:
525+
- productVersion
526+
- stackableVersion
527+
properties:
528+
custom:
529+
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
530+
type: string
531+
productVersion:
532+
description: Version of the product, e.g. `1.4.1`.
533+
type: string
534+
pullPolicy:
535+
default: IfNotPresent
536+
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
537+
enum:
538+
- IfNotPresent
539+
- Always
540+
- Never
541+
type: string
542+
pullSecrets:
543+
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
544+
items:
545+
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
546+
properties:
547+
name:
548+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
549+
type: string
550+
type: object
551+
nullable: true
552+
type: array
553+
repo:
554+
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
555+
nullable: true
556+
type: string
557+
stackableVersion:
558+
description: Stackable version of the product, e.g. 2.1.0
559+
type: string
560+
type: object
519561
journalNodes:
520562
nullable: true
521563
properties:
@@ -1485,12 +1527,10 @@ spec:
14851527
required:
14861528
- roleGroups
14871529
type: object
1488-
version:
1489-
nullable: true
1490-
type: string
14911530
zookeeperConfigMapName:
14921531
type: string
14931532
required:
1533+
- image
14941534
- zookeeperConfigMapName
14951535
type: object
14961536
required:

docs/modules/ROOT/pages/usage.adoc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ kind: ZookeeperCluster
1313
metadata:
1414
name: simple-zk
1515
spec:
16-
version: 3.5.8-stackable0.8.0
16+
image:
17+
productVersion: 3.5.8
18+
stackableVersion: 0.8.0
1719
servers:
1820
roleGroups:
1921
default:
@@ -45,7 +47,9 @@ kind: HdfsCluster
4547
metadata:
4648
name: simple
4749
spec:
48-
version: 3.3.4-stackable0.2.0
50+
image:
51+
productVersion: 3.3.4
52+
stackableVersion: 0.2.0
4953
zookeeperConfigMapName: simple-znode
5054
dfsReplication: 3
5155
nameNodes:

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-hdfs-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/constants.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ pub const FIELD_MANAGER_SCOPE_POD: &str = "pod-service";
77

88
pub const APP_NAME: &str = "hdfs";
99

10-
pub const TOOLS_IMAGE: &str = "docker.stackable.tech/stackable/tools:0.1.0-stackable0";
11-
1210
pub const LABEL_ENABLE: &str = "hdfs.stackable.tech/pod-service";
1311
pub const LABEL_STS_POD_NAME: &str = "statefulset.kubernetes.io/pod-name";
1412

rust/crd/src/lib.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use constants::*;
55
use error::{Error, HdfsOperatorResult};
66
use lazy_static::lazy_static;
77
use serde::{Deserialize, Serialize};
8+
use stackable_operator::commons::product_image_selection::ProductImage;
89
use stackable_operator::commons::resources::{NoRuntimeLimits, PvcConfig, Resources};
910
use stackable_operator::commons::resources::{
1011
NoRuntimeLimitsFragment, PvcConfigFragment, ResourcesFragment,
@@ -43,7 +44,7 @@ use stackable_operator::config::fragment;
4344
)]
4445
#[serde(rename_all = "camelCase")]
4546
pub struct HdfsClusterSpec {
46-
pub version: Option<String>,
47+
pub image: ProductImage,
4748
pub auto_format_fs: Option<bool>,
4849
pub zookeeper_config_map_name: String,
4950
pub data_nodes: Option<Role<DataNodeConfig>>,
@@ -171,22 +172,6 @@ lazy_static! {
171172
}
172173

173174
impl HdfsCluster {
174-
pub fn hdfs_version(&self) -> HdfsOperatorResult<&str> {
175-
self.spec
176-
.version
177-
.as_deref()
178-
.ok_or(Error::ObjectHasNoVersion {
179-
obj_ref: ObjectRef::from_obj(self),
180-
})
181-
}
182-
183-
pub fn hdfs_image(&self) -> HdfsOperatorResult<String> {
184-
Ok(format!(
185-
"docker.stackable.tech/stackable/hadoop:{}",
186-
self.hdfs_version()?
187-
))
188-
}
189-
190175
/// Kubernetes labels to attach to Pods within a role group.
191176
///
192177
/// The same labels are also used as selectors for Services and StatefulSets.
@@ -697,7 +682,9 @@ kind: HdfsCluster
697682
metadata:
698683
name: hdfs
699684
spec:
700-
version: 3.2.2
685+
image:
686+
productVersion: 3.3.4
687+
stackableVersion: 0.2.0
701688
zookeeperConfigMapName: hdfs-zk
702689
dfsReplication: 1
703690
log4j: |-
@@ -759,7 +746,9 @@ kind: HdfsCluster
759746
metadata:
760747
name: hdfs
761748
spec:
762-
version: 3.2.2
749+
image:
750+
productVersion: 3.3.4
751+
stackableVersion: 0.2.0
763752
zookeeperConfigMapName: hdfs-zk
764753
dfsReplication: 1
765754
log4j: |-
@@ -823,7 +812,9 @@ kind: HdfsCluster
823812
metadata:
824813
name: hdfs
825814
spec:
826-
version: 3.2.2
815+
image:
816+
productVersion: 3.3.4
817+
stackableVersion: 0.2.0
827818
zookeeperConfigMapName: hdfs-zk
828819
dfsReplication: 1
829820
log4j: |-
@@ -882,7 +873,9 @@ kind: HdfsCluster
882873
metadata:
883874
name: hdfs
884875
spec:
885-
version: 3.2.2
876+
image:
877+
productVersion: 3.3.4
878+
stackableVersion: 0.2.0
886879
zookeeperConfigMapName: hdfs-zk
887880
dfsReplication: 1
888881
log4j: |-
@@ -951,7 +944,9 @@ kind: HdfsCluster
951944
metadata:
952945
name: hdfs
953946
spec:
954-
version: 3.2.2
947+
image:
948+
productVersion: 3.3.4
949+
stackableVersion: 0.2.0
955950
zookeeperConfigMapName: hdfs-zk
956951
dfsReplication: 1
957952
log4j: |-

rust/operator/src/discovery.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use stackable_hdfs_crd::{
66
constants::{CORE_SITE_XML, HDFS_SITE_XML},
77
HdfsCluster, HdfsPodRef, HdfsRole,
88
};
9-
use stackable_operator::error::{Error, OperatorResult};
109
use stackable_operator::{
1110
builder::{ConfigMapBuilder, ObjectMetaBuilder},
11+
commons::product_image_selection::ResolvedProductImage,
12+
error::OperatorResult,
1213
k8s_openapi::api::core::v1::ConfigMap,
1314
kube::ResourceExt,
1415
};
@@ -19,6 +20,7 @@ pub fn build_discovery_configmap(
1920
hdfs: &HdfsCluster,
2021
controller: &str,
2122
namenode_podrefs: &[HdfsPodRef],
23+
resolved_product_image: &ResolvedProductImage,
2224
) -> OperatorResult<ConfigMap> {
2325
ConfigMapBuilder::new()
2426
.metadata(
@@ -28,8 +30,7 @@ pub fn build_discovery_configmap(
2830
.with_recommended_labels(build_recommended_labels(
2931
hdfs,
3032
controller,
31-
hdfs.hdfs_version()
32-
.map_err(|_| Error::MissingObjectKey { key: "version" })?,
33+
&resolved_product_image.app_version_label,
3334
&HdfsRole::NameNode.to_string(),
3435
"discovery",
3536
))

0 commit comments

Comments
 (0)