Skip to content

Commit e6cad4e

Browse files
committed
Add GCP Marketplace deployment support
Add Jsonnet configuration and manifests to support deploying parca-agent to Google Cloud Marketplace. Includes DaemonSet, RBAC, ConfigMap, and Application definitions.
1 parent a51e420 commit e6cad4e

File tree

8 files changed

+309
-1
lines changed

8 files changed

+309
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
TODO.md
1010
minikube-*
1111
/data
12+
/deploy/gcp/tmp/
1213

1314
# Snap Packaging Artifacts
1415
*.snap

deploy/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ vendor:
88

99
.PHONY: manifests
1010
manifests: vendor $(shell find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print)
11-
rm -rf manifests tilt
11+
rm -rf manifests tilt gcp/manifest/manifest.yaml.template
1212
mkdir -p manifests/openshift manifests/kubernetes tilt
1313
export VERSION=$(VERSION) SERVER_VERSION=$(SERVER_VERSION) && ./generate.sh
1414

deploy/gcp.jsonnet

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function(version='v0.0.1-alpha.3')
2+
// local ns = {
3+
// apiVersion: 'v1',
4+
// kind: 'Namespace',
5+
// metadata: {
6+
// name: 'parca',
7+
// labels: {
8+
// 'pod-security.kubernetes.io/enforce': 'privileged',
9+
// 'pod-security.kubernetes.io/audit': 'privileged',
10+
// 'pod-security.kubernetes.io/warn': 'privileged',
11+
// },
12+
// },
13+
// };
14+
15+
local agent = (import 'parca-agent/parca-agent.libsonnet')({
16+
name: '$name',
17+
namespace: '$namespace',
18+
version: version,
19+
image: 'ghcr.io/parca-dev/parca-agent:' + version,
20+
// This assumes there's a running parca in the cluster.
21+
stores: ['parca.parca.svc.cluster.local:7070'],
22+
insecure: true,
23+
// token: "<token>",
24+
// stores: [
25+
// 'grpc.polarsignals.com:443',
26+
// ],
27+
// Available Options:
28+
// samplingRatio: 0.5,
29+
// Docs for usage of Label Selector
30+
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors
31+
// podLabelSelector: 'app=my-web-app,version=v1',
32+
});
33+
34+
{
35+
// '0namespace': ns,
36+
// } + {
37+
['parca-agent-' + name]: agent[name]
38+
for name in std.objectFields(agent)
39+
if agent[name] != null
40+
}

