Skip to content

Commit bde48e0

Browse files
authored
Merge pull request #209 from projectsyn/feat/oke
Add support for OKE as an OpenShift flavor
2 parents 50e8727 + 5fdc4d7 commit bde48e0

5 files changed

+13
-18
lines changed

component/alertrules.libsonnet

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ local ignore_alerts = std.set(
5353
local runbook(alertname) =
5454
'https://hub.syn.tools/rook-ceph/runbooks/%s.html' % alertname;
5555

56-
local on_openshift =
57-
inv.parameters.facts.distribution == 'openshift4';
58-
5956
local alertpatching =
60-
if on_openshift then
57+
if helpers.on_openshift then
6158
import 'lib/alert-patching.libsonnet'
6259
else
6360
local patchRule(rule, patches={}, patch_name=true) =
@@ -91,7 +88,7 @@ local alertpatching =
9188
);
9289

9390
local prom =
94-
if on_openshift then
91+
if helpers.on_openshift then
9592
import 'lib/prom.libsonnet'
9693
else
9794
std.trace(

component/cephcluster.libsonnet

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ local params = inv.parameters.rook_ceph;
66

77
local helpers = import 'helpers.libsonnet';
88

9-
local on_openshift = inv.parameters.facts.distribution == 'openshift4';
10-
119
local serviceaccounts =
1210
if params.ceph_cluster.namespace != params.namespace then {
1311
[std.strReplace(suffix, '-', '_')]: kube.ServiceAccount('rook-ceph-%s' % suffix) {
@@ -26,7 +24,7 @@ local roles =
2624
if params.ceph_cluster.namespace != params.namespace then {
2725
// For OCP4 we need the metrics discovery role in the cluster
2826
// namespace, if it differs from the operator namespace.
29-
[if on_openshift then 'metrics']:
27+
[if helpers.on_openshift then 'metrics']:
3028
helpers.metrics_role(params.ceph_cluster.namespace),
3129
osd: kube.Role('rook-ceph-osd') {
3230
metadata+: {
@@ -100,7 +98,7 @@ local rolebindings =
10098
if params.ceph_cluster.namespace != params.namespace then
10199
(
102100
// For OCP4, we need the metrics discovery rolebinding
103-
if on_openshift then [
101+
if helpers.on_openshift then [
104102
helpers.ocp_metrics_rolebinding(
105103
params.ceph_cluster.namespace,
106104
roles.metrics,
@@ -284,7 +282,7 @@ local toolbox =
284282
super.containers[0] {
285283
image: '%(registry)s/%(image)s:%(tag)s' % params.images.rook,
286284
// Remove securityContext config on OCP4
287-
[if on_openshift then 'securityContext']: {},
285+
[if helpers.on_openshift then 'securityContext']: {},
288286
},
289287
],
290288
tolerations: params.tolerations,

component/csi_metrics.libsonnet

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ local params = inv.parameters.rook_ceph;
55

66
local helpers = import 'helpers.libsonnet';
77

8-
local on_openshift = inv.parameters.facts.distribution == 'openshift4';
9-
108
local ocp_role = helpers.metrics_role(params.namespace);
119

1210
local rbac =
13-
if on_openshift then [
11+
if helpers.on_openshift then [
1412
ocp_role,
1513
helpers.ocp_metrics_rolebinding(
1614
params.namespace,

component/helpers.libsonnet

+4
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ local nodeAffinity = {
5555
},
5656
};
5757

58+
local on_openshift =
59+
std.member([ 'openshift4', 'oke' ], inv.parameters.facts.distribution);
60+
5861
{
5962
load_manifest: load_manifest,
6063
metrics_role: metrics_role,
6164
ocp_metrics_rolebinding: ocp_metrics_rolebinding,
6265
nodeAffinity: nodeAffinity,
66+
on_openshift: on_openshift,
6367
}

component/main.jsonnet

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ local kube = import 'lib/kube.libjsonnet';
33
local inv = kap.inventory();
44
local params = inv.parameters.rook_ceph;
55

6-
local on_openshift =
7-
inv.parameters.facts.distribution == 'openshift4';
8-
96
local cephcluster = import 'cephcluster.libsonnet';
7+
local helpers = import 'helpers.libsonnet';
108

119
local ns_config =
12-
if on_openshift then {
10+
if helpers.on_openshift then {
1311
metadata+: {
1412
annotations+: {
1513
// set node selector to allow pods to be scheduled on all nodes -> CSI
@@ -106,7 +104,7 @@ std.mapWithKey(
106104
{
107105
'00_namespaces': namespaces,
108106
'01_aggregated_rbac': aggregated_rbac.cluster_roles,
109-
[if on_openshift then '02_openshift_sccs']: ocp_config.sccs,
107+
[if helpers.on_openshift then '02_openshift_sccs']: ocp_config.sccs,
110108
'03_rbac_fixes': cephfs_rbac_fix,
111109
'10_cephcluster_rbac': cephcluster.rbac,
112110
'10_cephcluster_configoverride': cephcluster.configmap,

0 commit comments

Comments
 (0)