diff --git a/.github/scripts/deploy_parca.sh b/.github/scripts/deploy_parca.sh new file mode 100755 index 0000000000..89c991ae93 --- /dev/null +++ b/.github/scripts/deploy_parca.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright 2024 Google LLC +# +# 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. + + +# Create GKE cluster +gcloud beta container --project "lees-gmp" clusters create "parca-cluster" --zone "us-central1-c" --no-enable-basic-auth --cluster-version "1.28.9-gke.1000000" --release-channel "regular" --machine-type "e2-medium" --image-type "COS_CONTAINERD" --disk-type "pd-balanced" --disk-size "100" --metadata disable-legacy-endpoints=true --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --num-nodes "3" --logging=SYSTEM,WORKLOAD --monitoring=SYSTEM --enable-ip-alias --network "projects/lees-gmp/global/networks/lees-network" --subnetwork "projects/lees-gmp/regions/us-central1/subnetworks/lees-network" --no-enable-intra-node-visibility --default-max-pods-per-node "110" --security-posture=standard --workload-vulnerability-scanning=disabled --no-enable-master-authorized-networks --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver --enable-autoupgrade --enable-autorepair --max-surge-upgrade 1 --max-unavailable-upgrade 0 --binauthz-evaluation-mode=DISABLED --no-enable-managed-prometheus --enable-shielded-nodes --node-locations "us-central1-c" +kubectl config set-cluster parca-cluster + +# Deploy Parca and Prometheus resources +kubectl create namespace parca +kubectl apply -f ../manifests/parca-server.yaml +kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.10.0/manifests/setup.yaml +kubectl apply -f $1 + +kubectl wait --for=condition=Ready deployment/gmp-operator -n gmp-system + +kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.10.0/examples/instrumentation/go-synthetic/go-synthetic.yaml + +# Port-forward Parca service to see visualization system +kubectl -n parca port-forward service/parca 7070 & + +sleep 1800 + +# Cleanup +kill %1 # Terminate the background port-forward process +kubectl delete all --all --all-namespaces \ No newline at end of file diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml index 5468faa8fe..870b97ecae 100644 --- a/.github/workflows/presubmit.yml +++ b/.github/workflows/presubmit.yml @@ -96,3 +96,16 @@ jobs: - uses: actions/checkout@v4 - name: Run e2e run: TEST_RUN=${{matrix.testrun}} make e2e + parca-profile: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} # Fetch the PR's code + - name: Profile the latest stabe version of GMP collector + run: | + ./.github/scripts/deploy_parca.sh https://raw.githubusercontent.com/GoogleCloudPlatform/prometheus-engine/v0.10.0/manifests/operator.yaml + - name: Profile the incoming change of GMP collector + run: | + ./.github/scripts/deploy_parca.sh ../../manifests/operator.yaml + diff --git a/examples/instrumentation/go-synthetic/go-synthetic.yaml b/examples/instrumentation/go-synthetic/go-synthetic.yaml index 91ae11cf02..627e9a6c45 100644 --- a/examples/instrumentation/go-synthetic/go-synthetic.yaml +++ b/examples/instrumentation/go-synthetic/go-synthetic.yaml @@ -34,6 +34,11 @@ spec: - "--listen-address=:8080" - "--cpu-burn-ops=75" - "--memory-ballast-mbs=1024" + - "--histogram-count=2" + - "--native-histogram-count=1" + - "--gauge-count=2" + - "--counter-count=2" + - "--summary-count=2" env: # Needed when using --tls-create-self-signed - name: POD_IP diff --git a/manifests/parca-server.yaml b/manifests/parca-server.yaml new file mode 100644 index 0000000000..488b86672e --- /dev/null +++ b/manifests/parca-server.yaml @@ -0,0 +1,195 @@ +# Copyright 2024 Google LLC +# +# 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. + +--- +apiVersion: v1 +data: + parca.yaml: |- + "object_storage": + "bucket": + "config": + "directory": "/var/lib/parca" + "type": "FILESYSTEM" + scrape_configs: + - job_name: 'kubernetes-pods' + kubernetes_sd_configs: + - role: pod + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_pod_label_app_kubernetes_io_(.+) + replacement: "app_kubernetes_io_$1" + - source_labels: [__meta_kubernetes_namespace] + action: replace + target_label: namespace + - source_labels: [__meta_kubernetes_pod_name] + action: replace + target_label: pod + - source_labels: [__meta_kubernetes_pod_container_name] + action: replace + target_label: container +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca + app.kubernetes.io/version: v0.21.0 + name: parca + namespace: parca +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca + app.kubernetes.io/version: v0.21.0 + name: parca + namespace: parca +spec: + replicas: 1 + selector: + matchLabels: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca + template: + metadata: + labels: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca + app.kubernetes.io/version: v0.21.0 + spec: + containers: + - args: + - /parca + - --http-address=:7070 + - --config-path=/etc/parca/parca.yaml + - --log-level=info + - --cors-allowed-origins=* + - --debuginfod-upstream-servers=debuginfod.systemtap.org + - --debuginfod-http-request-timeout=5m + image: ghcr.io/parca-dev/parca:v0.21.0 + livenessProbe: + exec: + command: + - /grpc_health_probe + - -v + - -addr=:7070 + initialDelaySeconds: 5 + name: parca + ports: + - containerPort: 7070 + name: http + readinessProbe: + exec: + command: + - /grpc_health_probe + - -v + - -addr=:7070 + initialDelaySeconds: 10 + resources: {} + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + terminationMessagePolicy: FallbackToLogsOnError + volumeMounts: + - mountPath: /etc/parca + name: config + - mountPath: /var/lib/parca + name: data + nodeSelector: + kubernetes.io/os: linux + securityContext: + fsGroup: 65534 + runAsNonRoot: true + runAsUser: 65534 + seccompProfile: + type: RuntimeDefault + supplementalGroups: + - 65534 + serviceAccountName: parca + terminationGracePeriodSeconds: 120 + volumes: + - configMap: + name: parca + name: config + - emptyDir: {} + name: data +--- +apiVersion: v1 +kind: Namespace +metadata: + labels: + pod-security.kubernetes.io/audit: privileged + pod-security.kubernetes.io/enforce: privileged + pod-security.kubernetes.io/warn: privileged + name: parca +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca + app.kubernetes.io/version: v0.21.0 + name: parca + namespace: parca +spec: + ports: + - name: http + port: 7070 + targetPort: 7070 + selector: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/component: observability + app.kubernetes.io/instance: parca + app.kubernetes.io/name: parca + app.kubernetes.io/version: v0.21.0 + name: parca + namespace: parca +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: parca-viewer +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: parca-viewer-binding +subjects: +- kind: ServiceAccount + name: parca + namespace: parca # Replace with your Parca namespace +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: parca-viewer