deploy/gcp/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM gcr.io/cloud-marketplace-tools/k8s/deployer_envsubst/onbuild
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: app.k8s.io/v1beta1
2+
kind: Application
3+
metadata:
4+
name: "$name"
5+
namespace: "$namespace"
6+
annotations:
7+
marketplace.cloud.google.com/deploy-info: '{"partner_id": "partner", "product_id": "nginx", "partner_name": "Partner"}'
8+
labels:
9+
app.kubernetes.io/name: "$name"
10+
spec:
11+
descriptor:
12+
type: parca-agent
13+
version: '0.44.0'
14+
selector:
15+
matchLabels:
16+
app.kubernetes.io/name: "$name"
17+
componentKinds:
18+
# The group is determined from the apiVersion: $GROUP_NAME/$VERSION
19+
- group: apps
20+
kind: DaemonSet
21+
- group: ''
22+
kind: Service
23+
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
apiVersion: rbac.authorization.k8s.io/v1
2+
kind: ClusterRole
3+
metadata:
4+
labels:
5+
app.kubernetes.io/component: observability
6+
app.kubernetes.io/instance: $name
7+
app.kubernetes.io/name: parca-agent
8+
app.kubernetes.io/version: v0.44.0
9+
name: $name
10+
namespace: $namespace
11+
rules:
12+
- apiGroups:
13+
- ""
14+
resources:
15+
- pods
16+
verbs:
17+
- list
18+
- watch
19+
- apiGroups:
20+
- ""
21+
resources:
22+
- nodes
23+
verbs:
24+
- get
25+
---
26+
apiVersion: rbac.authorization.k8s.io/v1
27+
kind: ClusterRoleBinding
28+
metadata:
29+
labels:
30+
app.kubernetes.io/component: observability
31+
app.kubernetes.io/instance: $name
32+
app.kubernetes.io/name: parca-agent
33+
app.kubernetes.io/version: v0.44.0
34+
name: $name
35+
namespace: $namespace
36+
roleRef:
37+
apiGroup: rbac.authorization.k8s.io
38+
kind: ClusterRole
39+
name: $name
40+
subjects:
41+
- kind: ServiceAccount
42+
name: $name
43+
namespace: $namespace
44+
---
45+
apiVersion: v1
46+
data:
47+
parca-agent.yaml: |-
48+
"relabel_configs":
49+
- "source_labels":
50+
- "__meta_process_executable_compiler"
51+
"target_label": "compiler"
52+
- "source_labels":
53+
- "__meta_system_kernel_machine"
54+
"target_label": "arch"
55+
- "source_labels":
56+
- "__meta_system_kernel_release"
57+
"target_label": "kernel_version"
58+
- "source_labels":
59+
- "__meta_kubernetes_namespace"
60+
"target_label": "namespace"
61+
- "source_labels":
62+
- "__meta_kubernetes_pod_name"
63+
"target_label": "pod"
64+
- "source_labels":
65+
- "__meta_kubernetes_pod_container_name"
66+
"target_label": "container"
67+
- "source_labels":
68+
- "__meta_kubernetes_pod_container_image"
69+
"target_label": "container_image"
70+
- "source_labels":
71+
- "__meta_kubernetes_node_label_topology_kubernetes_io_region"
72+
"target_label": "region"
73+
- "source_labels":
74+
- "__meta_kubernetes_node_label_topology_kubernetes_io_zone"
75+
"target_label": "zone"
76+
- "action": "labelmap"
77+
"regex": "__meta_kubernetes_pod_label_(.+)"
78+
"replacement": "${1}"
79+
- "action": "labeldrop"
80+
"regex": "apps_kubernetes_io_pod_index|controller_revision_hash|statefulset_kubernetes_io_pod_name|pod_template_hash"
81+
kind: ConfigMap
82+
metadata:
83+
labels:
84+
app.kubernetes.io/component: observability
85+
app.kubernetes.io/instance: $name
86+
app.kubernetes.io/name: parca-agent
87+
app.kubernetes.io/version: v0.44.0
88+
name: $name
89+
namespace: $namespace
90+
---
91+
apiVersion: apps/v1
92+
kind: DaemonSet
93+
metadata:
94+
labels:
95+
app.kubernetes.io/component: observability
96+
app.kubernetes.io/instance: $name
97+
app.kubernetes.io/name: parca-agent
98+
app.kubernetes.io/version: v0.44.0
99+
name: $name
100+
namespace: $namespace
101+
spec:
102+
selector:
103+
matchLabels:
104+
app.kubernetes.io/component: observability
105+
app.kubernetes.io/instance: $name
106+
app.kubernetes.io/name: parca-agent
107+
template:
108+
metadata:
109+
labels:
110+
app.kubernetes.io/component: observability
111+
app.kubernetes.io/instance: $name
112+
app.kubernetes.io/name: parca-agent
113+
app.kubernetes.io/version: v0.44.0
114+
spec:
115+
containers:
116+
- args:
117+
- --http-address=:7071
118+
- --node=$(NODE_NAME)
119+
- --config-path=/etc/parca-agent/parca-agent.yaml
120+
- --remote-store-address=parca.parca.svc.cluster.local:7070
121+
- --remote-store-insecure
122+
env:
123+
- name: NODE_NAME
124+
valueFrom:
125+
fieldRef:
126+
fieldPath: spec.nodeName
127+
image: ghcr.io/parca-dev/parca-agent:v0.44.0
128+
name: parca-agent
129+
ports:
130+
- containerPort: 7071
131+
name: http
132+
resources: {}
133+
securityContext:
134+
allowPrivilegeEscalation: true
135+
capabilities:
136+
add:
137+
- SYS_ADMIN
138+
privileged: true
139+
volumeMounts:
140+
- mountPath: /tmp
141+
name: tmp
142+
- mountPath: /run
143+
name: run
144+
- mountPath: /boot
145+
name: boot
146+
readOnly: true
147+
- mountPath: /lib/modules
148+
name: modules
149+
- mountPath: /sys/kernel/debug
150+
name: debugfs
151+
- mountPath: /sys/fs/cgroup
152+
name: cgroup
153+
- mountPath: /sys/fs/bpf
154+
name: bpffs
155+
- mountPath: /etc/parca-agent
156+
name: config
157+
- mountPath: /var/run/dbus/system_bus_socket
158+
name: dbus-system
159+
hostPID: true
160+
nodeSelector:
161+
kubernetes.io/os: linux
162+
securityContext:
163+
seccompProfile:
164+
type: RuntimeDefault
165+
serviceAccountName: $name
166+
tolerations:
167+
- operator: Exists
168+
volumes:
169+
- emptyDir: {}
170+
name: tmp
171+
- hostPath:
172+
path: /run
173+
name: run
174+
- hostPath:
175+
path: /boot
176+
name: boot
177+
- hostPath:
178+
path: /sys/fs/cgroup
179+
name: cgroup
180+
- hostPath:
181+
path: /lib/modules
182+
name: modules
183+
- hostPath:
184+
path: /sys/fs/bpf
185+
name: bpffs
186+
- hostPath:
187+
path: /sys/kernel/debug
188+
name: debugfs
189+
- configMap:
190+
name: $name
191+
name: config
192+
- hostPath:
193+
path: /var/run/dbus/system_bus_socket
194+
name: dbus-system
195+
---
196+
apiVersion: v1
197+
kind: ServiceAccount
198+
metadata:
199+
labels:
200+
app.kubernetes.io/component: observability
201+
app.kubernetes.io/instance: $name
202+
app.kubernetes.io/name: parca-agent
203+
app.kubernetes.io/version: v0.44.0
204+
name: $name
205+
namespace: $namespace
206+
---

