Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Product image selection #385

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ All notable changes to this project will be documented in this file.
- Updated stackable image versions ([#374]).
- `operator-rs` `0.22.0` -> `0.27.1` ([#377]).
- Don't run init container as root and avoid chmod and chowning ([#382]).
- [BREAKING] Use Product image selection instead of version. `spec.version` has been replaced by `spec.image` ([#385]).

[#374]: https://github.com/stackabletech/opa-operator/pull/374
[#377]: https://github.com/stackabletech/opa-operator/pull/377
[#382]: https://github.com/stackabletech/opa-operator/pull/382
[#385]: https://github.com/stackabletech/opa-operator/pull/385

## [0.11.0] - 2022-11-07

Expand Down
46 changes: 43 additions & 3 deletions deploy/crd/opacluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,48 @@ spec:
properties:
spec:
properties:
image:
anyOf:
- required:
- custom
- productVersion
- required:
- productVersion
- stackableVersion
properties:
custom:
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
type: string
productVersion:
description: Version of the product, e.g. `1.4.1`.
type: string
pullPolicy:
default: IfNotPresent
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
enum:
- IfNotPresent
- Always
- Never
type: string
pullSecrets:
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
items:
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
type: object
nullable: true
type: array
repo:
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
nullable: true
type: string
stackableVersion:
description: Stackable version of the product, e.g. 2.1.0
type: string
type: object
servers:
properties:
cliOverrides:
Expand Down Expand Up @@ -357,10 +399,8 @@ spec:
stopped:
nullable: true
type: boolean
version:
nullable: true
type: string
required:
- image
- servers
type: object
required:
Expand Down
46 changes: 43 additions & 3 deletions deploy/helm/opa-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,48 @@ spec:
properties:
spec:
properties:
image:
anyOf:
- required:
- custom
- productVersion
- required:
- productVersion
- stackableVersion
properties:
custom:
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
type: string
productVersion:
description: Version of the product, e.g. `1.4.1`.
type: string
pullPolicy:
default: IfNotPresent
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
enum:
- IfNotPresent
- Always
- Never
type: string
pullSecrets:
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
items:
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
type: object
nullable: true
type: array
repo:
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
nullable: true
type: string
stackableVersion:
description: Stackable version of the product, e.g. 2.1.0
type: string
type: object
servers:
properties:
cliOverrides:
Expand Down Expand Up @@ -359,10 +401,8 @@ spec:
stopped:
nullable: true
type: boolean
version:
nullable: true
type: string
required:
- image
- servers
type: object
required:
Expand Down
46 changes: 43 additions & 3 deletions deploy/manifests/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,48 @@ spec:
properties:
spec:
properties:
image:
anyOf:
- required:
- custom
- productVersion
- required:
- productVersion
- stackableVersion
properties:
custom:
description: Overwrite the docker image. Specify the full docker image name, e.g. `docker.stackable.tech/stackable/superset:1.4.1-stackable2.1.0`
type: string
productVersion:
description: Version of the product, e.g. `1.4.1`.
type: string
pullPolicy:
default: IfNotPresent
description: '[Pull policy](https://kubernetes.io/docs/concepts/containers/images/#image-pull-policy) used when pulling the Images'
enum:
- IfNotPresent
- Always
- Never
type: string
pullSecrets:
description: '[Image pull secrets](https://kubernetes.io/docs/concepts/containers/images/#specifying-imagepullsecrets-on-a-pod) to pull images from a private registry'
items:
description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
type: object
nullable: true
type: array
repo:
description: Name of the docker repo, e.g. `docker.stackable.tech/stackable`
nullable: true
type: string
stackableVersion:
description: Stackable version of the product, e.g. 2.1.0
type: string
type: object
servers:
properties:
cliOverrides:
Expand Down Expand Up @@ -360,10 +402,8 @@ spec:
stopped:
nullable: true
type: boolean
version:
nullable: true
type: string
required:
- image
- servers
type: object
required:
Expand Down
4 changes: 3 additions & 1 deletion docs/modules/ROOT/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ To create a single node OPA (v0.45.0) cluster with Prometheus metrics exposed on
metadata:
name: simple-opa
spec:
version: "0.45.0-stackable0.2.0"
image:
productVersion: 0.45.0
stackableVersion: 0.2.0
servers:
roleGroups:
default:
Expand Down
4 changes: 3 additions & 1 deletion docs/modules/getting_started/examples/code/opa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ kind: OpaCluster
metadata:
name: simple-opa
spec:
version: "0.45.0-stackable0.2.0"
image:
productVersion: 0.45.0
stackableVersion: 0.2.0
servers:
roleGroups:
default:
Expand Down
2 changes: 0 additions & 2 deletions rust/bundle-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ const BUNDLE_BUILDER_CONTROLLER_NAME: &str = "bundlebuilder";
#[strum_discriminants(derive(IntoStaticStr))]
#[allow(clippy::enum_variant_names)]
pub enum Error {
#[snafu(display("object defines no version"))]
ObjectHasNoVersion,
#[snafu(display("opa bundle has no name"))]
OpaBundleHasNoName,
#[snafu(display("opa bundle dir error"))]
Expand Down
24 changes: 8 additions & 16 deletions rust/crd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use serde::{Deserialize, Serialize};
use snafu::{OptionExt, ResultExt, Snafu};
use snafu::{ResultExt, Snafu};
use stackable_operator::{
commons::resources::{
CpuLimitsFragment, MemoryLimitsFragment, NoRuntimeLimits, NoRuntimeLimitsFragment,
Resources, ResourcesFragment,
commons::{
product_image_selection::ProductImage,
resources::{
CpuLimitsFragment, MemoryLimitsFragment, NoRuntimeLimits, NoRuntimeLimitsFragment,
Resources, ResourcesFragment,
},
},
config::{fragment, fragment::Fragment, fragment::ValidationError, merge::Merge},
k8s_openapi::apimachinery::pkg::api::resource::Quantity,
Expand All @@ -23,8 +26,6 @@ pub const CONFIG_FILE: &str = "config.yaml";

#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("object defines no version"))]
ObjectHasNoVersion,
#[snafu(display("fragment validation failure"))]
FragmentValidationFailure { source: ValidationError },
}
Expand All @@ -47,8 +48,7 @@ pub struct OpaSpec {
pub servers: Role<OpaConfig>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub stopped: Option<bool>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
pub image: ProductImage,
}

#[allow(clippy::derive_partial_eq_without_eq)]
Expand Down Expand Up @@ -141,14 +141,6 @@ pub enum OpaRole {
}

impl OpaCluster {
/// The image version provided in the `spec.version` field
pub fn image_version(&self) -> Result<&str, Error> {
self.spec
.version
.as_deref()
.context(ObjectHasNoVersionSnafu)
}

/// The name of the role-level load-balanced Kubernetes `Service`
pub fn server_role_service_name(&self) -> Option<String> {
self.metadata.name.clone()
Expand Down
Loading