Skip to content

Commit ee19b41

Browse files
author
orannahoum
committed
Add Prometheus Connector kind and script to deploy it
1 parent c7a23c2 commit ee19b41

30 files changed

+942
-4
lines changed

PROJECT

+3
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ resources:
1313
- group: skydive
1414
kind: SkydiveFlowExporter
1515
version: v1
16+
- group: skydive
17+
kind: PrometheusConnector
18+
version: v1
1619
version: "2"

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ oc port-forward service/skydive-analyzer 8082:8082 --namespace=skydive
5151
After a successful deployment of skydive operator run the script:
5252

5353
```
54-
bash deploy_skydive_flow_exporter_operator.sh
54+
./deploy_skydive_flow_exporter_operator.sh
5555
```
5656

5757
for deployment developing using minio run: (don't forget to kill the old flow_exporter_operator if still running)
5858

5959
```
60-
bash hack/deploy_skydive_flow_exporter_dev_operator.sh
60+
./hack/deploy_skydive_flow_exporter_dev_operator.sh
61+
```
62+
63+
#### Prometheus Connector
64+
65+
After a successful deployment of skydive operator run the script:
66+
67+
```
68+
./deploy_prometheus_connector.sh
6169
```
6270

6371
### Customize skydive deployment / CRD

api/v1/prometheusconnector_types.go

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
v1 "k8s.io/api/core/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
25+
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
26+
27+
// PrometheusConnectorSpec defines the desired state of PrometheusConnector
28+
type PrometheusConnectorSpec struct {
29+
Namespace string `json:"namespace,omitempty"`
30+
31+
Deployment PrometheusConnectorDeploymentSpec `json:"deployment"`
32+
}
33+
34+
type PrometheusConnectorDeploymentSpec struct {
35+
// List of environment variables to set in the container.
36+
// Cannot be updated.
37+
// +optional
38+
// +patchMergeKey=name
39+
// +patchStrategy=merge
40+
Env []v1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,7,rep,name=env"`
41+
}
42+
43+
// PrometheusConnectorStatus defines the observed state of PrometheusConnector
44+
type PrometheusConnectorStatus struct {
45+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
46+
// Important: Run "make" to regenerate code after modifying this file
47+
}
48+
49+
// +kubebuilder:object:root=true
50+
51+
// PrometheusConnector is the Schema for the prometheusconnectors API
52+
type PrometheusConnector struct {
53+
metav1.TypeMeta `json:",inline"`
54+
metav1.ObjectMeta `json:"metadata,omitempty"`
55+
56+
Spec PrometheusConnectorSpec `json:"spec,omitempty"`
57+
Status PrometheusConnectorStatus `json:"status,omitempty"`
58+
}
59+
60+
// +kubebuilder:object:root=true
61+
62+
// PrometheusConnectorList contains a list of PrometheusConnector
63+
type PrometheusConnectorList struct {
64+
metav1.TypeMeta `json:",inline"`
65+
metav1.ListMeta `json:"metadata,omitempty"`
66+
Items []PrometheusConnector `json:"items"`
67+
}
68+
69+
func init() {
70+
SchemeBuilder.Register(&PrometheusConnector{}, &PrometheusConnectorList{})
71+
}

api/v1/zz_generated.deepcopy.go

+112
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: skydive-prometheus-connector
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
app: skydive-prometheus-connector
10+
tier: prometheus-connector
11+
template:
12+
metadata:
13+
labels:
14+
app: skydive-prometheus-connector
15+
tier: prometheus-connector
16+
spec:
17+
containers:
18+
- image: skydive/skydive-flow-exporter
19+
imagePullPolicy: Always
20+
name: skydive-prometheus-connector
21+
ports:
22+
- containerPort: 9100
23+
protocol: TCP
24+
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Route
3+
metadata:
4+
labels:
5+
app: skydive-prometheus-connector
6+
name: skydive-prometheus-connector
7+
spec:
8+
port:
9+
targetPort: api
10+
to:
11+
kind: Service
12+
name: skydive-prometheus-connector
13+
weight: 100
14+
wildcardPolicy: None
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: skydive-prometheus-connector
6+
name: skydive-prometheus-connector
7+
spec:
8+
ports:
9+
- name: api
10+
port: 9100
11+
protocol: TCP
12+
targetPort: 9100
13+
selector:
14+
app: skydive-prometheus-connector
15+
tier: prometheus-connector
16+
sessionAffinity: None
17+
type: NodePort

assets/prometheus/config-map.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: prom-config-skydive
5+
data:
6+
prometheus.yml: |-
7+
global:
8+
scrape_interval: 5s
9+
evaluation_interval: 5s
10+
scrape_configs:
11+
- job_name: 'prometheus'
12+
static_configs:
13+
- targets: ['localhost:9090']
14+
- job_name: 'skydive-openshift-stats'
15+
static_configs:
16+
- targets: ['skydive-prometheus-connector:9100']

assets/prometheus/deployment.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Prometheus (Deployment)
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: prometheus
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: prometheus
11+
tier: prometheus-connector
12+
template:
13+
metadata:
14+
labels:
15+
app: prometheus
16+
tier: prometheus-connector
17+
spec:
18+
containers:
19+
- image: prom/prometheus
20+
imagePullPolicy: IfNotPresent
21+
name: prometheus
22+
ports:
23+
- containerPort: 9090
24+
protocol: TCP
25+
resources: {}
26+
terminationMessagePath: /dev/termination-log
27+
terminationMessagePolicy: File
28+
volumeMounts:
29+
- mountPath: /prometheus
30+
name: prometheus-volume-1
31+
- mountPath: /etc/prometheus/
32+
name: prom-config-skydive-volume
33+
dnsPolicy: ClusterFirst
34+
restartPolicy: Always
35+
schedulerName: default-scheduler
36+
securityContext: {}
37+
terminationGracePeriodSeconds: 30
38+
volumes:
39+
- emptyDir: {}
40+
name: prometheus-volume-1
41+
- configMap:
42+
defaultMode: 420
43+
name: prom-config-skydive
44+
name: prom-config-skydive-volume

assets/prometheus/route.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Route
3+
metadata:
4+
labels:
5+
app: prometheus
6+
name: prometheus
7+
spec:
8+
port:
9+
targetPort: api
10+
to:
11+
kind: Service
12+
name: prometheus
13+
weight: 100
14+
wildcardPolicy: None

assets/prometheus/service.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app: prometheus
6+
name: prometheus
7+
spec:
8+
ports:
9+
- name: api
10+
port: 9090
11+
protocol: TCP
12+
targetPort: 9090
13+
selector:
14+
app: prometheus
15+
tier: prometheus-connector
16+
sessionAffinity: None
17+
type: NodePort

0 commit comments

Comments
 (0)