deploy/gcp/schema.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
x-google-marketplace:
2+
schemaVersion: v2
3+
4+
applicationApiVersion: v1beta1
5+
# The published version is required and MUST match the tag
6+
# of the deployer image
7+
publishedVersion: '0.44.0'
8+
publishedVersionMetadata:
9+
releaseNote: >-
10+
A first release.
11+
# The images property will be filled in during part 2
12+
images: {}
13+
14+
properties:
15+
name:
16+
type: string
17+
x-google-marketplace:
18+
type: NAME
19+
namespace:
20+
type: string
21+
x-google-marketplace:
22+
type: NAMESPACE
23+
replicas:
24+
type: integer
25+
title: Nginx Replica Count
26+
description: The number of nginx replicas to deploy
27+
28+
required:
29+
- name
30+
- namespace

deploy/generate.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/usr/bin/env bash
22
set -e
33

4+
# Kubernetes
45
jsonnet --tla-str version="${VERSION}" -J vendor main.jsonnet -m manifests/kubernetes | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}
56
for f in manifests/kubernetes/*; do cat ${f} >> manifests/kubernetes-manifest.yaml; echo '---' >> manifests/kubernetes-manifest.yaml; done
7+
# OpenShift
68
jsonnet --tla-str version="${VERSION}" -J vendor openshift.jsonnet -m manifests/openshift | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}
79
for f in manifests/openshift/*; do cat ${f} >> manifests/openshift-manifest.yaml; echo '---' >> manifests/openshift-manifest.yaml; done
10+
# GCP Marketplace
11+
jsonnet --tla-str version="${VERSION}" -J vendor gcp.jsonnet -m gcp/tmp | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}
12+
for f in gcp/tmp/*; do cat ${f} >> gcp/manifest/manifest.yaml.template; echo '---' >> gcp/manifest/manifest.yaml.template; done
13+
# Tilt
814
jsonnet --tla-str serverVersion="${SERVER_VERSION}" -J vendor dev.jsonnet -m tilt | xargs -I{} sh -c 'cat {} | gojsontoyaml > {}.yaml; rm -f {}' -- {}
15+

0 commit comments

Comments
 (0)