Created
February 17, 2017 15:30
-
-
Save loa/8460c67bee44eea90583146a05294a14 to your computer and use it in GitHub Desktop.
OpenShift New project
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
# it's required that name is identical with repo name | |
NAME=project | |
[email protected]/user/project.git | |
HOSTNAME=project.example.com | |
# create deploy key | |
ssh-keygen -t rsa -N "" -b 4096 -f deploy-key | |
# create new project | |
oc new-project $NAME | |
# create project | |
oc new-app $REPO --strategy=docker | |
# create secret with deploy-key | |
oc create secret generic $NAME-deploykey --from-file=ssh-privatekey=./deploy-key | |
# add deploy-key as secret to buildconfig | |
oc patch buildconfig $NAME -p "{\"spec\":{\"source\":{\"sourceSecret\":{\"name\": \"${NAME}-deploykey\"}}}}" | |
# clean git url | |
REPO_URL=$(echo $REPO | sed 's/:/\//' | sed 's/git@/https:\/\//' | sed 's/\.git$//') | |
# public part of deploy key need to be added to github project | |
echo Add public part as deploy key in GitHub project and hit ENTER | |
echo ${REPO_URL}/settings/keys | |
echo | |
cat deploy-key.pub | |
read -n 1 | |
# trigger new build with deploy-key | |
oc start-build $NAME | |
# create route to expose service | |
oc expose service/$NAME --hostname=$HOSTNAME | |
# patch route to enable edge tls termination | |
oc patch route $NAME -p '{"spec":{"tls":{"termination": "edge"}}}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment