Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ruby demo #53

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ruby/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ruby:bullseye

COPY ./app.rb /tmp

CMD ["ruby", "/tmp/app.rb"]
3 changes: 3 additions & 0 deletions ruby/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: build
build:
docker build -t parca-demo:ruby .
47 changes: 47 additions & 0 deletions ruby/app.rb
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions ruby/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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"
Loading