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

Run elasticsearch operator on infra nodes #44

Closed
wants to merge 4 commits into from
Closed
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
10 changes: 7 additions & 3 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ parameters:
typekey: 'kubernetes.labels.logFormat'
typename: 'nologformat'

openshift4_elasticsearch_operator:
targetNamespaces:
- ${openshift4_logging:namespace}
elasticsearchOperator:
patchTarget:
namespace: openshift-operators-redhat
name: elasticsearch-operator
patch:
nodeSelector:
node-role.kubernetes.io/infra: ''
25 changes: 25 additions & 0 deletions component/deployment-patch.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local common = import 'common.libsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local resourceLocker = import 'lib/resource-locker.libjsonnet';
local inv = kap.inventory();
// The hiera parameters for the component
local params = inv.parameters.openshift4_logging;

local deploymentToPatch = kube._Object('apps/v1', 'Deployment', params.elasticsearchOperator.patchTarget.name) {
metadata+: {
namespace: params.elasticsearchOperator.patchTarget.namespace,
},
};

local patch = resourceLocker.Patch(deploymentToPatch, {
spec: {
template: {
spec: params.elasticsearchOperator.patch,
},
},
});

{
'40_deployment_patch': patch,
}
4 changes: 3 additions & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ local namespace_groups = (
},
},
'60_prometheus_rules': alert_rules.rules,
} + (import 'kibana-host.libsonnet')
}
+ (import 'kibana-host.libsonnet')
+ (import 'deployment-patch.libsonnet')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should address scheduling of operator pods which are managed through component openshift4-operators in that component (https://github.com/appuio/component-openshift4-operators) and not in the components which make use of component openshift4-operators.

I'd suggest to simply set the openshift.io/node-selector: node-role.kubernetes.io/infra= annotation on the namespaces managed by that component.

Alternatively the component library of component openshift4-operators could support configuring deployment patches, but I don't think that's actually necessary in this case, since we'll always want all operators to run on the infra nodes, if there are any.

Copy link
Contributor Author

@bastjan bastjan Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first instinct too. But i found the openshift.io/node-selector annotation already explicitly set to empty.

But I'm unsure if this is really needed...

Copy link
Member

@simu simu Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I copied that from the official instructions, cf. https://docs.openshift.com/container-platform/4.9/logging/cluster-logging-deploying.html#cluster-logging-deploy-cli_cluster-logging-deploying but I don't see how that's necessary unless some operators need to run on the control plane nodes.

I'd propose to go ahead and change the annotation in that component, since there's no real reason for the operator deployments themselves to run on specific nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 makes for a way simpler change

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 makes for a way simpler change

IMO the even bigger upside is that we don't need to copy-paste this change to any component which installs an operator via the openshift4-operators component library.

18 changes: 18 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,24 @@ clusterLogForwarding:
See the https://docs.openshift.com/container-platform/latest/logging/cluster-logging-enabling-json-logging.html#cluster-logging-configuration-of-json-log-data-for-default-elasticsearch_cluster-logging-enabling-json-logging[OpenShift docs] for a detailed explanation.


== `elasticsearchOperator`

[horizontal]
type:: dictionary
default::
+
[source,yaml]
----
patchTarget:
namespace: openshift-operators-redhat
name: elasticsearch-operator
patch:
nodeSelector:
node-role.kubernetes.io/infra: ''
----

Overrides for the ElasticSearch Operator deployment.

== Example

[source,yaml]
Expand Down
9 changes: 9 additions & 0 deletions tests/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ applications:
parameters:
kapitan:
dependencies:
- type: https
source: https://raw.githubusercontent.com/projectsyn/component-resource-locker/v2.1.0/lib/resource-locker.libjsonnet
output_path: vendor/lib/resource-locker.libjsonnet
- type: https
source: https://raw.githubusercontent.com/appuio/component-openshift4-operators/v1.0.2/lib/openshift4-operators.libsonnet
output_path: vendor/lib/openshift4-operators.libsonnet
Expand All @@ -17,3 +20,9 @@ parameters:
openshift4_monitoring:
alerts:
ignoreNames: []

resource_locker:
namespace: syn-resource-locker

openshift4_logging:
kibana_host: kibana.example.com
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
name: kibana-manager
name: kibana-manager
namespace: syn-resource-locker
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
name: syn-resource-locker-kibana-manager
name: syn-resource-locker-kibana-manager
rules:
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
name: syn-resource-locker-kibana-manager
name: syn-resource-locker-kibana-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: syn-resource-locker-kibana-manager
subjects:
- kind: ServiceAccount
name: kibana-manager
namespace: syn-resource-locker
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
name: syn-resource-locker-kibana-manager
name: syn-resource-locker-kibana-manager
namespace: openshift-logging
rules:
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- get
- patch
- apiGroups:
- route.openshift.io
resources:
- routes/custom-host
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
name: syn-resource-locker-kibana-manager
name: syn-resource-locker-kibana-manager
namespace: openshift-logging
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: syn-resource-locker-kibana-manager
subjects:
- kind: ServiceAccount
name: kibana-manager
namespace: syn-resource-locker
---
apiVersion: redhatcop.redhat.io/v1alpha1
kind: ResourceLocker
metadata:
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
labels:
name: openshift-logging-kibana
name: openshift-logging-kibana
namespace: syn-resource-locker
spec:
patches:
- id: patch1
patchTemplate: "\"spec\":\n \"host\": \"kibana.example.com\""
patchType: application/strategic-merge-patch+json
targetObjectRef:
apiVersion: route.openshift.io/v1
kind: Route
name: kibana
namespace: openshift-logging
serviceAccountRef:
name: kibana-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
name: elasticsearch-operator-manager
name: elasticsearch-operator-manager
namespace: syn-resource-locker
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
labels:
name: syn-resource-locker-elasticsearch-operator-manager
name: syn-resource-locker-elasticsearch-operator-manager
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
labels:
name: syn-resource-locker-elasticsearch-operator-manager
name: syn-resource-locker-elasticsearch-operator-manager
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: syn-resource-locker-elasticsearch-operator-manager
subjects:
- kind: ServiceAccount
name: elasticsearch-operator-manager
namespace: syn-resource-locker
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
labels:
name: syn-resource-locker-elasticsearch-operator-manager
name: syn-resource-locker-elasticsearch-operator-manager
namespace: openshift-operators-redhat
rules:
- apiGroups:
- apps
resources:
- deployments
verbs:
- get
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
labels:
name: syn-resource-locker-elasticsearch-operator-manager
name: syn-resource-locker-elasticsearch-operator-manager
namespace: openshift-operators-redhat
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: syn-resource-locker-elasticsearch-operator-manager
subjects:
- kind: ServiceAccount
name: elasticsearch-operator-manager
namespace: syn-resource-locker
---
apiVersion: redhatcop.redhat.io/v1alpha1
kind: ResourceLocker
metadata:
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
labels:
name: openshift-operators-redhat-elasticsearch-operator
name: openshift-operators-redhat-elasticsearch-operator
namespace: syn-resource-locker
spec:
patches:
- id: patch1
patchTemplate: "\"spec\":\n \"template\":\n \"spec\":\n \"nodeSelector\"\
:\n \"node-role.kubernetes.io/infra\": \"\""
patchType: application/strategic-merge-patch+json
targetObjectRef:
apiVersion: apps/v1
kind: Deployment
name: elasticsearch-operator
namespace: openshift-operators-redhat
serviceAccountRef:
name: elasticsearch-operator-manager