Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions monitoring/environments/scaleway-parca-demo/main.jsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
local m = import 'main.libsonnet';

local kubeThanos = m.kubeThanos({
namespace: 'parca-analytics',
objectStorageConfig: {
key: 'thanos.yaml',
name: 'parca-analytics-objectstorage',
},
volumeClaimTemplate: {
apiVersion: 'v1',
kind: 'PersistentVolumeClaim',
spec: {
accessModes: ['ReadWriteOnce'],
resources: { requests: { storage: '10Gi' } },
storageClassName: 'scw-bssd-retain',
},
},
});

local prometheuses = [
m.prometheus({
prometheus+:: {
Expand Down Expand Up @@ -149,6 +166,17 @@ local prometheuses = [
},
},

networkPolicy+: {
spec+: {
ingress+: [{
from: [{
namespaceSelector: { matchLabels: { 'kubernetes.io/metadata.name': p._config.namespace } },
podSelector: { matchLabels: { 'app.kubernetes.io/name': 'thanos-query' } },
}],
}],
},
},

// We do not monitor k8s metrics with this instance.
clusterRole:: {},
clusterRoleBinding:: {},
Expand All @@ -157,23 +185,6 @@ local prometheuses = [

local prometheusOperator = m.prometheusOperator();

local kubeThanos = m.kubeThanos({
namespace: 'parca-analytics',
objectStorageConfig: {
key: 'thanos.yaml',
name: 'parca-analytics-objectstorage',
},
volumeClaimTemplate: {
apiVersion: 'v1',
kind: 'PersistentVolumeClaim',
spec: {
accessModes: ['ReadWriteOnce'],
resources: { requests: { storage: '10Gi' } },
storageClassName: 'scw-bssd-retain',
},
},
});

{
apiVersion: 'v1',
kind: 'List',
Expand Down
71 changes: 69 additions & 2 deletions monitoring/lib/kube-thanos.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,79 @@ function(params={}) {
replicas: 1,
serviceMonitor: true,
}),
store: store,
store: store {
networkPolicy: {
kind: 'NetworkPolicy',
apiVersion: 'networking.k8s.io/v1',
metadata: {
name: 'thanos-store',
namespace: cfg.namespace,
},
spec: {
podSelector: {
matchLabels: {
'app.kubernetes.io/name': 'thanos-store',
},
},
egress: [{}], // Allow all outside egress to connect to object storage
ingress: [{
from: [{
namespaceSelector: {
matchLabels: {
'kubernetes.io/metadata.name': cfg.namespace,
},
},
podSelector: {
matchLabels: {
'app.kubernetes.io/name': 'thanos-query',
},
},
}],
}],
policyTypes: ['Egress'],
},
},
},

query: t.query(cfg {
replicas: 1,
replicaLabels: ['prometheus_replica', 'rule_replica'],
serviceMonitor: true,
stores: [store.storeEndpoint, 'dnssrv+_grpc._tcp.prometheus-parca-analytics-thanos-sidecar.%s.svc.cluster.local' % cfg.namespace],
}),
}) + {
networkPolicy: {
kind: 'NetworkPolicy',
apiVersion: 'networking.k8s.io/v1',
metadata: {
name: 'thanos-query',
namespace: 'parca-analytics',
},
spec: {
podSelector: {
matchLabels: {
'app.kubernetes.io/name': 'thanos-query',
},
},
egress: [{
to: [
{
namespaceSelector: {
matchLabels: {
'kubernetes.io/metadata.name': 'parca-analytics',
},
},
},
{
namespaceSelector: {
matchLabels: {
'kubernetes.io/metadata.name': 'kube-system',
},
},
},
],
}],
},
},

},
}