github.com/grafana/pyroscope@v1.18.0/examples/grafana-alloy-auto-instrumentation/ebpf/kubernetes/python-fast-slow.yaml (about)

     1  apiVersion: v1
     2  kind: ConfigMap
     3  metadata:
     4    name: python-app
     5    namespace: pyroscope-ebpf
     6  data:
     7    main: |
     8      #!/usr/bin/env python3
     9  
    10      import logging
    11      import os
    12  
    13      def work(n):
    14      	i = 0
    15      	while i < n:
    16      		i += 1
    17  
    18      def fast_function():
    19      		work(20000)
    20  
    21      def slow_function():
    22      	    work(80000)
    23  
    24      if __name__ == "__main__":
    25      	while True:
    26      		fast_function()
    27      		slow_function()
    28  
    29  ---
    30  apiVersion: apps/v1
    31  kind: Deployment
    32  metadata:
    33    name: python-fast-slow
    34    namespace: pyroscope-ebpf
    35  spec:
    36    replicas: 1
    37    selector:
    38      matchLabels:
    39        app: python-fast-slow
    40    template:
    41      metadata:
    42        labels:
    43          app: python-fast-slow
    44      spec:
    45        containers:
    46          - name: python-fast-slow
    47            image: python:3.11
    48            imagePullPolicy: IfNotPresent
    49            command: [ "python3" ]
    50            args: [ "/app/main.py" ]
    51            volumeMounts:
    52              - name: app
    53                mountPath: /app
    54        volumes:
    55          - name: app
    56            configMap:
    57              name: python-app
    58              items:
    59                - key: main
    60                  path: main.py