From 6975b7cdb7e12c55ca6983d800027ffa89e2be7b Mon Sep 17 00:00:00 2001 From: "Marcos P. Sanchez" Date: Sat, 19 Oct 2024 01:40:47 +0200 Subject: [PATCH 1/2] add ruby demo --- ruby/Dockerfile | 6 ++++++ ruby/Makefile | 3 +++ ruby/app.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++ ruby/deployment.yaml | 25 +++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 ruby/Dockerfile create mode 100644 ruby/Makefile create mode 100644 ruby/app.rb create mode 100644 ruby/deployment.yaml diff --git a/ruby/Dockerfile b/ruby/Dockerfile new file mode 100644 index 0000000..23f29ea --- /dev/null +++ b/ruby/Dockerfile @@ -0,0 +1,6 @@ +FROM ruby:bullseye + +COPY ./app.rb /tmp + +CMD ["ruby", "/tmp/app.rb"] + diff --git a/ruby/Makefile b/ruby/Makefile new file mode 100644 index 0000000..c94c62e --- /dev/null +++ b/ruby/Makefile @@ -0,0 +1,3 @@ +.PHONY: build +build: + docker build -t parca-demo:ruby . diff --git a/ruby/app.rb b/ruby/app.rb new file mode 100644 index 0000000..edd5a3e --- /dev/null +++ b/ruby/app.rb @@ -0,0 +1,48 @@ +require 'prime' +require 'fileutils' + +STDOUT.sync = true + +def a(n) + b(n) +end + +def b(n) + ## Make some calculations + i = 100_000 + while i > 0 do + Prime.prime?(i) + i -= 1 + end + c(n) +end + +def c(n) + ## Create a new file + File.open("test.txt", "w") do |f| + f.write("Hello, world!") + end + ## Pass new file to d + d("test.txt") +end + +def d(file) + ## Read file + File.open(file, "r") do |f| + ## Print file contents and time + puts f.read + " :: " + Time.now.to_s + end + f(file) +end + +def f(file) + ## Delete file + File.delete(file) +end + +## Infinte loop +while true + sleep(1) + a(1) +end + diff --git a/ruby/deployment.yaml b/ruby/deployment.yaml new file mode 100644 index 0000000..22ac0ae --- /dev/null +++ b/ruby/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/name: demo-ruby + name: ruby + namespace: parca +spec: + replicas: 3 + selector: + matchLabels: + app.kubernetes.io/name: demo-ruby + template: + metadata: + labels: + app.kubernetes.io/name: demo-ruby + spec: + containers: + - image: parca-demo:ruby + name: python + resources: + limits: + cpu: "100m" + memory: "256Mi" + From 9e35acf6b7329e3dfa4d378feb6f4a3fa7f5477f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:13:34 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- ruby/Dockerfile | 1 - ruby/app.rb | 1 - ruby/deployment.yaml | 1 - 3 files changed, 3 deletions(-) diff --git a/ruby/Dockerfile b/ruby/Dockerfile index 23f29ea..e252565 100644 --- a/ruby/Dockerfile +++ b/ruby/Dockerfile @@ -3,4 +3,3 @@ FROM ruby:bullseye COPY ./app.rb /tmp CMD ["ruby", "/tmp/app.rb"] - diff --git a/ruby/app.rb b/ruby/app.rb index edd5a3e..4ae95dd 100644 --- a/ruby/app.rb +++ b/ruby/app.rb @@ -45,4 +45,3 @@ def f(file) sleep(1) a(1) end - diff --git a/ruby/deployment.yaml b/ruby/deployment.yaml index 22ac0ae..53ce569 100644 --- a/ruby/deployment.yaml +++ b/ruby/deployment.yaml @@ -22,4 +22,3 @@ spec: limits: cpu: "100m" memory: "256Mi" -