Skip to content

Commit

Permalink
add k8s sidecar docker dir
Browse files Browse the repository at this point in the history
  • Loading branch information
hebelsan committed Jan 3, 2024
1 parent e5146bb commit ced3015
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
16 changes: 16 additions & 0 deletions k8s-sidecar/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM alpine

RUN apk add bash jq
RUN apk add bash tar

COPY resources/opa.tar.gz /opa.tar.gz

RUN tar -xzf /opa.tar.gz -C /bin/ --remove-files

RUN chmod +x /bin/opa

COPY k8s-sidecar/start.sh /

COPY k8s-sidecar/config-template.json /

CMD ["/start.sh"]
29 changes: 29 additions & 0 deletions k8s-sidecar/config-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"bundles": {
($instanceID): {
"polling": {
"min_delay_seconds": 10,
"max_delay_seconds": 20
},
"service": "bundle_storage",
"resource": $instanceResource,
"signing": null,
"persist": false,
"size_limit_bytes": 0
}
},
"services": {
"bundle_storage": {
"url": $bundleUrl,
"credentials": {
"client_tls": {
"cert": $iasCertPath,
"private_key": $iasKeyPath
}
}
}
},
"plugins": {
"dcl": true
}
}
22 changes: 22 additions & 0 deletions k8s-sidecar/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

if ! ls /etc/secrets/sapbtp/identity; then
>&2 echo "Error: No identity service found at /etc/secrets/sapbtp/identity"
exit 1
fi
files=(/etc/secrets/sapbtp/identity/*)
if [ ${#files[@]} -gt 1 ]; then
>&2 echo "Error: More than one identity service found at /etc/secrets/sapbtp/identity"
exit 1
fi

bundle_url=$(cat "${files[0]}/url")/bundle-gateway
instance_id=$(cat "${files[0]}/authorization_instance_id")
ias_cert_path=$(pwd -P)/"${files[0]}/certificate"
ias_key_path=$(pwd -P)/"${files[0]}/key"

jq -n --arg bundleUrl "$bundle_url" --arg iasCertPath "$ias_cert_path" --arg iasKeyPath "$ias_key_path" --arg instanceResource "$instance_id.tar.gz" --arg instanceID "$instance_id" -f config-template.json >config.yml

>&2 echo "INFO: " "$(cat config.yml)"

opa run -s -c config.yml --addr=[]:8181

0 comments on commit ced3015

Please sign in to comment.