PaaS/OpenShift2019. 7. 29. 17:51

1. On line Imagestreams and Templates Import
--------------------------------------------------------------------------------
for resource in eap72-image-stream.json \
  eap72-amq-persistent-s2i.json \
  eap72-amq-s2i.json \
  eap72-basic-s2i.json \
  eap72-https-s2i.json \
  eap72-mongodb-persistent-s2i.json \
  eap72-mongodb-s2i.json \
  eap72-mysql-persistent-s2i.json \
  eap72-mysql-s2i.json \
  eap72-postgresql-persistent-s2i.json \
  eap72-postgresql-s2i.json \
  eap72-sso-s2i.json \
  eap72-third-party-db-s2i.json \
  eap72-tx-recovery-s2i.json
do
  oc replace -n openshift --force -f https://raw.githubusercontent.com/jboss-container-images/jboss-eap-7-openshift-image/eap72/templates/${resource}
done

2. Off Line Imagestreams and Templates Import
--------------------------------------------------------------------------------
2.1 Obtaining images (on line)
docker login registry.redhat.io
docker pull registry.redhat.io/jboss-eap-7/eap72-openshift:latest
docker save -o eap72-openshift.tar registry.redhat.io/jboss-eap-7/eap72-openshift:latest

2.2 private docker registry Image Import (off line)
※ prerequisites: private docker registry (distribution docker, Quay, etc)

docker load -i eap72-openshift.tar

docker login -u user -p $(oc whoami -t) registry.example.com:5000
docker tag registry.redhat.io/jboss-eap-7/eap72-openshift:latest registry.example.com:5000/jboss-eap-7/jboss-eap72-openshift:latest
docker tag registry.redhat.io/jboss-eap-7/eap72-openshift:latest registry.example.com:5000/jboss-eap-7/jboss-eap72-openshift:1.0
docker push registry.example.com:5000/jboss-eap-7/jboss-eap72-openshift:latest
docker push registry.example.com:5000/jboss-eap-7/jboss-eap72-openshift:1.0

2.3 Obtaining and Modifing ImageStream template (ex. eap72-image-stream.json)
git clone https://github.com/jboss-container-images/jboss-eap-7-openshift-image.git
cd jboss-eap-7-openshift-image
vi eap72-image-stream.json
# DockerImage
registry.redhat.io/jboss-eap-7/eap72-openshift:latest => registry.example.com:5000/jboss-eap-7/eap72-openshift:latest
registry.redhat.io/jboss-eap-7/eap72-openshift:1.0 => registry.example.com:5000/jboss-eap-7/eap72-openshift:1.0

2.4 Importing ImageStreams and Templates
oc create -f templates -n openshift

※ push images from the integrated container registry directly
docker login -p $(oc whoami -t) -e unused -u unused docker-registry-default.apps.example.com
docker tag registry.example.com:5000/jboss-eap-7/jboss-eap72-openshift:latest docker-registry-default.apps.example.com/openshift/jboss-eap72-openshift:latest
docker push docker-registry-default.apps.example.com/openshift/jboss-eap72-openshift:latest

2.5 Updating and Tagging Existing Images
oc import-image registry.example.com:5000/jboss-eap-7/jboss-eap72-openshift:latest --insecure=true --confirm -n openshift
oc tag jboss-eap72-openshift:latest jboss-eap72-openshift:1.0 -n openshift

3. Template spec check (parameter)
--------------------------------------------------------------------------------
oc process eap72-mysql-s2i --parameters -n openshift > tem_eap72-mysql-s2i_spec.txt

4. Creating New Applications With Templates
--------------------------------------------------------------------------------
● Application Building with parameter settings

build.sh

#!/bin/sh

PROJECT_NAME=eap72-mysql-s2i
SVC_ACCOUNT_NAME=eap7-service-account
SECRET_NAME=eap7-app-secret
CUSTOM_DB_USERNAME=openshift
CUSTOM_DB_PASSWORD=password
CUSTOM_DB_NAME=mysql57
TEMPLATE_NAME=eap72-mysql-s2i

oc new-project $PROJECT_NAME --display-name="eap72-mysql-s2i" --description="EAP72-MYSQL-S2I TEST"
oc project $PROJECT_NAME
oc create serviceaccount $SVC_ACCOUNT_NAME -n $(oc project -q)
oc policy add-role-to-user view system:serviceaccount:$(oc project -q):$SVC_ACCOUNT_NAME -n $(oc project -q)
oc policy add-role-to-user view system:serviceaccount:$(oc project -q):default -n $(oc project -q)

oc create secret generic $SECRET_NAME --from-literal=username=developer --from-literal=password=password --type=kubernetes.io/basic-auth -n $(oc project -q)
oc secrets link  $SVC_ACCOUNT_NAME $SECRET_NAME -n $(oc project -q)

#oc get --export template -n openshift -o json $TEMPLATE_NAME > $TEMPLATE_NAME.json
#oc process -f $TEMPLATE_NAME.json -p DB_USERNAME=$CUSTOM_DB_USERNAME -p DB_PASSWORD=$CUSTOM_DB_PASSWORD -p DB_DATABASE=$CUSTOM_DB_NAME | oc create -f - -n $(oc project -q)
oc process $TEMPLATE_NAME -p DB_USERNAME=$CUSTOM_DB_USERNAME -p DB_PASSWORD=$CUSTOM_DB_PASSWORD -p DB_DATABASE=$CUSTOM_DB_NAME | oc create -f - -n $(oc project -q)

5. app test
--------------------------------------------------------------------------------
oc logs -f bc/eap-app
oc logs -f dc/eap-app
oc get route -n eap72-mysql-s2i
oc describe route eap-app -n eap72-mysql-s2i
curl eap-app-eap72-mysql-s2i.apps.example.com

Reference URL)
https://github.com/jboss-container-images/jboss-eap-7-openshift-image/blob/eap72-dev/docs/templates/eap72-mysql-s2i.adoc
https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.2/

Posted by sonorous34