Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
feat: fix permissions
Browse files Browse the repository at this point in the history
Signed-off-by: Zuhair AlSader <[email protected]>
  • Loading branch information
zalsader committed Dec 20, 2023
1 parent 7d43911 commit d091e79
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 3 deletions.
5 changes: 5 additions & 0 deletions knative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ https://knative.dev/docs/serving/configuration/feature-flags/#kubernetes-persist
features:
kubernetes.podspec-persistent-volume-claim: "enabled"
kubernetes.podspec-persistent-volume-write: "enabled"
kubernetes.podspec-securitycontext: "enabled"
```
## Add pvc to funcs
Expand All @@ -67,6 +68,10 @@ run:
cd producer
kn func build --registry docker.io/<your_username>
kn func deploy

# this is to fix permission issues
kubectl patch services.serving/producer --type merge \
-p '{"spec": {"template": {"spec": {"securityContext": {"fsGroup":1000}}}}}'
```
do the same for consumer.

Expand Down
70 changes: 70 additions & 0 deletions knative/deploy/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: busybot
spec:
schedule: "* * * * *"
successfulJobsHistoryLimit: 10
failedJobsHistoryLimit: 5
concurrencyPolicy: Replace
jobTemplate:
metadata:
labels:
app: busybot
cron: busybot
spec:
template:
spec:
containers:
- name: busybot-cont
image: alpine:3.18.4
imagePullPolicy: IfNotPresent
env:
- name: STORE
value: /store
- name: COUNT
value: "5"
- name: DEL_COUNT
value: "2"
- name: SIZE
value: 50M
volumeMounts:
- name: knative-pc-cephfs
mountPath: /store
command:
- /bin/sh
- -c
- |
echo Reading directory
echo "Number of files: $(ls $STORE | wc -l)"
# Read $COUNT random files from store and calculate md5
ls $STORE | shuf -n $COUNT | while read file
do
md5sum $STORE/$file
done
# Write $COUNT random files from store
shuf -n $COUNT -i 0-99 | while read file
do
dd if=/dev/urandom of=/tmp/file bs=$SIZE count=1
md5=$(md5sum /tmp/file | awk '{ print $1 }')
filename=$(printf "%02d" $file)
echo Writing $filename
rm -f $STORE/$filename-*
mv /tmp/file $STORE/$filename-$md5
done
# Delete $DEL_COUNT random files from store
ls $STORE | shuf -n $DEL_COUNT | while read file
do
echo Deleting $file
rm $STORE/$file
done
restartPolicy: Never
volumes:
- name: knative-pc-cephfs
persistentVolumeClaim:
claimName: knative-pc-cephfs
readOnly: false
3 changes: 2 additions & 1 deletion knative/deploy/serving.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ spec:
ingress-class: "kourier.ingress.networking.knative.dev"
features:
kubernetes.podspec-persistent-volume-claim: "enabled"
kubernetes.podspec-persistent-volume-write: "enabled"
kubernetes.podspec-persistent-volume-write: "enabled"
kubernetes.podspec-securitycontext: "enabled"
2 changes: 1 addition & 1 deletion knative/list/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: list
runtime: go
registry: docker.io/zuhairkoor
image: docker.io/zuhairkoor/list:latest
imageDigest: sha256:be980eef1d2008e7bf8b308051824d1048698e239d8986554ff3e08b66ff385d
imageDigest: sha256:62b1a99f81cde6454ace5433e8eb2c142fc35a947af6162cbd304c1e5d11b622
created: 2023-12-19T00:25:46.352372057-05:00
build:
builder: pack
Expand Down
2 changes: 1 addition & 1 deletion knative/producer/func.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: producer
runtime: go
registry: docker.io/zuhairkoor
image: docker.io/zuhairkoor/producer:latest
imageDigest: sha256:c17987414b33618cf2490ae23e31280dd5a68dd0a6a4571e71288380fe0efe02
imageDigest: sha256:d1c63d1f83bc8d742f857e83bc313c700c927228ae9ef6335062e03e436e938b
created: 2023-12-13T00:38:54.564292994-05:00
build:
builder: pack
Expand Down

0 comments on commit d091e79

Please sign in to comment.