/
controller.go
executable file
·3292 lines (3104 loc) · 114 KB
/
controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Tencent is pleased to support the open source community by making TKEStack
* available.
*
* Copyright (C) 2012-2019 Tencent. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* https://opensource.org/licenses/Apache-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package prometheus
import (
"context"
"encoding/json"
"fmt"
"math/rand"
"reflect"
"strings"
"sync"
"time"
"github.com/coreos/prometheus-operator/pkg/apis/monitoring"
monitoringv1 "github.com/coreos/prometheus-operator/pkg/apis/monitoring/v1"
influxApi "github.com/influxdata/influxdb1-client/v2"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/util/workqueue"
apiregistrationv1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1"
clientset "tkestack.io/tke/api/client/clientset/versioned"
platformv1informer "tkestack.io/tke/api/client/informers/externalversions/platform/v1"
platformv1lister "tkestack.io/tke/api/client/listers/platform/v1"
v1 "tkestack.io/tke/api/platform/v1"
notifyapi "tkestack.io/tke/cmd/tke-notify-api/app"
controllerutil "tkestack.io/tke/pkg/controller"
esutil "tkestack.io/tke/pkg/monitor/storage/es/client"
monitorutil "tkestack.io/tke/pkg/monitor/util"
"tkestack.io/tke/pkg/platform/controller/addon/prometheus/images"
"tkestack.io/tke/pkg/platform/util"
"tkestack.io/tke/pkg/util/apiclient"
containerregistryutil "tkestack.io/tke/pkg/util/containerregistry"
"tkestack.io/tke/pkg/util/log"
"tkestack.io/tke/pkg/util/metrics"
)
const (
prometheusClientRetryCount = 5
prometheusClientRetryInterval = 5 * time.Second
prometheusMaxRetryCount = 5
prometheusTimeOut = 5 * time.Minute
)
const (
// PrometheusService is the service name for prometheus app
PrometheusOperatorService = "prometheus-operator"
PrometheusOperatorServicePort = "http"
prometheusOperatorServiceAccount = "prometheus-operator"
prometheusOperatorClusterRoleBinding = "prometheus-operator"
prometheusOperatorClusterRole = "prometheus-operator"
prometheusOperatorWorkLoad = "prometheus-operator"
PrometheusBeatService = "prometheus-beat"
PrometheusBeatServicePort = "http"
PrometheusBeatConfigmap = "prometheus-beat-config"
PrometheusBeatConfigFile = "prometheusbeat.yml"
prometheusBeatWorkLoad = "prometheus-beat"
// PrometheusService is the service name for prometheus app
PrometheusService = "prometheus"
// PrometheusServicePort is the port name for prometheus service
PrometheusServicePort = "http"
PrometheusCRDName = "k8s"
prometheusServiceAccount = PrometheusService + "-" + PrometheusCRDName
prometheusClusterRoleBinding = PrometheusService + "-" + PrometheusCRDName
prometheusClusterRole = PrometheusService + "-" + PrometheusCRDName
prometheusSecret = PrometheusService + "-" + PrometheusCRDName + "-" + "additional-scrape-config"
prometheusWorkLoad = "prometheus"
prometheusETCDSecret = "prometheus-etcd"
prometheusRuleRecord = "prometheus-records"
PrometheusRuleAlert = "prometheus-alerts"
prometheusConfigName = "prometheus.config.yaml"
prometheusImagePath = "prometheus"
// AlertManagerService defines the service for alert manager app
AlertManagerService = "alertmanager"
// AlertManagerWorkLoad defines the app name for alert manager
AlertManagerWorkLoad = "alertmanager"
// AlertManagerConfigMap defines the configmap name which stores the alertmanager config rules
AlertManagerConfigMap = "alertmanager-config"
// AlertManagerConfigName defines the entry name of the configmap which saves the alertmanager rules
AlertManagerConfigName = "alertmanager.yml"
alertManagerImagePath = "alertmanager"
alertManagerServicePort = "http"
alertManagerCRDName = "main"
alertManagerServiceAccount = AlertManagerService + "-" + alertManagerCRDName
alertManagerSecret = AlertManagerService + "-" + alertManagerCRDName
nodeExporterService = "node-exporter"
nodeExporterDaemonSet = "node-exporter"
kubeStateService = "kube-state-metrics"
kubeStateServiceAccount = "kube-state-metrics"
kubeStateClusterRoleBinding = "kube-state-metrics"
kubeStateClusterRole = "kube-state-metrics"
kubeStateRoleBinding = "kube-state-metrics"
kubeStateRole = "kube-state-metrics-resizer"
kubeStateWorkLoad = "kube-state-metrics"
prometheusAdapterAuthDelegatorClusterRoleBinding = "custom-metrics:system:auth-delegator"
prometheusAdapterServiceAccount = "custom-metrics-apiserver"
prometheusAdapterWorkLoad = "custom-metrics-apiserver"
prometheusAdapterService = "custom-metrics-apiserver"
prometheusAdapterClusterRole = "custom-metrics-server-resources"
prometheusAdapterResourceReaderClusterRole = "custom-metrics-resource-reader"
prometheusAdapterResourceReaderClusterRoleBinding = "custom-metrics-resource-reader"
prometheusAdapterHPAClusterRoleBinding = "hpa-controller-custom-metrics"
prometheusAdapterAuthReaderRoleBinding = "custom-metrics-auth-reader"
prometheusAdapterConfigMap = "adapter-config"
systemAuthDelegatorClusterRole = "system:auth-delegator"
nodeProblemDetectorWorkload = "node-problem-detector"
nodeProblemDetectorServiceAccount = "node-problem-detector"
nodeProblemDetectorClusterRoleBinding = "node-problem-detector"
nodeProblemDetectorClusterRole = "node-problem-detector"
specialLabelName = "k8s-submitter"
specialLabelValue = "controller"
)
type influxdbClient struct {
address string
client influxApi.Client
}
type thanosClient struct {
address string
}
// more client will be added, now support influxdb, es and thanos
type remoteClient struct {
influxdb *influxdbClient
es *esutil.Client
thanos *thanosClient
}
// Controller is responsible for performing actions dependent upon a prometheus phase.
type Controller struct {
client clientset.Interface
cache *prometheusCache
health sync.Map
checking sync.Map
upgrading sync.Map
queue workqueue.RateLimitingInterface
lister platformv1lister.PrometheusLister
listerSynced cache.InformerSynced
stopCh <-chan struct{}
// RemoteAddress for prometheus
remoteClients []remoteClient
remoteType string
// NotifyApiAddress
notifyAPIAddress string
}
// NewController creates a new Controller object.
func NewController(client clientset.Interface, prometheusInformer platformv1informer.PrometheusInformer, resyncPeriod time.Duration, remoteAddress []string, remoteType string) *Controller {
// create the controller so we can inject the enqueue function
controller := &Controller{
client: client,
cache: &prometheusCache{prometheusMap: make(map[string]*cachedPrometheus)},
queue: workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "prometheus"),
remoteType: remoteType,
}
if client != nil && client.PlatformV1().RESTClient().GetRateLimiter() != nil {
_ = metrics.RegisterMetricAndTrackRateLimiterUsage("prometheus_controller", client.PlatformV1().RESTClient().GetRateLimiter())
}
// configure the prometheus informer event handlers
prometheusInformer.Informer().AddEventHandlerWithResyncPeriod(
cache.ResourceEventHandlerFuncs{
AddFunc: controller.enqueuePrometheus,
UpdateFunc: func(oldObj, newObj interface{}) {
oldPrometheus, ok1 := oldObj.(*v1.Prometheus)
curPrometheus, ok2 := newObj.(*v1.Prometheus)
if ok1 && ok2 && controller.needsUpdate(oldPrometheus, curPrometheus) {
controller.enqueuePrometheus(newObj)
}
},
DeleteFunc: controller.enqueuePrometheus,
},
resyncPeriod,
)
controller.lister = prometheusInformer.Lister()
controller.listerSynced = prometheusInformer.Informer().HasSynced
// construct remote client
switch remoteType {
case "influxdb":
for _, remoteAddr := range remoteAddress {
remoteClient := remoteClient{
influxdb: &influxdbClient{},
}
client, err := monitorutil.ParseInfluxdb(remoteAddr)
if err != nil {
log.Errorf("Parse remote address %s to client failed: %v", remoteAddr, err)
remoteClient.influxdb.client = nil
remoteClient.influxdb.address = remoteAddr
} else {
attrs := strings.Split(remoteAddr, "&")
remoteClient.influxdb.address = attrs[0]
remoteClient.influxdb.client = client
}
controller.remoteClients = append(controller.remoteClients, remoteClient)
}
case "elasticsearch":
for _, remoteAddr := range remoteAddress {
remoteClient := remoteClient{
es: &esutil.Client{},
}
client, err := monitorutil.ParseES(remoteAddr)
if err != nil {
log.Errorf("Parse remote address %s to client failed: %v", remoteAddr, err)
remoteClient.es.URL = remoteAddr
} else {
remoteClient.es = &client
}
controller.remoteClients = append(controller.remoteClients, remoteClient)
}
case "thanos":
for _, remoteAddr := range remoteAddress {
remoteClient := remoteClient{
thanos: &thanosClient{address: remoteAddr},
}
controller.remoteClients = append(controller.remoteClients, remoteClient)
}
default:
log.Errorf("invalid remote type: %s", remoteType)
}
return controller
}
// obj could be an *v1.Prometheus, or a DeletionFinalStateUnknown marker item.
func (c *Controller) enqueuePrometheus(obj interface{}) {
key, err := controllerutil.KeyFunc(obj)
if err != nil {
log.Error("Couldn't get key for object", log.Any("object", obj), log.Err(err))
return
}
c.queue.Add(key)
}
func (c *Controller) needsUpdate(oldPrometheus *v1.Prometheus, newPrometheus *v1.Prometheus) bool {
return !reflect.DeepEqual(oldPrometheus, newPrometheus)
}
// Run will set up the event handlers for types we are interested in, as well
// as syncing informer caches and starting workers.
func (c *Controller) Run(workers int, stopCh <-chan struct{}) error {
// Start the informer factories to begin populating the informer caches
log.Info("Starting prometheus controller")
defer log.Info("Shutting down prometheus controller")
// Check if database for project existed, if not, just create
query := influxApi.Query{
Command: "create database " + monitorutil.ProjectDatabaseName,
Database: monitorutil.ProjectDatabaseName,
}
if c.remoteType == "influxdb" {
// Wait unitl influxdb is OK
_ = wait.PollImmediateInfinite(10*time.Second, func() (bool, error) {
for _, client := range c.remoteClients {
if client.influxdb.client == nil {
return false, nil
}
log.Debugf("query sql: %s", query.Command)
resp, err := client.influxdb.client.Query(query)
if err != nil {
log.Errorf("Create database %s for %s failed: %v", monitorutil.ProjectDatabaseName, client.influxdb.address, err)
return false, nil
} else if resp.Error() != nil {
log.Errorf("Create database %s for %s failed: %v", monitorutil.ProjectDatabaseName, client.influxdb.address, resp.Error())
return false, nil
}
}
log.Info("Created database projects in influxdb")
return true, nil
})
}
defer runtime.HandleCrash()
defer c.queue.ShutDown()
if ok := cache.WaitForCacheSync(stopCh, c.listerSynced); !ok {
return fmt.Errorf("failed to wait for cluster caches to sync")
}
c.stopCh = stopCh
for i := 0; i < workers; i++ {
go wait.Until(c.worker, time.Second, stopCh)
}
<-stopCh
return nil
}
// worker processes the queue of objects.
func (c *Controller) worker() {
for c.processNextWorkItem() {
}
}
func (c *Controller) processNextWorkItem() bool {
key, quit := c.queue.Get()
if quit {
return false
}
defer c.queue.Done(key)
err := c.syncPrometheus(key.(string))
if err == nil {
c.queue.Forget(key)
return true
}
runtime.HandleError(fmt.Errorf("error processing prometheus %v (will retry): %v", key, err))
c.queue.AddRateLimited(key)
return true
}
// syncPrometheus will sync the Prometheus with the given key if it has had
// its expectations fulfilled, meaning it did not expect to see any more of its
// namespaces created or deleted. This function is not meant to be invoked
// concurrently with the same key.
func (c *Controller) syncPrometheus(key string) error {
startTime := time.Now()
var cachedPrometheus *cachedPrometheus
defer func() {
log.Info("Finished syncing prometheus", log.String("prome", key), log.Duration("processTime", time.Since(startTime)))
}()
_, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
return err
}
// prometheus holds the latest prometheus info from apiserver
prometheus, err := c.lister.Get(name)
switch {
case errors.IsNotFound(err):
log.Info("Prometheus has been deleted. Attempting to cleanup resources", log.String("prome", key))
err = c.processPrometheusDeletion(context.Background(), key)
case err != nil:
log.Warn("Unable to retrieve prometheus from store", log.String("prome", key), log.Err(err))
default:
cachedPrometheus = c.cache.getOrCreate(key)
err = c.processPrometheusUpdate(context.Background(), cachedPrometheus, prometheus, key)
}
return err
}
func (c *Controller) processPrometheusDeletion(ctx context.Context, key string) error {
cachedPrometheus, ok := c.cache.get(key)
if !ok {
log.Error("Prometheus not in cache even though the watcher thought it was. Ignoring the deletion", log.String("prome", key))
return nil
}
return c.processPrometheusDelete(ctx, cachedPrometheus, key)
}
func (c *Controller) processPrometheusDelete(ctx context.Context, cachedPrometheus *cachedPrometheus, key string) error {
log.Info("prometheus will be dropped", log.String("prome", key))
prometheus := cachedPrometheus.state
if prometheus != nil {
DeleteMetricPrometheusStatusFail(prometheus.Spec.TenantID, prometheus.Spec.ClusterName, prometheus.Name)
}
err := c.uninstallPrometheus(ctx, prometheus, true)
if err != nil {
log.Errorf("Prometheus uninstall fail: %v", err)
return err
}
if c.cache.Exist(key) {
log.Info("delete the prometheus cache", log.String("prome", key))
c.cache.delete(key)
}
if _, ok := c.health.Load(key); ok {
log.Info("delete the prometheus health cache", log.String("prome", key))
c.health.Delete(key)
}
return nil
}
func (c *Controller) processPrometheusUpdate(ctx context.Context, cachedPrometheus *cachedPrometheus, prometheus *v1.Prometheus, key string) error {
if cachedPrometheus.state != nil {
// exist and the cluster name changed
if cachedPrometheus.state.UID != prometheus.UID {
log.Info("Prometheus uid has chenged, just delete!", log.String("prome", key))
if err := c.processPrometheusDelete(ctx, cachedPrometheus, key); err != nil {
return err
}
}
}
notifyAPIConfigMap, err := c.client.PlatformV1().ConfigMaps().Get(ctx, notifyapi.NotifyApiConfigMapName, metav1.GetOptions{})
if err == nil && notifyAPIConfigMap != nil {
if v, ok := notifyAPIConfigMap.Annotations[notifyapi.NotifyAPIAddressKey]; ok {
if c.notifyAPIAddress != v {
c.notifyAPIAddress = v
}
}
}
err = c.createPrometheusIfNeeded(ctx, key, cachedPrometheus, prometheus)
if err != nil {
return err
}
cachedPrometheus.state = prometheus
// Always update the cache upon success.
c.cache.set(key, cachedPrometheus)
return nil
}
func (c *Controller) prometheusReinitialize(ctx context.Context, key string, cachedPrometheus *cachedPrometheus, prometheus *v1.Prometheus) func() (bool, error) {
// this func will always return true that keeps the poll once
return func() (bool, error) {
log.Info("Reinitialize, try to reinstall", log.String("prome", key))
c.uninstallPrometheus(ctx, prometheus, false)
err := c.installPrometheus(ctx, prometheus)
if err == nil {
prometheus = prometheus.DeepCopy()
prometheus.Status.Phase = v1.AddonPhaseChecking
prometheus.Status.Reason = ""
prometheus.Status.LastReInitializingTimestamp = metav1.NewTime(time.Now())
err = c.persistUpdate(ctx, prometheus)
if err != nil {
return true, err
}
return true, nil
}
log.Info("Reinitialize, try to uninstall", log.String("prome", key))
// First, rollback the prometheus
if err := c.uninstallPrometheus(ctx, prometheus, false); err != nil {
log.Error("Uninstall prometheus error.", log.String("prome", key))
return true, err
}
if prometheus.Status.RetryCount == prometheusMaxRetryCount {
log.Error("PrometheusReinitialize exceed max retry, set failed", log.String("prome", key))
prometheus = prometheus.DeepCopy()
prometheus.Status.Phase = v1.AddonPhaseFailed
prometheus.Status.Reason = fmt.Sprintf("Install error and retried max(%d) times already.", prometheusMaxRetryCount)
err := c.persistUpdate(ctx, prometheus)
if err != nil {
log.Error("Update prometheus error.")
return true, err
}
return true, nil
}
// Add the retry count will trigger reinitialize function from the persistent controller again.
prometheus = prometheus.DeepCopy()
prometheus.Status.Phase = v1.AddonPhaseReinitializing
prometheus.Status.Reason = err.Error()
prometheus.Status.LastReInitializingTimestamp = metav1.NewTime(time.Now())
prometheus.Status.RetryCount++
err = c.persistUpdate(ctx, prometheus)
if err != nil {
return true, err
}
return true, nil
}
}
func (c *Controller) createPrometheusIfNeeded(ctx context.Context, key string, cachedPrometheus *cachedPrometheus, prometheus *v1.Prometheus) error {
switch prometheus.Status.Phase {
case v1.AddonPhaseInitializing:
log.Info("Prometheus will be created", log.String("prome", key))
err := c.installPrometheus(ctx, prometheus)
if err == nil {
log.Info("Prometheus created success", log.String("prome", key))
prometheus = prometheus.DeepCopy()
prometheus.Status.Phase = v1.AddonPhaseChecking
prometheus.Status.Reason = ""
prometheus.Status.RetryCount = 0
return c.persistUpdate(ctx, prometheus)
}
log.Error(fmt.Sprintf("Prometheus created failed: %v", err), log.String("prome", key))
prometheus = prometheus.DeepCopy()
prometheus.Status.Phase = v1.AddonPhaseReinitializing
prometheus.Status.Reason = err.Error()
prometheus.Status.RetryCount = 1
return c.persistUpdate(ctx, prometheus)
case v1.AddonPhaseReinitializing:
log.Info("Prometheus entry Reinitializing", log.String("prome", key))
var interval = time.Since(prometheus.Status.LastReInitializingTimestamp.Time)
var waitTime time.Duration
if interval >= prometheusTimeOut {
waitTime = time.Duration(1)
} else {
waitTime = prometheusTimeOut - interval
}
go wait.Poll(waitTime, prometheusTimeOut, c.prometheusReinitialize(ctx, key, cachedPrometheus, prometheus))
case v1.AddonPhaseChecking:
log.Info("Prometheus entry Checking", log.String("prome", key))
if _, ok := c.checking.Load(key); !ok {
c.checking.Store(key, prometheus)
initDelay := time.Now().Add(5 * time.Minute)
go func() {
defer c.checking.Delete(key)
wait.PollImmediate(5*time.Second, 5*time.Minute, c.checkPrometheusStatus(ctx, prometheus, key, initDelay))
}()
}
case v1.AddonPhaseRunning:
log.Info("Prometheus entry Running", log.String("prome", key))
UpdateMetricPrometheusStatusFail(prometheus.Spec.TenantID, prometheus.Spec.ClusterName, prometheus.Name, false)
if needUpgrade(prometheus) {
c.health.Delete(key)
prometheus = prometheus.DeepCopy()
prometheus.Status.Phase = v1.AddonPhaseUpgrading
prometheus.Status.Reason = ""
prometheus.Status.RetryCount = 0
return c.persistUpdate(ctx, prometheus)
}
if _, ok := c.health.Load(key); !ok {
c.health.Store(key, prometheus)
go wait.PollImmediateUntil(5*time.Minute, c.watchPrometheusHealth(ctx, key), c.stopCh)
}
case v1.AddonPhaseUpgrading:
log.Info("Prometheus entry upgrading", log.String("prome", key))
if _, ok := c.upgrading.Load(key); !ok {
c.upgrading.Store(key, prometheus)
delay := time.Now().Add(5 * time.Minute)
go func() {
defer c.upgrading.Delete(key)
wait.PollImmediate(5*time.Second, 5*time.Minute, c.checkPrometheusUpgrade(ctx, prometheus, key, delay))
}()
}
case v1.AddonPhaseFailed:
log.Info("Prometheus entry fail", log.String("prome", key))
c.upgrading.Delete(key)
c.health.Delete(key)
UpdateMetricPrometheusStatusFail(prometheus.Spec.TenantID, prometheus.Spec.ClusterName, prometheus.Name, true)
// should try check when prometheus recover again
log.Info("Prometheus try checking after fail", log.String("prome", key))
if _, ok := c.checking.Load(key); !ok {
c.checking.Store(key, prometheus)
go func() {
defer c.checking.Delete(key)
wait.PollImmediateUntil(60*time.Second, c.checkPrometheusStatus(ctx, prometheus, key, time.Time{}), c.stopCh)
}()
}
}
return nil
}
func (c *Controller) installPrometheus(ctx context.Context, prometheus *v1.Prometheus) error {
if c.notifyAPIAddress == "" {
return fmt.Errorf("empty notify api address, check if notify api exists")
}
components := images.Get(prometheus.Spec.Version)
prometheus.Status.Version = prometheus.Spec.Version
if prometheus.Status.SubVersion == nil {
prometheus.Status.SubVersion = make(map[string]string)
}
cluster, err := c.client.PlatformV1().Clusters().Get(ctx, prometheus.Spec.ClusterName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("get cluster failed: %v", err)
}
kubeClient, err := util.BuildExternalClientSet(ctx, cluster, c.client.PlatformV1())
if err != nil {
return fmt.Errorf("get kubeClient failed: %v", err)
}
kaClient, err := util.BuildKubeAggregatorClientSet(ctx, cluster, c.client.PlatformV1())
if err != nil {
return fmt.Errorf("get kaClient failed: %v", err)
}
crdClient, err := util.BuildExternalExtensionClientSet(ctx, cluster, c.client.PlatformV1())
if err != nil {
return fmt.Errorf("get crdClient failed: %v", err)
}
mclient, err := util.BuildExternalMonitoringClientSet(ctx, cluster, c.client.PlatformV1())
if err != nil {
return fmt.Errorf("get mclient failed: %v", err)
}
// Set remote write address
var remoteWrites []string
switch c.remoteType {
case "influxdb":
remoteWrites, err = c.initInfluxdb(cluster.Name)
if err != nil {
return fmt.Errorf("init Influxdb failed: %v", err)
}
case "elasticsearch":
remoteWrites, err = c.initESAdapter(ctx, kubeClient, components)
if err != nil {
return fmt.Errorf("init ESAdapter failed: %v", err)
}
prometheus.Status.SubVersion[PrometheusBeatService] = components.PrometheusBeatWorkLoad.Tag
case "thanos":
remoteWrites, err = c.initThanos()
if err != nil {
return fmt.Errorf("init Thanos failed: %v", err)
}
default:
}
if len(prometheus.Spec.RemoteAddress.WriteAddr) > 0 {
remoteWrites = prometheus.Spec.RemoteAddress.WriteAddr
}
// For remote read, just set from spec
var remoteReads []string
if len(prometheus.Spec.RemoteAddress.ReadAddr) > 0 {
remoteReads = prometheus.Spec.RemoteAddress.ReadAddr
}
log.Infof("Start to create crds")
crds := getCRDs()
for _, crd := range crds {
if apiclient.ClusterVersionIsBefore116(kubeClient) {
crdObj := apiextensionsv1beta1.CustomResourceDefinition{}
err := json.Unmarshal([]byte(crd), &crdObj)
if err != nil {
return fmt.Errorf("Unmarshal crd failed: %v", err)
}
crdObj.TypeMeta.APIVersion = "apiextensions.k8s.io/v1beta1"
_, err = crdClient.ApiextensionsV1beta1().CustomResourceDefinitions().Create(ctx, &crdObj, metav1.CreateOptions{})
if err != nil {
log.Errorf("create crd failed %v", err)
return err
}
} else {
crdObj := apiextensionsv1.CustomResourceDefinition{}
err := json.Unmarshal([]byte(crd), &crdObj)
if err != nil {
return fmt.Errorf("Unmarshal crd failed: %v", err)
}
_, err = crdClient.ApiextensionsV1().CustomResourceDefinitions().Create(ctx, &crdObj, metav1.CreateOptions{})
if err != nil {
log.Errorf("create crd failed %v", err)
return err
}
}
}
log.Infof("Start to create prometheus-operator")
// Service prometheus-operator
if _, err := kubeClient.CoreV1().Services(metav1.NamespaceSystem).Create(ctx, servicePrometheusOperator(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-operator service failed: %v", err)
}
// ServiceAccount for prometheus-operator
if _, err := kubeClient.CoreV1().ServiceAccounts(metav1.NamespaceSystem).Create(ctx, serviceAccountPrometheusOperator(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-operator ServiceAccount failed: %v", err)
}
// ClusterRole for prometheus-operator
if _, err := kubeClient.RbacV1().ClusterRoles().Create(ctx, clusterRolePrometheusOperator(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-operator ClusterRole failed: %v", err)
}
// ClusterRoleBinding prometheus-operator
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, clusterRoleBindingPrometheusOperator(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-operator ClusterRoleBinding failed: %v", err)
}
// Deployment for prometheus-operator
if _, err := kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Create(ctx, deployPrometheusOperatorApps(components, prometheus), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-operator Deployment failed: %v", err)
}
prometheus.Status.SubVersion[PrometheusOperatorService] = components.PrometheusOperatorService.Tag
extensionsAPIGroup := apiclient.ClusterVersionIsBefore19(kubeClient)
// get notify webhook address
var webhookAddr string
if prometheus.Spec.NotifyWebhook != "" {
webhookAddr = prometheus.Spec.NotifyWebhook
} else {
webhookAddr = c.notifyAPIAddress + "/webhook"
}
log.Infof("Start to create alertmanager")
// secret for alertmanager
if _, err := kubeClient.CoreV1().Secrets(metav1.NamespaceSystem).Create(ctx, createSecretForAlertmanager(webhookAddr, prometheus.Spec.AlertRepeatInterval), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create alertmanager secret failed: %v", err)
}
// ServiceAccount for alertmanager
if _, err := kubeClient.CoreV1().ServiceAccounts(metav1.NamespaceSystem).Create(ctx, serviceAccountAlertmanager(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create alertmanager ServiceAccount failed: %v", err)
}
// Service for alertmanager
if _, err := kubeClient.CoreV1().Services(metav1.NamespaceSystem).Create(ctx, createServiceForAlerterManager(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create alertmanager Service failed: %v", err)
}
// Crd alertmanager instance
if _, err := mclient.MonitoringV1().Alertmanagers(metav1.NamespaceSystem).Create(ctx, createAlertManagerCRD(components, prometheus), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create alertmanager Crd instance failed: %v", err)
}
prometheus.Status.SubVersion[AlertManagerService] = components.AlertManagerService.Tag
log.Infof("Start to create prometheus")
// Secret for prometheus-etcd
credential, err := util.GetClusterCredentialV1(ctx, c.client.PlatformV1(), cluster)
if err != nil {
return fmt.Errorf("get credential failed: %v", err)
}
if _, err := kubeClient.CoreV1().Secrets(metav1.NamespaceSystem).Create(ctx, secretETCDPrometheus(credential), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-etcd Secret failed: %v", err)
}
// Service Prometheus
if _, err := kubeClient.CoreV1().Services(metav1.NamespaceSystem).Create(ctx, servicePrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus Service failed: %v", err)
}
// Secret for prometheus
if _, err := kubeClient.CoreV1().Secrets(metav1.NamespaceSystem).Create(ctx, createSecretForPrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus Secret failed: %v", err)
}
// ServiceAccount for prometheus
if _, err := kubeClient.CoreV1().ServiceAccounts(metav1.NamespaceSystem).Create(ctx, serviceAccountPrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus ServiceAccount failed: %v", err)
}
// ClusterRole for prometheus
if _, err := kubeClient.RbacV1().ClusterRoles().Create(ctx, clusterRolePrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus ClusterRole failed: %v", err)
}
// ClusterRoleBinding Prometheus
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, clusterRoleBindingPrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus ClusterRoleBinding failed: %v", err)
}
// prometheus rule record
if _, err := mclient.MonitoringV1().PrometheusRules(metav1.NamespaceSystem).Create(ctx, recordsForPrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus rule record failed: %v", err)
}
// prometheus rule alert, empty for now, edit by tke-monitor
if _, err := mclient.MonitoringV1().PrometheusRules(metav1.NamespaceSystem).Create(ctx, alertsForPrometheus(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus rule alert failed: %v", err)
}
// Crd prometheus instance
if _, err := mclient.MonitoringV1().Prometheuses(metav1.NamespaceSystem).Create(ctx, createPrometheusCRD(components, prometheus, cluster, remoteWrites, remoteReads, c.remoteType), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus crd instance failed: %v", err)
}
prometheus.Status.SubVersion[PrometheusService] = components.PrometheusService.Tag
log.Infof("Start to create node-exporter")
// DaemonSet for node-exporter
if _, err := kubeClient.AppsV1().DaemonSets(metav1.NamespaceSystem).Create(ctx, createDaemonSetForNodeExporter(components), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create node-exporter failed: %v", err)
}
prometheus.Status.SubVersion[nodeExporterService] = components.NodeExporterService.Tag
log.Infof("Start to create kube-state-metrics")
// Service for kube-state-metrics
if _, err := kubeClient.CoreV1().Services(metav1.NamespaceSystem).Create(ctx, createServiceForMetrics(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics Service failed: %v", err)
}
// ServiceAccount for kube-state-metrics
if _, err := kubeClient.CoreV1().ServiceAccounts(metav1.NamespaceSystem).Create(ctx, createServiceAccountForMetrics(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics ServiceAccount failed: %v", err)
}
// ClusterRole for kube-state-metrics
if _, err := kubeClient.RbacV1().ClusterRoles().Create(ctx, createClusterRoleForMetrics(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics ClusterRole failed: %v", err)
}
// ClusterRoleBinding for kube-state-metrics
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, createClusterRoleBindingForMetrics(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics ClusterRoleBinding failed: %v", err)
}
// Role for kube-state-metrics
if _, err := kubeClient.RbacV1().Roles(metav1.NamespaceSystem).Create(ctx, createRoleForMetrics(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics Role failed: %v", err)
}
// RoleBinding for kube-state-metrics
if _, err := kubeClient.RbacV1().RoleBindings(metav1.NamespaceSystem).Create(ctx, createRoleBingdingForMetrics(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics RoleBinding failed: %v", err)
}
// Deployment for kube-state-metrics
if extensionsAPIGroup {
if _, err := kubeClient.ExtensionsV1beta1().Deployments(metav1.NamespaceSystem).Create(ctx, createExtensionDeploymentForMetrics(components, prometheus), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics Deployment failed: %v", err)
}
} else {
if _, err := kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Create(ctx, createAppsDeploymentForMetrics(components, prometheus), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create kube-state-metrics Deployment failed: %v", err)
}
}
prometheus.Status.SubVersion[kubeStateService] = components.KubeStateService.Tag
log.Infof("Start to create promtheus-adapter")
// Service for prometheus-adapter
if _, err := kubeClient.CoreV1().Services(metav1.NamespaceSystem).Create(ctx, createServiceForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter Service failed: %v", err)
}
// ServiceAccount for prometheus-adapter
if _, err := kubeClient.CoreV1().ServiceAccounts(metav1.NamespaceSystem).Create(ctx, createServiceAccountForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter ServiceAccount failed: %v", err)
}
// ResourceReaderClusterRole for prometheus-adapter
if _, err := kubeClient.RbacV1().ClusterRoles().Create(ctx, createResourceReaderClusterRoleForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter ResourceReaderClusterRole failed: %v", err)
}
// ClusterRole for prometheus-adapter
if _, err := kubeClient.RbacV1().ClusterRoles().Create(ctx, createClusterRoleForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter ClusterRole failed: %v", err)
}
// AuthDelegatorClusterRoleBinding for prometheus-adapter
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, createAuthDelegatorClusterRoleBindingForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter AuthDelegatorClusterRoleBinding failed: %v", err)
}
// ResourceReaderClusterRoleBinding for prometheus-adapter
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, createResourceReaderClusterRoleBindingForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter ResourceReaderClusterRoleBinding failed: %v", err)
}
// HPAClusterRoleBinding for prometheus-adapter
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, createHPAClusterRoleBindingForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter HPAClusterRoleBinding failed: %v", err)
}
// AuthReaderRoleBinding for prometheus-adapter
if _, err := kubeClient.RbacV1().RoleBindings(metav1.NamespaceSystem).Create(ctx, createAuthReaderRoleBingdingForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter AuthReaderRoleBinding failed: %v", err)
}
// APIService for prometheus-adapter
for _, apiservice := range createAPIServiceForPrometheusAdapter() {
if _, err := kaClient.ApiregistrationV1().APIServices().Create(ctx, apiservice, metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter APIService failed: %v", err)
}
}
// ConfigMap for prometheus-adapter
if _, err := kubeClient.CoreV1().ConfigMaps(metav1.NamespaceSystem).Create(ctx, createConfigMapForPrometheusAdapter(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter ConfigMap failed: %v", err)
}
// Deployment for prometheus-adapter
if _, err := kubeClient.AppsV1().Deployments(metav1.NamespaceSystem).Create(ctx, createAppsDeploymentForPrometheusAdapter(components, prometheus), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create prometheus-adapter Deployment failed: %v", err)
}
prometheus.Status.SubVersion[prometheusAdapterService] = components.PrometheusAdapter.Tag
if prometheus.Spec.WithNPD {
// ServiceAccount for node-problem-detector
if _, err := kubeClient.CoreV1().ServiceAccounts(metav1.NamespaceSystem).Create(ctx, createServiceAccountForNPD(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create node-problem-detector ServiceAccount failed: %v", err)
}
// ClusterRole for node-problem-detector
if _, err := kubeClient.RbacV1().ClusterRoles().Create(ctx, createClusterRoleForNPD(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create node-problem-detector ClusterRole failed: %v", err)
}
// ClusterRoleBinding for node-problem-detector
if _, err := kubeClient.RbacV1().ClusterRoleBindings().Create(ctx, createClusterRoleBindingForNPD(), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create node-problem-detector ClusterRoleBinding failed: %v", err)
}
// DaemonSet for node-problem-detector
if _, err := kubeClient.AppsV1().DaemonSets(metav1.NamespaceSystem).Create(ctx, createDaemonSetForNPD(components), metav1.CreateOptions{}); err != nil {
return fmt.Errorf("create node-problem-detector DaemonSet failed: %v", err)
}
prometheus.Status.SubVersion[nodeProblemDetectorWorkload] = components.NodeProblemDetector.Tag
}
return nil
}
var selectorForPrometheusOperator = metav1.LabelSelector{
MatchLabels: map[string]string{specialLabelName: specialLabelValue, "k8s-app": "prometheus-operator"},
}
func servicePrometheusOperator() *corev1.Service {
return &corev1.Service{
TypeMeta: metav1.TypeMeta{
Kind: "Service",
APIVersion: "v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: PrometheusOperatorService,
Namespace: metav1.NamespaceSystem,
Labels: map[string]string{"kubernetes.io/name": "Prometheus-Operator", "addonmanager.kubernetes.io/mode": "Reconcile", "kubernetes.io/cluster-service": "true"},
},
Spec: corev1.ServiceSpec{
Selector: selectorForPrometheusOperator.MatchLabels,
Ports: []corev1.ServicePort{
{Name: PrometheusOperatorServicePort, Port: 8080, TargetPort: intstr.FromInt(8080), Protocol: corev1.ProtocolTCP},
},
},
}
}
func serviceAccountPrometheusOperator() *corev1.ServiceAccount {
return &corev1.ServiceAccount{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "ServiceAccount",
},
ObjectMeta: metav1.ObjectMeta{
Name: prometheusOperatorServiceAccount,
Namespace: metav1.NamespaceSystem,
Labels: map[string]string{"kubernetes.io/cluster-service": "true", "addonmanager.kubernetes.io/mode": "Reconcile"},
},
}
}
func clusterRolePrometheusOperator() *rbacv1.ClusterRole {
return &rbacv1.ClusterRole{
TypeMeta: metav1.TypeMeta{
APIVersion: "rbac.authorization.k8s.io/v1beta1",
Kind: "ClusterRole",
},
ObjectMeta: metav1.ObjectMeta{
Name: prometheusOperatorClusterRole,
Labels: map[string]string{"kubernetes.io/cluster-service": "true", "addonmanager.kubernetes.io/mode": "Reconcile"},
},
Rules: []rbacv1.PolicyRule{
{
APIGroups: []string{"apiextensions.k8s.io"},
Resources: []string{"customresourcedefinitions"},
Verbs: []string{"*"},
},
{
APIGroups: []string{monitoring.GroupName},
Resources: []string{"alertmanagers", "prometheuses", "prometheuses/finalizers", "alertmanagers/finalizers", "servicemonitors", "podmonitors", "prometheusrules"},
Verbs: []string{"*"},
},
{
APIGroups: []string{"apps"},
Resources: []string{"statefulsets"},
Verbs: []string{"*"},
},
{
APIGroups: []string{""},
Resources: []string{"configmaps", "secrets"},
Verbs: []string{"*"},
},
{
APIGroups: []string{""},
Resources: []string{"pods"},
Verbs: []string{"list", "delete"},
},
{
APIGroups: []string{""},
Resources: []string{"services", "services/finalizers", "endpoints"},
Verbs: []string{"get", "create", "update", "delete"},
},
{
APIGroups: []string{""},
Resources: []string{"nodes"},
Verbs: []string{"list", "watch"},
},
{
APIGroups: []string{""},
Resources: []string{"namespaces"},
Verbs: []string{"list", "watch", "get"},
},
},
}
}
func clusterRoleBindingPrometheusOperator() *rbacv1.ClusterRoleBinding {
return &rbacv1.ClusterRoleBinding{
TypeMeta: metav1.TypeMeta{
Kind: "ClusterRoleBinding",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: prometheusOperatorClusterRoleBinding,
Labels: map[string]string{"kubernetes.io/cluster-service": "true", "addonmanager.kubernetes.io/mode": "Reconcile"},
},
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole",