Skip to content

Commit

Permalink
Create ServiceMonitor in the same namespace as the operator (#158)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Oct 20, 2020
1 parent 3cb27a1 commit 2709602
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 155 deletions.
16 changes: 8 additions & 8 deletions api/crds/bindata.go

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions api/crds/installer.kubedb.com_kubedbenterprises.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,6 @@ spec:
type: string
enabled:
type: boolean
prometheus:
properties:
namespace:
type: string
type: object
serviceMonitor:
properties:
labels:
Expand All @@ -735,7 +730,6 @@ spec:
type: object
required:
- agent
- prometheus
- serviceMonitor
type: object
nameOverride:
Expand Down
6 changes: 0 additions & 6 deletions api/crds/installer.kubedb.com_kubedbenterprises.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -701,11 +701,6 @@ spec:
type: string
enabled:
type: boolean
prometheus:
properties:
namespace:
type: string
type: object
serviceMonitor:
properties:
labels:
Expand All @@ -715,7 +710,6 @@ spec:
type: object
required:
- agent
- prometheus
- serviceMonitor
type: object
nameOverride:
Expand Down
6 changes: 0 additions & 6 deletions api/crds/installer.kubedb.com_kubedboperators.v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,6 @@ spec:
type: string
enabled:
type: boolean
prometheus:
properties:
namespace:
type: string
type: object
serviceMonitor:
properties:
labels:
Expand All @@ -735,7 +730,6 @@ spec:
type: object
required:
- agent
- prometheus
- serviceMonitor
type: object
nameOverride:
Expand Down
6 changes: 0 additions & 6 deletions api/crds/installer.kubedb.com_kubedboperators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,6 @@ spec:
type: string
enabled:
type: boolean
prometheus:
properties:
namespace:
type: string
type: object
serviceMonitor:
properties:
labels:
Expand All @@ -720,7 +715,6 @@ spec:
type: object
required:
- agent
- prometheus
- serviceMonitor
type: object
nameOverride:
Expand Down
12 changes: 0 additions & 12 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@
"type": "object",
"required": [
"agent",
"prometheus",
"serviceMonitor"
],
"properties": {
Expand All @@ -1065,9 +1064,6 @@
"enabled": {
"type": "boolean"
},
"prometheus": {
"$ref": "#/definitions/dev.kubedb.installer.apis.installer.v1alpha1.PrometheusSpec"
},
"serviceMonitor": {
"$ref": "#/definitions/dev.kubedb.installer.apis.installer.v1alpha1.ServiceMonitorLabels"
}
Expand Down Expand Up @@ -1100,14 +1096,6 @@
}
}
},
"dev.kubedb.installer.apis.installer.v1alpha1.PrometheusSpec": {
"type": "object",
"properties": {
"namespace": {
"type": "string"
}
}
},
"dev.kubedb.installer.apis.installer.v1alpha1.ServiceAccountSpec": {
"type": "object",
"required": [
Expand Down
6 changes: 0 additions & 6 deletions apis/installer/v1alpha1/kubedb_operator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,9 @@ type Monitoring struct {
// +optional
Enabled bool `json:"enabled"`
Agent string `json:"agent"`
Prometheus *PrometheusSpec `json:"prometheus"`
ServiceMonitor *ServiceMonitorLabels `json:"serviceMonitor"`
}

type PrometheusSpec struct {
// +optional
Namespace string `json:"namespace"`
}

type ServiceMonitorLabels struct {
// +optional
Labels map[string]string `json:"labels"`
Expand Down
28 changes: 2 additions & 26 deletions apis/installer/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion charts/kubedb-enterprise/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ The following table lists the configurable parameters of the `kubedb-enterprise`
| enableAnalytics | If true, sends usage analytics | `true` |
| monitoring.enabled | If true, enables monitoring KubeDB operator | `false` |
| monitoring.agent | Name of monitoring agent (either "prometheus.io/operator" or "prometheus.io/builtin") | `"none"` |
| monitoring.prometheus.namespace | Specify the namespace where Prometheus server is running or will be deployed. | `""` |
| monitoring.serviceMonitor.labels | Specify the labels for ServiceMonitor. Prometheus crd will select ServiceMonitor using these labels. Only usable when monitoring agent is `prometheus.io/operator`. | `{}` |
| additionalPodSecurityPolicies | Additional psp names passed to operator <br> Example: <br> `helm template ./chart/kubedb-enterprise \` <br> `--set additionalPodSecurityPolicies[0]=abc \` <br> `--set additionalPodSecurityPolicies[1]=xyz` | `[]` |

Expand Down
17 changes: 0 additions & 17 deletions charts/kubedb-enterprise/templates/apiregistration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@ data:
tls.crt: {{ $serverCrt }}
tls.key: {{ $serverKey }}
---
{{ $promNamespace:= default .Release.Namespace .Values.monitoring.prometheus.namespace }}
{{- if (and (ne $promNamespace .Release.Namespace) .Values.monitoring.enabled) }}
# if operator monitoring is enabled and prometheus namespace is different than operator
# create the above secret in prometheus namespace too.
apiVersion: v1
kind: Secret
metadata:
name: {{ include "kubedb-enterprise.fullname" . }}-apiserver-cert
namespace: {{ $promNamespace }}
labels:
{{- include "kubedb-enterprise.labels" . | nindent 4 }}
type: kubernetes.io/tls
data:
tls.crt: {{ $serverCrt }}
tls.key: {{ $serverKey }}
---
{{ end }}
# to read the config for terminating authentication
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down
6 changes: 5 additions & 1 deletion charts/kubedb-enterprise/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "kubedb-enterprise.fullname" . }}
namespace: {{ default .Release.Namespace .Values.monitoring.prometheus.namespace }}
namespace: {{ .Release.Namespace }}
labels:
{{- if .Values.monitoring.serviceMonitor.labels }}
{{- range $key, $val := .Values.monitoring.serviceMonitor.labels }}
Expand All @@ -24,6 +24,10 @@ spec:
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
scheme: https
tlsConfig:
ca:
secret:
name: {{ include "kubedb-enterprise.fullname" . }}-apiserver-cert
key: tls.crt
caFile: /etc/prometheus/secrets/{{ include "kubedb-enterprise.fullname" . }}-apiserver-cert/tls.crt
serverName: "{{ include "kubedb-enterprise.fullname" . }}.{{ .Release.Namespace }}.svc"
{{- end }}
6 changes: 0 additions & 6 deletions charts/kubedb-enterprise/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,6 @@ properties:
type: string
enabled:
type: boolean
prometheus:
properties:
namespace:
type: string
type: object
serviceMonitor:
properties:
labels:
Expand All @@ -645,7 +640,6 @@ properties:
type: object
required:
- agent
- prometheus
- serviceMonitor
type: object
nameOverride:
Expand Down
4 changes: 0 additions & 4 deletions charts/kubedb-enterprise/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ monitoring:
enabled: false
# Name of monitoring agent (either "prometheus.io/operator" or "prometheus.io/builtin")
agent: "none"
# specify where ServiceMonitor crd will be created
prometheus:
# Specify the namespace where Prometheus server is running or will be deployed.
namespace: ""
serviceMonitor:
# Specify the labels for ServiceMonitor.
# Prometheus crd will select ServiceMonitor using these labels.
Expand Down
1 change: 0 additions & 1 deletion charts/kubedb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ The following table lists the configurable parameters of the `kubedb` chart and
| enableAnalytics | If true, sends usage analytics | `true` |
| monitoring.enabled | If true, enables monitoring KubeDB operator | `false` |
| monitoring.agent | Name of monitoring agent (either "prometheus.io/operator" or "prometheus.io/builtin") | `"none"` |
| monitoring.prometheus.namespace | Specify the namespace where Prometheus server is running or will be deployed. | `""` |
| monitoring.serviceMonitor.labels | Specify the labels for ServiceMonitor. Prometheus crd will select ServiceMonitor using these labels. Only usable when monitoring agent is `prometheus.io/operator`. | `{}` |
| additionalPodSecurityPolicies | Additional psp names passed to operator <br> Example: <br> `helm template ./chart/kubedb \` <br> `--set additionalPodSecurityPolicies[0]=abc \` <br> `--set additionalPodSecurityPolicies[1]=xyz` | `[]` |

Expand Down
17 changes: 0 additions & 17 deletions charts/kubedb/templates/apiregistration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,6 @@ data:
tls.crt: {{ $serverCrt }}
tls.key: {{ $serverKey }}
---
{{ $promNamespace:= default .Release.Namespace .Values.monitoring.prometheus.namespace }}
{{- if (and (ne $promNamespace .Release.Namespace) .Values.monitoring.enabled) }}
# if operator monitoring is enabled and prometheus namespace is different than operator
# create the above secret in prometheus namespace too.
apiVersion: v1
kind: Secret
metadata:
name: {{ include "kubedb.fullname" . }}-apiserver-cert
namespace: {{ $promNamespace }}
labels:
{{- include "kubedb.labels" . | nindent 4 }}
type: kubernetes.io/tls
data:
tls.crt: {{ $serverCrt }}
tls.key: {{ $serverKey }}
---
{{ end }}
# to read the config for terminating authentication
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down
6 changes: 5 additions & 1 deletion charts/kubedb/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "kubedb.fullname" . }}
namespace: {{ default .Release.Namespace .Values.monitoring.prometheus.namespace }}
namespace: {{ .Release.Namespace }}
labels:
{{- if .Values.monitoring.serviceMonitor.labels }}
{{- range $key, $val := .Values.monitoring.serviceMonitor.labels }}
Expand All @@ -24,6 +24,10 @@ spec:
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
scheme: https
tlsConfig:
ca:
secret:
name: {{ include "kubedb.fullname" . }}-apiserver-cert
key: tls.crt
caFile: /etc/prometheus/secrets/{{ include "kubedb.fullname" . }}-apiserver-cert/tls.crt
serverName: "{{ include "kubedb.fullname" . }}.{{ .Release.Namespace }}.svc"
{{- end }}
6 changes: 0 additions & 6 deletions charts/kubedb/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,6 @@ properties:
type: string
enabled:
type: boolean
prometheus:
properties:
namespace:
type: string
type: object
serviceMonitor:
properties:
labels:
Expand All @@ -645,7 +640,6 @@ properties:
type: object
required:
- agent
- prometheus
- serviceMonitor
type: object
nameOverride:
Expand Down
4 changes: 0 additions & 4 deletions charts/kubedb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ monitoring:
enabled: false
# Name of monitoring agent (either "prometheus.io/operator" or "prometheus.io/builtin")
agent: "none"
# specify where ServiceMonitor crd will be created
prometheus:
# Specify the namespace where Prometheus server is running or will be deployed.
namespace: ""
serviceMonitor:
# Specify the labels for ServiceMonitor.
# Prometheus crd will select ServiceMonitor using these labels.
Expand Down

0 comments on commit 2709602

Please sign in to comment.