-
Notifications
You must be signed in to change notification settings - Fork 0
/
convertToOpenShift
executable file
·53 lines (45 loc) · 1.3 KB
/
convertToOpenShift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
DOCKERREG=dockerreg.conygre.com
DNSNAME=velociti2.dev2.conygre.com
PORTNUMBER=4200
# Check we are in the directory where docker-compose.yaml is
if [[ ! -e docker-compose.yaml ]]
then
echo "Please run this command from the directory where your docker-compose.yaml"
exit 1
fi
# Convert docker to openshift
if [[ ! -d openshiftnew ]]
then
mkdir openshiftnew
fi
cd openshiftnew
kompose convert -f ../docker-compose.yaml --provider=openshift
# Set the Docker registry location
if [[ -z $DOCKERREG ]]
then
echo -n "Please enter the private IP address of your Docker registry: "
read DOCKERREG
fi
for line in *.yaml
do
sed -i -e "s,name: cd/\\(.*\\):,name: ${DOCKERREG}:5000/cd/\\1:," \
-e "s,importPolicy: {},importPolicy:\n insecure: true," \
$line
done
# Add the route for the application
if [[ -z $DNSNAME ]]
then
echo -n "Please enter the DNS name for your application: "
read DNSNAME
fi
if [[ -z $PORTNUMBER ]]
then
echo -n "Please enter the exposed port number for your application: "
read PORTNUMBER
fi
sed -e "s/DNSNAME/${DNSNAME}/" -e "s/PORTNUMBER/${PORTNUMBER}/" ../bin/app-route.yaml >app-route.yaml
# To import into OC
#oc apply -f <list of the yaml files>
# The below automates the list to comma separated as required by the command
oc apply -f `echo * | sed 's/ /,/g'`