when mhc is managed create an alert for frequent remediation (#2123)

This commit is contained in:
Spencer Amann 2022-05-31 13:34:48 +00:00 коммит произвёл GitHub
Родитель 8753830fda
Коммит 7bba674b3a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
18 изменённых файлов: 4075 добавлений и 18 удалений

Просмотреть файл

@ -116,11 +116,7 @@ questions or comments.
* machineset: Ensures that a minimum of two worker replicas are met.
* machinehealthcheck: Ensures the MachineHealthCheck resource is running as configured so that at most one worker node at a time is automatically
reconciled when not ready for at least 5 minutes.
* The CR will only be applied when both `aro.machinehealthcheck.managed` and `aro.machinehealthcheck.enabled` are set to `"true"`.
* When `aro.machinehealthcheck.enabled` is `"false"` and `aro.machinehealthcheck.managed` is `"false"` the CR will be removed from the cluster.
* If `aro.machinehealthcheck.enabled` is `"false"` no actions will be taken to modify the CR.
* machinehealthcheck: Ensures the MachineHealthCheck resource is running as configured. See [machinehealthcheck/doc.go](pkg/operator/controllers/machinehealthcheck/doc.go)
* More information around the MHC CR can be found [in openshift documentation of MHC](https://docs.openshift.com/container-platform/4.9/machine_management/deploying-machine-health-checks.html)
* monitoring: Ensures that the OpenShift monitoring configuration in the `openshift-monitoring` namespace is consistent and immutable.

1
go.mod
Просмотреть файл

@ -48,6 +48,7 @@ require (
github.com/openshift/machine-config-operator v3.11.0+incompatible
github.com/pires/go-proxyproto v0.6.2
github.com/pkg/errors v0.9.1
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.48.1
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/common v0.33.0
github.com/sirupsen/logrus v1.8.1

1
go.sum
Просмотреть файл

@ -2348,6 +2348,7 @@ github.com/proglottis/gpgme v0.1.1/go.mod h1:fPbW/EZ0LvwQtH8Hy7eixhp1eF3G39dtx7G
github.com/prometheus-community/prom-label-proxy v0.2.0/go.mod h1:XdjyZg7LCbCC5FADHtpgNp6kQ0W9beXVGfmcvndMj5Y=
github.com/prometheus-operator/prometheus-operator v0.48.1/go.mod h1:lXJz0R74XkhfLwsw5mIeLPJZOVIQp6kQyMyMjOU+MWY=
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.44.1/go.mod h1:3WYi4xqXxGGXWDdQIITnLNmuDzO5n6wYva9spVhR4fg=
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.48.1 h1:OGC7+ktZ6h8xI99VB6i8iuiXecdhUmwto9vbGzoVMac=
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.48.1/go.mod h1:3WYi4xqXxGGXWDdQIITnLNmuDzO5n6wYva9spVhR4fg=
github.com/prometheus-operator/prometheus-operator/pkg/client v0.48.1/go.mod h1:k4BrWlVQQsvBiTcDnKEMgyh/euRxyxgrHdur/ZX/sdA=
github.com/prometheus/alertmanager v0.20.0/go.mod h1:9g2i48FAyZW6BtbsnvHtMHQXl2aVtrORKwKVCQ+nbrg=

Просмотреть файл

@ -157,6 +157,8 @@ func acceptableNames(path string) []string {
return []string{"coreosarch"}
case "github.com/openshift/installer/pkg/rhcos":
return []string{"rhcospkg"}
case "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1":
return []string{"monitoringv1"}
case "golang.org/x/crypto/ssh":
return []string{"", "cryptossh"}
case "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1":

Просмотреть файл

@ -1,6 +1,7 @@
// Code generated for package machinehealthcheck by go-bindata DO NOT EDIT. (@generated)
// sources:
// staticresources/machinehealthcheck.yaml
// staticresources/mhcremediationalert.yaml
package machinehealthcheck
import (
@ -97,6 +98,26 @@ func machinehealthcheckYaml() (*asset, error) {
return a, nil
}
var _mhcremediationalertYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\x91\x4d\x8b\x14\x4d\x10\x84\xef\xfd\x2b\xe2\xf8\xbe\x87\x5e\x5d\x0f\x22\x75\x10\x44\x84\xbd\x2c\xc8\x08\x5e\x44\x86\x9c\xea\x70\xaa\x98\xfa\x68\x32\xb3\x67\xdd\x7f\x2f\xdd\xd3\xea\x5e\xcc\x63\x55\x3e\x11\x4f\x51\x32\xe7\xaf\x54\xcb\xbd\x05\xd4\xde\xb2\x77\xcd\xed\x7c\x17\xbb\xb2\xdb\x5d\xec\xf5\xd5\xf5\x7e\xb8\xe4\x36\x05\x7c\xd6\x5e\xe9\x89\x8b\x1d\x96\xc2\xa1\xd2\x65\x12\x97\x30\x00\x4d\x2a\x03\x6a\x8a\xa3\xb2\x72\xca\xe2\xb9\xb7\x51\x0a\xd5\xf7\x5b\x9b\x25\x32\xa0\xcf\x6c\x96\xf2\x0f\x1f\xab\xc4\x94\x1b\x47\x99\xf3\x00\x14\x39\xb1\xd8\x1a\x05\xcc\x7f\x7a\x02\x2e\xef\x6c\x3b\xd3\x5e\x18\xb0\x05\x8e\xba\x14\xda\x60\x33\xe3\xba\x7f\xd6\xbe\xcc\x1b\x39\xee\x1a\xa6\x1c\xff\xa5\x02\x6c\xf4\xad\x68\xbc\x05\x06\x7c\x39\x7c\x7a\xbc\xe9\x3c\x50\x8a\xa7\x8f\x89\xf1\x72\xf8\x8b\x1f\xc4\xf9\x90\xcf\x69\xa3\x00\xfe\x9c\x35\x20\xb7\xa8\x14\xe3\x7f\x55\xe6\x7c\xdc\x9f\x93\x36\x3e\xae\xfc\xf1\x45\xff\xd1\x96\x18\x69\x76\xf4\xee\x52\xf0\xed\xed\xeb\xfa\xfd\x7f\xbc\xc7\xfd\x9e\xf8\xa1\xb5\xee\xdb\xe6\xae\xb6\xce\x23\xcd\xe4\xcc\x00\x3c\x75\xbd\x50\xd1\xfa\x44\x43\x92\x2b\x71\x22\x1b\x7e\x17\x70\xc2\x1b\x74\x45\xed\x4a\x78\xae\x34\xe4\x06\x4f\x44\x11\x73\xa4\xbe\x28\x3c\x65\x43\x95\x67\xe4\x36\xe5\x28\x4e\x48\xc3\xd2\xcc\xe5\x54\xb8\x15\x94\x2e\x13\x74\x69\x2d\xb7\x33\xfa\x8d\x8f\x65\x31\xa7\xee\x4a\x2f\x3f\x69\x1d\xe3\x95\x9a\xfd\x39\xe0\x49\x74\xc5\x86\x5f\x01\x00\x00\xff\xff\x76\x45\x90\xe0\x4e\x02\x00\x00")
func mhcremediationalertYamlBytes() ([]byte, error) {
return bindataRead(
_mhcremediationalertYaml,
"mhcremediationalert.yaml",
)
}
func mhcremediationalertYaml() (*asset, error) {
bytes, err := mhcremediationalertYamlBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "mhcremediationalert.yaml", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
// Asset loads and returns the asset for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
@ -149,7 +170,8 @@ func AssetNames() []string {
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"machinehealthcheck.yaml": machinehealthcheckYaml,
"machinehealthcheck.yaml": machinehealthcheckYaml,
"mhcremediationalert.yaml": mhcremediationalertYaml,
}
// AssetDir returns the file names below a certain
@ -193,7 +215,8 @@ type bintree struct {
}
var _bintree = &bintree{nil, map[string]*bintree{
"machinehealthcheck.yaml": {machinehealthcheckYaml, map[string]*bintree{}},
"machinehealthcheck.yaml": {machinehealthcheckYaml, map[string]*bintree{}},
"mhcremediationalert.yaml": {mhcremediationalertYaml, map[string]*bintree{}},
}}
// RestoreAsset restores an asset under the given directory

Просмотреть файл

@ -5,8 +5,9 @@ package machinehealthcheck
/*
The controller in this package aims to ensure that MachineHealthCheck objects
exist and are correctly configured to automatically mitigate non-ready worker nodes.
The controller in this package aims to ensure the ARO MachineHealthCheck CR and MHC Remediation Alert
exist and are correctly configured to automatically mitigate non-ready worker nodes and create an in-cluster alert
when remediation is occuring frequently.
There are two flags which control the operations performed by the controller:
@ -15,10 +16,11 @@ aro.machinehealthcheck.enabled:
- When set to true, the controller continues on to check the managed flag
aro.machinehealthcheck.managed
- When set to false, the controller will attempt to remove the aro-machinehealthcheck CR from the cluster.
- When set to false, the controller will attempt to remove the aro-machinehealthcheck CR and the MHC Remediation alert from the cluster.
This should effectively disable the MHC we deploy and prevent the automatic reconciliation of nodes.
- When set to true, the controller will deploy/overwrite the aro-machinehealthcheck CR to the cluster.
This enables the cluster to self heal when at most 1 worker node goes not ready for at least 5 minutes.
- When set to true, the controller will deploy/overwrite the aro-machinehealthcheck CR and the MHC Remediation alert to the cluster.
This enables the cluster to self heal when at most 1 worker node goes not ready for at least 5 minutes and alert when remediation
occurs 2 or more times within an hour.
The aro-machinehealth check is configured in a way that if 2 worker nodes go not ready it will not take any action.
More information about how the MHC works can be found here:

Просмотреть файл

@ -52,10 +52,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
if err != nil {
return reconcile.Result{RequeueAfter: time.Hour}, err
}
err = r.dh.EnsureDeleted(ctx, "PrometheusRule", "openshift-machine-api", "mhc-remediation-alert")
if err != nil {
return reconcile.Result{RequeueAfter: time.Hour}, err
}
return reconcile.Result{}, nil
}
var resources []kruntime.Object
// this loop prevents us from hard coding resource strings
// and ensures all static resources are accounted for.
for _, assetName := range AssetNames() {

Просмотреть файл

@ -60,7 +60,7 @@ func TestReconciler(t *testing.T) {
wantErr: "",
},
{
name: "Managed Feature Flag is false: ensure mhc is deleted",
name: "Managed Feature Flag is false: ensure mhc and its alert are deleted",
arocli: arofake.NewSimpleClientset(&arov1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: arov1alpha1.SingletonClusterName,
@ -74,6 +74,7 @@ func TestReconciler(t *testing.T) {
}),
mocks: func(mdh *mock_dynamichelper.MockInterface) {
mdh.EXPECT().EnsureDeleted(gomock.Any(), "MachineHealthCheck", "openshift-machine-api", "aro-machinehealthcheck").Times(1)
mdh.EXPECT().EnsureDeleted(gomock.Any(), "PrometheusRule", "openshift-machine-api", "mhc-remediation-alert").Times(1)
},
wantErr: "",
},
@ -96,6 +97,26 @@ func TestReconciler(t *testing.T) {
wantErr: "Could not delete mhc",
wantRequeueAfter: time.Hour,
},
{
name: "Managed Feature Flag is false: mhc deletes but mhc alert fails to delete, an error is returned",
arocli: arofake.NewSimpleClientset(&arov1alpha1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: arov1alpha1.SingletonClusterName,
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
enabled: strconv.FormatBool(true),
managed: strconv.FormatBool(false),
},
},
}),
mocks: func(mdh *mock_dynamichelper.MockInterface) {
mdh.EXPECT().EnsureDeleted(gomock.Any(), "MachineHealthCheck", "openshift-machine-api", "aro-machinehealthcheck").Times(1)
mdh.EXPECT().EnsureDeleted(gomock.Any(), "PrometheusRule", "openshift-machine-api", "mhc-remediation-alert").Return(errors.New("Could not delete mhc alert"))
},
wantErr: "Could not delete mhc alert",
wantRequeueAfter: time.Hour,
},
{
name: "Managed Feature Flag is true: dynamic helper ensures resources",
arocli: arofake.NewSimpleClientset(&arov1alpha1.Cluster{
@ -142,10 +163,7 @@ func TestReconciler(t *testing.T) {
tt.mocks(mdh)
ctx := context.Background()
r := &Reconciler{
arocli: tt.arocli,
dh: mdh,
}
r := NewReconciler(tt.arocli, mdh)
request := ctrl.Request{}
request.Name = "cluster"

Просмотреть файл

@ -0,0 +1,18 @@
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: mhc-remediation-alert
namespace: openshift-machine-api
labels:
prometheus: k8s
role: alert-rules
spec:
groups:
- name: sre-mhc-remediation-alert
rules:
- alert: SREMachineHealthCheckRemediationRateHigh
expr: increase(mapi_machinehealthcheck_remediation_success_total [60m]) > 1
Annotations:
Message: worker nodes have been remediated 2 or more times in the last hour this may indicate an unstable workload running on the cluster
labels:
severity: warning

Просмотреть файл

@ -9,6 +9,7 @@ import (
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
securityv1 "github.com/openshift/api/security/v1"
mcv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
@ -39,7 +40,7 @@ func init() {
utilruntime.Must(rbacv1defaults.RegisterDefaults(scheme.Scheme))
utilruntime.Must(machinev1beta1.AddToScheme(scheme.Scheme))
utilruntime.Must(consolev1.AddToScheme(scheme.Scheme))
utilruntime.Must(monitoringv1.AddToScheme(scheme.Scheme))
// AzureMachineProviderSpec is not registered by default
scheme.Scheme.AddKnownTypes(machinev1beta1.GroupVersion, &machinev1beta1.AzureMachineProviderSpec{})
}

202
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/LICENSE сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
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
http://www.apache.org/licenses/LICENSE-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 OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

19
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/register.go сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,19 @@
// Copyright 2018 The prometheus-operator Authors
//
// 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
//
// http://www.apache.org/licenses/LICENSE-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 OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package monitoring
const (
GroupName = "monitoring.coreos.com"
)

18
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/doc.go сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,18 @@
// Copyright 2017 The prometheus-operator Authors
//
// 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
//
// http://www.apache.org/licenses/LICENSE-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 OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// +k8s:deepcopy-gen=package
// +groupName=monitoring.coreos.com
package v1

67
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/register.go сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,67 @@
// Copyright 2018 The prometheus-operator Authors
//
// 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
//
// http://www.apache.org/licenses/LICENSE-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 OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring"
)
// SchemeGroupVersion is the group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: monitoring.GroupName, Version: Version}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
var (
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Prometheus{},
&PrometheusList{},
&ServiceMonitor{},
&ServiceMonitorList{},
&PodMonitor{},
&PodMonitorList{},
&Probe{},
&ProbeList{},
&Alertmanager{},
&AlertmanagerList{},
&PrometheusRule{},
&PrometheusRuleList{},
&ThanosRuler{},
&ThanosRulerList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}

220
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/thanos_types.go сгенерированный поставляемый Normal file
Просмотреть файл

@ -0,0 +1,220 @@
// Copyright 2020 The prometheus-operator Authors
//
// 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
//
// http://www.apache.org/licenses/LICENSE-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 OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package v1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
const (
ThanosRulerKind = "ThanosRuler"
ThanosRulerName = "thanosrulers"
ThanosRulerKindKey = "thanosrulers"
)
// ThanosRuler defines a ThanosRuler deployment.
// +genclient
// +k8s:openapi-gen=true
// +kubebuilder:resource:categories="prometheus-operator"
type ThanosRuler struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// Specification of the desired behavior of the ThanosRuler cluster. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
Spec ThanosRulerSpec `json:"spec"`
// Most recent observed status of the ThanosRuler cluster. Read-only. Not
// included when requesting from the apiserver, only from the ThanosRuler
// Operator API itself. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
Status *ThanosRulerStatus `json:"status,omitempty"`
}
// ThanosRulerList is a list of ThanosRulers.
// +k8s:openapi-gen=true
type ThanosRulerList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata
metav1.ListMeta `json:"metadata,omitempty"`
// List of Prometheuses
Items []*ThanosRuler `json:"items"`
}
// ThanosRulerSpec is a specification of the desired behavior of the ThanosRuler. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
// +k8s:openapi-gen=true
type ThanosRulerSpec struct {
// PodMetadata contains Labels and Annotations gets propagated to the thanos ruler pods.
PodMetadata *EmbeddedObjectMetadata `json:"podMetadata,omitempty"`
// Thanos container image URL.
Image string `json:"image,omitempty"`
// An optional list of references to secrets in the same namespace
// to use for pulling thanos images from registries
// see http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// When a ThanosRuler deployment is paused, no actions except for deletion
// will be performed on the underlying objects.
Paused bool `json:"paused,omitempty"`
// Number of thanos ruler instances to deploy.
Replicas *int32 `json:"replicas,omitempty"`
// Define which Nodes the Pods are scheduled on.
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Resources defines the resource requirements for single Pods.
// If not provided, no requests/limits will be set
Resources v1.ResourceRequirements `json:"resources,omitempty"`
// If specified, the pod's scheduling constraints.
Affinity *v1.Affinity `json:"affinity,omitempty"`
// If specified, the pod's tolerations.
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
// If specified, the pod's topology spread constraints.
TopologySpreadConstraints []v1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
// SecurityContext holds pod-level security attributes and common container settings.
// This defaults to the default PodSecurityContext.
SecurityContext *v1.PodSecurityContext `json:"securityContext,omitempty"`
// Priority class assigned to the Pods
PriorityClassName string `json:"priorityClassName,omitempty"`
// ServiceAccountName is the name of the ServiceAccount to use to run the
// Thanos Ruler Pods.
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// Storage spec to specify how storage shall be used.
Storage *StorageSpec `json:"storage,omitempty"`
// Volumes allows configuration of additional volumes on the output StatefulSet definition. Volumes specified will
// be appended to other volumes that are generated as a result of StorageSpec objects.
Volumes []v1.Volume `json:"volumes,omitempty"`
// ObjectStorageConfig configures object storage in Thanos.
// Alternative to ObjectStorageConfigFile, and lower order priority.
ObjectStorageConfig *v1.SecretKeySelector `json:"objectStorageConfig,omitempty"`
// ObjectStorageConfigFile specifies the path of the object storage configuration file.
// When used alongside with ObjectStorageConfig, ObjectStorageConfigFile takes precedence.
ObjectStorageConfigFile *string `json:"objectStorageConfigFile,omitempty"`
// ListenLocal makes the Thanos ruler listen on loopback, so that it
// does not bind against the Pod IP.
ListenLocal bool `json:"listenLocal,omitempty"`
// QueryEndpoints defines Thanos querier endpoints from which to query metrics.
// Maps to the --query flag of thanos ruler.
QueryEndpoints []string `json:"queryEndpoints,omitempty"`
// Define configuration for connecting to thanos query instances.
// If this is defined, the QueryEndpoints field will be ignored.
// Maps to the `query.config` CLI argument.
// Only available with thanos v0.11.0 and higher.
QueryConfig *v1.SecretKeySelector `json:"queryConfig,omitempty"`
// Define URLs to send alerts to Alertmanager. For Thanos v0.10.0 and higher,
// AlertManagersConfig should be used instead. Note: this field will be ignored
// if AlertManagersConfig is specified.
// Maps to the `alertmanagers.url` arg.
AlertManagersURL []string `json:"alertmanagersUrl,omitempty"`
// Define configuration for connecting to alertmanager. Only available with thanos v0.10.0
// and higher. Maps to the `alertmanagers.config` arg.
AlertManagersConfig *v1.SecretKeySelector `json:"alertmanagersConfig,omitempty"`
// A label selector to select which PrometheusRules to mount for alerting and
// recording.
RuleSelector *metav1.LabelSelector `json:"ruleSelector,omitempty"`
// Namespaces to be selected for Rules discovery. If unspecified, only
// the same namespace as the ThanosRuler object is in is used.
RuleNamespaceSelector *metav1.LabelSelector `json:"ruleNamespaceSelector,omitempty"`
// EnforcedNamespaceLabel enforces adding a namespace label of origin for each alert
// and metric that is user created. The label value will always be the namespace of the object that is
// being created.
EnforcedNamespaceLabel string `json:"enforcedNamespaceLabel,omitempty"`
// PrometheusRulesExcludedFromEnforce - list of Prometheus rules to be excluded from enforcing
// of adding namespace labels. Works only if enforcedNamespaceLabel set to true.
// Make sure both ruleNamespace and ruleName are set for each pair
PrometheusRulesExcludedFromEnforce []PrometheusRuleExcludeConfig `json:"prometheusRulesExcludedFromEnforce,omitempty"`
// Log level for ThanosRuler to be configured with.
LogLevel string `json:"logLevel,omitempty"`
// Log format for ThanosRuler to be configured with.
LogFormat string `json:"logFormat,omitempty"`
// Port name used for the pods and governing service.
// This defaults to web
PortName string `json:"portName,omitempty"`
// Interval between consecutive evaluations.
EvaluationInterval string `json:"evaluationInterval,omitempty"`
// Time duration ThanosRuler shall retain data for. Default is '24h',
// and must match the regular expression `[0-9]+(ms|s|m|h|d|w|y)` (milliseconds seconds minutes hours days weeks years).
Retention string `json:"retention,omitempty"`
// Containers allows injecting additional containers or modifying operator generated
// containers. This can be used to allow adding an authentication proxy to a ThanosRuler pod or
// to change the behavior of an operator generated container. Containers described here modify
// an operator generated container if they share the same name and modifications are done via a
// strategic merge patch. The current container names are: `thanos-ruler` and `config-reloader`.
// Overriding containers is entirely outside the scope of what the maintainers will support and by doing
// so, you accept that this behaviour may break at any time without notice.
Containers []v1.Container `json:"containers,omitempty"`
// InitContainers allows adding initContainers to the pod definition. Those can be used to e.g.
// fetch secrets for injection into the ThanosRuler configuration from external sources. Any
// errors during the execution of an initContainer will lead to a restart of the Pod.
// More info: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
// Using initContainers for any use case other then secret fetching is entirely outside the scope
// of what the maintainers will support and by doing so, you accept that this behaviour may break
// at any time without notice.
InitContainers []v1.Container `json:"initContainers,omitempty"`
// TracingConfig configures tracing in Thanos. This is an experimental feature, it may change in any upcoming release in a breaking way.
TracingConfig *v1.SecretKeySelector `json:"tracingConfig,omitempty"`
// Labels configure the external label pairs to ThanosRuler. If not provided, default replica label
// `thanos_ruler_replica` will be added as a label and be dropped in alerts.
Labels map[string]string `json:"labels,omitempty"`
// AlertDropLabels configure the label names which should be dropped in ThanosRuler alerts.
// If `labels` field is not provided, `thanos_ruler_replica` will be dropped in alerts by default.
AlertDropLabels []string `json:"alertDropLabels,omitempty"`
// The external URL the Thanos Ruler instances will be available under. This is
// necessary to generate correct URLs. This is necessary if Thanos Ruler is not
// served from root of a DNS name.
ExternalPrefix string `json:"externalPrefix,omitempty"`
// The route prefix ThanosRuler registers HTTP handlers for. This allows thanos UI to be served on a sub-path.
RoutePrefix string `json:"routePrefix,omitempty"`
// GRPCServerTLSConfig configures the gRPC server from which Thanos Querier reads
// recorded rule data.
// Note: Currently only the CAFile, CertFile, and KeyFile fields are supported.
// Maps to the '--grpc-server-tls-*' CLI args.
GRPCServerTLSConfig *TLSConfig `json:"grpcServerTlsConfig,omitempty"`
// The external Query URL the Thanos Ruler will set in the 'Source' field
// of all alerts.
// Maps to the '--alert.query-url' CLI arg.
AlertQueryURL string `json:"alertQueryUrl,omitempty"`
}
// ThanosRulerStatus is the most recent observed status of the ThanosRuler. Read-only. Not
// included when requesting from the apiserver, only from the Prometheus
// Operator API itself. More info:
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
// +k8s:openapi-gen=true
type ThanosRulerStatus struct {
// Represents whether any actions on the underlying managed objects are
// being performed. Only delete actions will be performed.
Paused bool `json:"paused"`
// Total number of non-terminated pods targeted by this ThanosRuler deployment
// (their labels match the selector).
Replicas int32 `json:"replicas"`
// Total number of non-terminated pods targeted by this ThanosRuler deployment
// that have the desired version spec.
UpdatedReplicas int32 `json:"updatedReplicas"`
// Total number of available pods (ready for at least minReadySeconds)
// targeted by this ThanosRuler deployment.
AvailableReplicas int32 `json:"availableReplicas"`
// Total number of unavailable pods targeted by this ThanosRuler deployment.
UnavailableReplicas int32 `json:"unavailableReplicas"`
}
// DeepCopyObject implements the runtime.Object interface.
func (l *ThanosRuler) DeepCopyObject() runtime.Object {
return l.DeepCopy()
}
// DeepCopyObject implements the runtime.Object interface.
func (l *ThanosRulerList) DeepCopyObject() runtime.Object {
return l.DeepCopy()
}

1484
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/types.go сгенерированный поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

1975
vendor/github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1/zz_generated.deepcopy.go сгенерированный поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

4
vendor/modules.txt поставляемый
Просмотреть файл

@ -1253,6 +1253,10 @@ github.com/pquerna/cachecontrol/cacheobject
# github.com/proglottis/gpgme v0.1.1
## explicit; go 1.11
github.com/proglottis/gpgme
# github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.48.1
## explicit; go 1.14
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1
# github.com/prometheus/client_golang v1.12.1
## explicit; go 1.13
github.com/prometheus/client_golang/prometheus