diff --git a/ruby/Dockerfile b/ruby/Dockerfile new file mode 100644 index 0000000..e252565 --- /dev/null +++ b/ruby/Dockerfile @@ -0,0 +1,5 @@ +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..4ae95dd --- /dev/null +++ b/ruby/app.rb @@ -0,0 +1,47 @@ +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..53ce569 --- /dev/null +++ b/ruby/deployment.yaml @@ -0,0 +1,24 @@ +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"