-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring of container creation mechanism (#750)
- Loading branch information
Showing
17 changed files
with
165 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash -e | ||
|
||
if [[ $# != 1 ]]; then | ||
echo Usage: $0 gcp_project[/udmi_namespace] | ||
false | ||
fi | ||
|
||
full_id=$1 | ||
shift | ||
|
||
gcp_project=${full_id%/*} | ||
udmi_space=${full_id#$gcp_project} | ||
udmi_space=${udmi_space#/} | ||
success=$(mktemp) | ||
rm -f $success | ||
|
||
ROOT=$(dirname $0)/.. | ||
cd $ROOT | ||
|
||
echo Configuring for GCP project $gcp_project... | ||
|
||
current_project=$(gcloud config get project) | ||
quota_project=$(jq -r .quota_project_id $HOME/.config/gcloud/application_default_credentials.json) | ||
|
||
if [[ $quota_project != $gcp_project ]]; then | ||
echo Setting gcloud quota project to $gcp_project | ||
gcloud auth application-default set-quota-project $gcp_project | ||
fi | ||
|
||
if [[ $gcp_project != $current_project ]]; then | ||
echo Setting gcloud defailt project to $gcp_project | ||
gcloud --quiet config set project $gcp_project | ||
fi | ||
|
||
saved=$(kubectl config current-context) | ||
kcontexts=$(kubectl config get-contexts -o name | fgrep _${gcp_project}_) | ||
|
||
if [[ -z $kcontexts ]]; then | ||
echo No kubectl context defined for project $gcp_project | ||
echo " kubectl config get-contexts -o name | fgrep _${gcp_project}_)" | ||
false | ||
fi | ||
|
||
for context in $kcontexts; do | ||
echo Checking k8s context $context | ||
|
||
k8s_parts=$(tr '_' ' ' <<<$context) | ||
GCP_PROJECT=$(awk '{print $2}' <<<$k8s_parts) | ||
GCP_REGION=$(awk '{print $3}' <<<$k8s_parts) | ||
K8S_CLUSTER=$(awk '{print $4}' <<<$k8s_parts) | ||
UDMI_NAMESPACE=$(awk '{print $5}' <<<$k8s_parts) | ||
|
||
if [[ $GCP_PROJECT == $gcp_project && $UDMI_NAMESPACE == $udmi_space ]]; then | ||
echo Matched k8s context $context | ||
echo $context > $success | ||
break | ||
fi | ||
done | ||
|
||
if [[ ! -f $success ]]; then | ||
echo No k8s context matching project $gcp_project and udmi namespace ${udmi_space:-\<default\>} found. | ||
false | ||
fi | ||
|
||
K8S_CONTEXT=$(< $success) | ||
|
||
kubectl config use-context $K8S_CONTEXT | ||
|
||
k8s_namespace=$(kubectl config get-contexts --no-headers $K8S_CONTEXT | awk '{ print $5 }') | ||
echo Using k8s namespace ${k8s_namespace:-default} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Empty dummy build script for non-existant selfie source. | ||
|
||
mkdir -p build/libs | ||
touch build/libs/selfie-1.0-SNAPSHOT-all.jar |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM alpine:latest | ||
|
||
WORKDIR /root | ||
|
||
RUN apk add openjdk17 bash gcompat mosquitto-clients curl jq | ||
|
||
# Workaround for https://github.com/grpc/grpc-java/issues/8751 | ||
ENV LD_PRELOAD=/lib/libgcompat.so.0 | ||
|
||
ADD build/libs/validator-1.0-SNAPSHOT-all.jar build/libs/validator-1.0-SNAPSHOT-all.jar | ||
|
||
ADD bin/ bin/ | ||
|
||
CMD ["/root/bin/automate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash -e | ||
# | ||
# Automation of tools using PubSub triggers. | ||
# | ||
|
||
env | ||
|
||
exec tail -f /dev/null |
Oops, something went wrong.