Skip to content

Commit

Permalink
Add local development scripts (#361)
Browse files Browse the repository at this point in the history
* Add local development scripts

Signed-off-by: Max Shaposhnyk <[email protected]>

* Fixups

Signed-off-by: Max Shaposhnyk <[email protected]>

---------

Signed-off-by: Max Shaposhnyk <[email protected]>
  • Loading branch information
mshaposhnik authored Dec 23, 2024
1 parent 4b44ab6 commit 8da4c3f
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ target
.project
.classpath
.vscode/
.tmp
*~
local-test
out
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ dev-image: build build-otp
dev: dev-image
./deploy/development.sh

dev-minikube: dev
.PHONY: dev-minikube
dev-minikube: dev-image
./deploy/generate_ca.sh
./deploy/minikube-development.sh

## Tool Versions
Expand Down
26 changes: 26 additions & 0 deletions deploy/generate_ca.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

# This script generates the certificates needed for the otp

set -e


THIS_DIR="$(dirname "$(realpath "$0")")"
TEMP_DIR="${THIS_DIR}/../.tmp"

GENCERTS_DIR="${GENCERTS_DIR:-"${TEMP_DIR}/k8s/certs"}"

echo "Generating CA bundle"
mkdir -p "${GENCERTS_DIR}"

openssl genrsa -out ${GENCERTS_DIR}/ca.key 2048
openssl req -x509 -new -nodes -key ${GENCERTS_DIR}/ca.key -subj "/CN=otp-service.mpc.svc" -days 365 -out ${GENCERTS_DIR}/ca.crt

# verify created
cat ${GENCERTS_DIR}/ca.crt >/dev/null
if [ $? -eq 0 ]; then
echo "CA bundle created"
else
echo "CA generation failed"
exit 1
fi
44 changes: 44 additions & 0 deletions deploy/minikube-development.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

DIR=`dirname $0`
TEMP_DIR="${DIR}/../.tmp"

if [ -z "$QUAY_USERNAME" ]; then
echo "Set QUAY_USERNAME"
exit 1
fi


kubectl create ns multi-platform-controller --dry-run=client -o yaml | kubectl apply -f -
kubectl config set-context --current --namespace=multi-platform-controller

kubectl delete --ignore-not-found secret awskeys awsiam ibmiam
kubectl create secret generic awskeys --from-file=id_rsa=$ID_RSA_KEY
kubectl create secret generic awsiam --from-literal=access-key-id=$MULTI_ARCH_ACCESS_KEY --from-literal=secret-access-key=$MULTI_ARCH_SECRET_KEY
kubectl create secret generic ibmiam --from-literal=api-key=$IBM_CLOUD_API_KEY
kubectl label secrets awsiam build.appstudio.redhat.com/multi-platform-secret=true
kubectl label secrets ibmiam build.appstudio.redhat.com/multi-platform-secret=true
kubectl label secrets awskeys build.appstudio.redhat.com/multi-platform-secret=true

# Check Tekton
kubectl describe crd pipelinerun >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Tekton API already installed"
else
echo "Tekton API not found, installing"
kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
# If you need full Tekton operator, comment the line above and uncomment below:
# kubectl apply --filename https://storage.googleapis.com/tekton-releases/operator/latest/release.yaml
fi

echo "Installing the Operator"
rm -r $DIR/overlays/development
find $DIR -name dev-template -exec cp -r {} {}/../development \;
find $DIR -path \*development\*.yaml -exec sed -i s/QUAY_USERNAME/${QUAY_USERNAME}/ {} \;
kubectl apply -k $DIR/overlays/development

kubectl rollout restart deployment -n multi-platform-controller multi-platform-controller

echo "Creating OTP TLS secret"
kubectl create secret tls otp-tls-secrets --key ${TEMP_DIR}/k8s/certs/ca.key --cert ${TEMP_DIR}/k8s/certs/ca.crt --dry-run=client -o yaml | kubectl apply -f -
kubectl rollout restart deployment -n multi-platform-controller multi-platform-otp-server

0 comments on commit 8da4c3f

Please sign in to comment.