Skip to content

Commit

Permalink
Merge pull request #131 from appuio/fix/missing-es-operator-metrics-t…
Browse files Browse the repository at this point in the history
…oken

Manually generate missing Elasticsearch Operator metrics token
  • Loading branch information
DebakelOrakel authored May 2, 2024
2 parents f9878ee + 3cd4a68 commit e8ff4d7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions component/elasticsearch.libsonnet
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// main template for openshift4-lokistack
local workaround = import 'es_workaround.libsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local resourceLocker = import 'lib/resource-locker.libjsonnet';
Expand Down Expand Up @@ -125,6 +126,7 @@ if elasticsearch.enabled then
'40_es_machineconfig': machineconfig_journald,
'40_es_netpol': netpol_operator,
[if kibana_host != null then '40_es_kibana_host']: kibana_patchWithAdditionalPermissions,
'40_es_operator_metrics_token': workaround.missing_metrics_token,
}
else
std.trace(
Expand Down
35 changes: 35 additions & 0 deletions component/es_workaround.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local com = import 'lib/commodore.libjsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local po = import 'lib/patch-operator.libsonnet';

// The hiera parameters for the component
local inv = kap.inventory();
local params = inv.parameters.openshift4_logging;


// Generate missing metrics SA token for Elasticsearch Operator.
//
// The ServiceMonitor for the Elasticsearch Operator references a SA token secret
// called `elasticsearch-operator-controller-manager-metrics-token` which doesn't exist
// on the cluster after the operator is installed or upgraded to 5.8.6 via
// OLM.
local missing_metrics_token =
kube.Secret('elasticsearch-operator-controller-manager-metrics-token') {
metadata+: {
// Loki operator is deployed in openshift-operators-redhat
namespace: 'openshift-operators-redhat',
annotations+: {
'kubernetes.io/service-account.name': 'elasticsearch-operator-controller-manager-metrics-reader',
// disable argocd prune/delete so removing the workaround should be
// fairly easy in case the Elasticsearch Operator OLM install fixes the issue.
'argocd.argoproj.io/sync-options': 'Prune=false,Delete=false',
},
},
data:: {},
type: 'kubernetes.io/service-account-token',
};

{
missing_metrics_token: [ missing_metrics_token ],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Secret
metadata:
annotations:
argocd.argoproj.io/sync-options: Prune=false,Delete=false
kubernetes.io/service-account.name: elasticsearch-operator-controller-manager-metrics-reader
labels:
name: elasticsearch-operator-controller-manager-metrics-token
name: elasticsearch-operator-controller-manager-metrics-token
namespace: openshift-operators-redhat
type: kubernetes.io/service-account-token

0 comments on commit e8ff4d7

Please sign in to comment.