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

Add support for OKE as an OpenShift flavor #209

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 2 additions & 5 deletions component/alertrules.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ local ignore_alerts = std.set(
local runbook(alertname) =
'https://hub.syn.tools/rook-ceph/runbooks/%s.html' % alertname;

local on_openshift =
inv.parameters.facts.distribution == 'openshift4';

local alertpatching =
if on_openshift then
if helpers.on_openshift then
import 'lib/alert-patching.libsonnet'
else
local patchRule(rule, patches={}, patch_name=true) =
Expand Down Expand Up @@ -91,7 +88,7 @@ local alertpatching =
);

local prom =
if on_openshift then
if helpers.on_openshift then
import 'lib/prom.libsonnet'
else
std.trace(
Expand Down
8 changes: 3 additions & 5 deletions component/cephcluster.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ local params = inv.parameters.rook_ceph;

local helpers = import 'helpers.libsonnet';

local on_openshift = inv.parameters.facts.distribution == 'openshift4';

local serviceaccounts =
if params.ceph_cluster.namespace != params.namespace then {
[std.strReplace(suffix, '-', '_')]: kube.ServiceAccount('rook-ceph-%s' % suffix) {
Expand All @@ -26,7 +24,7 @@ local roles =
if params.ceph_cluster.namespace != params.namespace then {
// For OCP4 we need the metrics discovery role in the cluster
// namespace, if it differs from the operator namespace.
[if on_openshift then 'metrics']:
[if helpers.on_openshift then 'metrics']:
helpers.metrics_role(params.ceph_cluster.namespace),
osd: kube.Role('rook-ceph-osd') {
metadata+: {
Expand Down Expand Up @@ -100,7 +98,7 @@ local rolebindings =
if params.ceph_cluster.namespace != params.namespace then
(
// For OCP4, we need the metrics discovery rolebinding
if on_openshift then [
if helpers.on_openshift then [
helpers.ocp_metrics_rolebinding(
params.ceph_cluster.namespace,
roles.metrics,
Expand Down Expand Up @@ -284,7 +282,7 @@ local toolbox =
super.containers[0] {
image: '%(registry)s/%(image)s:%(tag)s' % params.images.rook,
// Remove securityContext config on OCP4
[if on_openshift then 'securityContext']: {},
[if helpers.on_openshift then 'securityContext']: {},
},
],
tolerations: params.tolerations,
Expand Down
4 changes: 1 addition & 3 deletions component/csi_metrics.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ local params = inv.parameters.rook_ceph;

local helpers = import 'helpers.libsonnet';

local on_openshift = inv.parameters.facts.distribution == 'openshift4';

local ocp_role = helpers.metrics_role(params.namespace);

local rbac =
if on_openshift then [
if helpers.on_openshift then [
ocp_role,
helpers.ocp_metrics_rolebinding(
params.namespace,
Expand Down
4 changes: 4 additions & 0 deletions component/helpers.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ local nodeAffinity = {
},
};

local on_openshift =
std.member([ 'openshift4', 'oke' ], inv.parameters.facts.distribution);

{
load_manifest: load_manifest,
metrics_role: metrics_role,
ocp_metrics_rolebinding: ocp_metrics_rolebinding,
nodeAffinity: nodeAffinity,
on_openshift: on_openshift,
}
8 changes: 3 additions & 5 deletions component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ local kube = import 'lib/kube.libjsonnet';
local inv = kap.inventory();
local params = inv.parameters.rook_ceph;

local on_openshift =
inv.parameters.facts.distribution == 'openshift4';

local cephcluster = import 'cephcluster.libsonnet';
local helpers = import 'helpers.libsonnet';

local ns_config =
if on_openshift then {
if helpers.on_openshift then {
metadata+: {
annotations+: {
// set node selector to allow pods to be scheduled on all nodes -> CSI
Expand Down Expand Up @@ -106,7 +104,7 @@ std.mapWithKey(
{
'00_namespaces': namespaces,
'01_aggregated_rbac': aggregated_rbac.cluster_roles,
[if on_openshift then '02_openshift_sccs']: ocp_config.sccs,
[if helpers.on_openshift then '02_openshift_sccs']: ocp_config.sccs,
'03_rbac_fixes': cephfs_rbac_fix,
'10_cephcluster_rbac': cephcluster.rbac,
'10_cephcluster_configoverride': cephcluster.configmap,
Expand Down