Quantcast
Channel: DevOps tips & tricks
Viewing all articles
Browse latest Browse all 181

Weblogic k8s operator - create model in image

$
0
0

 HOWTO

See also

GitHub code


Quick start sample files
[dave@fedora weblogic-kubernetes-operator]$ cd kubernetes/samples/quick-start/
[dave@fedora quick-start]$ find
.
./archive
./archive/wlsdeploy
./archive/wlsdeploy/applications
./archive/wlsdeploy/applications/quickstart
./archive/wlsdeploy/applications/quickstart/WEB-INF
./archive/wlsdeploy/applications/quickstart/WEB-INF/web.xml
./archive/wlsdeploy/applications/quickstart/index.jsp
./domain-resource.yaml
./ingress-route.yaml
./model.properties
./model.yaml


Download the latest WebLogic Deploy Tooling (WDT) and WebLogic Image Tool (WIT) installer ZIP files to a new directory; for example, use directory /tmp/quickstart/tools. Both WDT and WIT are required to create your Model in Image auxiliary images.
Download WDT and image tool
 mkdir -p ~/k8s/quickstart/tools
$ curl -m 120 -fL https://github.com/oracle/weblogic-deploy-tooling/releases/latest/download/weblogic-deploy.zip   -o ~/k8s/quickstart/tools/weblogic-deploy.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2382k  100 2382k    0     0  1685k      0  0:00:01  0:00:01 --:--:-- 3648k
[dave@fedora tools]$ curl -m 120 -fL https://github.com/oracle/weblogic-image-tool/releases/latest/download/imagetool.zip \
  -o ~/k8s/quickstart/tools/imagetool.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 2075k  100 2075k    0     0  1322k      0  0:00:01  0:00:01 --:--:-- 4572k

$ imagetool.sh cache addInstaller \
  --type wdt \
  --version latest \
  --path ~/k8s/quickstart/tools/weblogic-deploy.zip
list files in WDT
[dave@fedora k8s]$ find weblogic-deploy -type d
weblogic-deploy
weblogic-deploy/etc
weblogic-deploy/lib
weblogic-deploy/lib/python
weblogic-deploy/lib/python/wlsdeploy
weblogic-deploy/lib/python/wlsdeploy/util
weblogic-deploy/lib/python/wlsdeploy/json
weblogic-deploy/lib/python/wlsdeploy/yaml
weblogic-deploy/lib/python/wlsdeploy/aliases
weblogic-deploy/lib/python/wlsdeploy/exception
weblogic-deploy/lib/python/wlsdeploy/logging
weblogic-deploy/lib/python/wlsdeploy/tool
weblogic-deploy/lib/python/wlsdeploy/tool/validate
weblogic-deploy/lib/python/wlsdeploy/tool/discover
weblogic-deploy/lib/python/wlsdeploy/tool/util
weblogic-deploy/lib/python/wlsdeploy/tool/util/filters
weblogic-deploy/lib/python/wlsdeploy/tool/util/targets
weblogic-deploy/lib/python/wlsdeploy/tool/prepare
weblogic-deploy/lib/python/wlsdeploy/tool/deploy
weblogic-deploy/lib/python/wlsdeploy/tool/compare
weblogic-deploy/lib/python/wlsdeploy/tool/extract
weblogic-deploy/lib/python/wlsdeploy/tool/modelhelp
weblogic-deploy/lib/python/wlsdeploy/tool/encrypt
weblogic-deploy/lib/python/wlsdeploy/tool/create
weblogic-deploy/lib/typedefs
weblogic-deploy/lib/targets
weblogic-deploy/lib/targets/vz
weblogic-deploy/lib/targets/wko4-pv
weblogic-deploy/lib/targets/wko4
weblogic-deploy/lib/targets/wko-pv
weblogic-deploy/lib/targets/vz-dii
weblogic-deploy/lib/targets/k8s
weblogic-deploy/lib/targets/wko4-dii
weblogic-deploy/lib/targets/vz-pv
weblogic-deploy/lib/targets/wko-dii
weblogic-deploy/lib/targets/templates
weblogic-deploy/lib/targets/wko
weblogic-deploy/lib/injectors
weblogic-deploy/bin
weblogic-deploy/samples

unzip image tool
[dave@fedora k8s]$ unzip  imagetool.zip 
Archive:  imagetool.zip
   creating: imagetool/
   creating: imagetool/lib/
  inflating: imagetool/lib/fluent-hc-4.5.14.jar  
  inflating: imagetool/lib/httpclient-4.5.14.jar  
  inflating: imagetool/lib/httpcore-4.4.16.jar  
  inflating: imagetool/lib/commons-logging-1.2.jar  
  inflating: imagetool/lib/commons-codec-1.11.jar  
  inflating: imagetool/lib/httpmime-4.5.14.jar  
  inflating: imagetool/lib/picocli-4.7.4.jar  
  inflating: imagetool/lib/compiler-0.9.10.jar  
   creating: imagetool/bin/
  inflating: imagetool/bin/setup.sh  
  inflating: imagetool/bin/logging.properties  
  inflating: imagetool/bin/imagetool.cmd  
  inflating: imagetool/bin/imagetool.sh  
  inflating: imagetool/LICENSE.txt   
  inflating: imagetool/lib/imagetool.jar  
  inflating: imagetool/lib/imagetool_completion.sh  
  inflating: imagetool/VERSION.txt   
[dave@fedora k8s]$ ls /home/


Download 

 and put them in your ~/k8s/quickstart/models directory. 

Then use the jar command to put the web application files into a model archive ZIP file.


[dave@fedora k8s]$ imagetool.sh cache deleteEntry --key wdt_latest
[INFO   ] Nothing to delete for key: wdt_latest
[dave@fedora k8s]$ imagetool.sh cache addInstaller \
  --type wdt \
  --version latest \
  --path imagetool.zip 
[INFO   ] Successfully added to cache. wdt_latest=/home/dave/k8s/imagetool.zip
[dave@fedora k8s]$ mkdir -p ~/k8s/quickstart/models/archive/wlsdeploy/applications/quickstart/WEB-INF
[dave@fedora k8s]$ curl -m 120 -fL https://raw.githubusercontent.com/oracle/weblogic-kubernetes-operator/release/4.1/kubernetes/samples/quick-start/model.yaml -o ~/k8s/quickstart/models/model.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1057  100  
$ curl -m 120 -fL https://raw.githubusercontent.com/oracle/weblogic-kubernetes-operator/release/4.1/kubernetes/samples/quick-start/model.properties -o ~/k8s/quickstart/models/model.properties
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    94  100    94    0     0    405      0 --:--:-- --:--:-- --:--:--   406

[dave@fedora k8s]$ curl -m 120 -fL https://raw.githubusercontent.com/oracle/weblogic-kubernetes-operator/release/4.1/kubernetes/samples/quick-start/archive/wlsdeploy/applications/quickstart/index.jsp -o ~/k8s/quickstart/models/archive/wlsdeploy/applications/quickstart/index.jsp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1243  100  1243    0     0   4836      0 --:--:-- --:--:-- --:--:--  4855
[dave@fedora k8s]$ curl -m 120 -fL https://raw.githubusercontent.com/oracle/weblogic-kubernetes-operator/release/4.1/kubernetes/samples/quick-start/archive/wlsdeploy/applications/quickstart/WEB-INF/web.xml -o ~/k8s/quickstart/models/archive/wlsdeploy/applications/quickstart/WEB-INF/web.xml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   390  100   390    0     0   1461      0 --:--:-- --:--:-- --:--:--  1460
[dave@fedora k8s]$ jar cvf ~/k8s/quickstart/models/archive.zip -C ~/k8s/quickstart/models/archive/ wlsdeploy
added manifest
adding: wlsdeploy/(in = 0) (out= 0)(stored 0%)
adding: wlsdeploy/applications/(in = 0) (out= 0)(stored 0%)
adding: wlsdeploy/applications/quickstart/(in = 0) (out= 0)(stored 0%)
adding: wlsdeploy/applications/quickstart/WEB-INF/(in = 0) (out= 0)(stored 0%)
adding: wlsdeploy/applications/quickstart/WEB-INF/web.xml(in = 390) (out= 278)(deflated 28%)
adding: wlsdeploy/applications/quickstart/index.jsp(in = 1243) (out= 585)(deflated 52%)
[dave@fedora k8s]$ jar tvf ~/k8s/quickstart/models/archive.zip
     0 Sat Mar 02 20:02:28 CET 2024 META-INF/
    67 Sat Mar 02 20:02:28 CET 2024 META-INF/MANIFEST.MF
     0 Sat Mar 02 20:00:06 CET 2024 wlsdeploy/
     0 Sat Mar 02 20:00:06 CET 2024 wlsdeploy/applications/
     0 Sat Mar 02 20:01:32 CET 2024 wlsdeploy/applications/quickstart/
     0 Sat Mar 02 20:01:54 CET 2024 wlsdeploy/applications/quickstart/WEB-INF/
   390 Sat Mar 02 20:01:54 CET 2024 wlsdeploy/applications/quickstart/WEB-INF/web.xml
  1243 Sat Mar 02 20:01:32 CET 2024 wlsdeploy/applications/quickstart/index.jsp

Model files
$ find quickstart/models/
quickstart/models/
quickstart/models/archive
quickstart/models/archive/wlsdeploy
quickstart/models/archive/wlsdeploy/applications
quickstart/models/archive/wlsdeploy/applications/quickstart
quickstart/models/archive/wlsdeploy/applications/quickstart/WEB-INF
quickstart/models/archive/wlsdeploy/applications/quickstart/WEB-INF/web.xml
quickstart/models/archive/wlsdeploy/applications/quickstart/index.jsp
quickstart/models/model.yaml
quickstart/models/archive.zip
quickstart/models/model.properties

Create auxiliary image containing WDT model YAML files application archives the WDT installation files
 $ imagetool.sh createAuxImage   --tag quick-start-aux-image:v1   --wdtModel ~/k8s/quickstart/models/model.yaml   --wdtVariables ~/k8s/quickstart/models/model.properties   --wdtArchive ~/k8s/quickstart/models/archive.zip
[INFO   ] WebLogic Image Tool version 1.12.1
[INFO   ] Image Tool build ID: bcc59d31-b52a-4464-95c5-0e49307fb550
[INFO   ] Temporary directory used for image build context: /home/dave/wlsimgbuilder_temp1447416871605136089
[INFO   ] Copying /home/dave/k8s/quickstart/models/model.yaml to build context folder.
[INFO   ] Copying /home/dave/k8s/quickstart/models/archive.zip to build context folder.
[INFO   ] Copying /home/dave/k8s/quickstart/models/model.properties to build context folder.
[INFO   ] Copying /home/dave/k8s/quickstart/tools/weblogic-deploy.zip to build context folder.
[INFO   ] Starting build: docker build --no-cache --force-rm --tag quick-start-aux-image:v1 /home/dave/wlsimgbuilder_temp1447416871605136089
[INFO   ] Build successful. Build time=3s. Image tag=quick-start-aux-image:v1

Check created Docker image
$ docker images quick-start-aux-image:v1
REPOSITORY              TAG       IMAGE ID       CREATED          SIZE
quick-start-aux-image   v1        7d0eca09a837   40 seconds ago   6.65MB

After the image is created, it will have the WDT executables in /auxiliary/weblogic-deploy, and WDT model, property, and archive files in /auxiliary/models. You can run ls in the Docker image to verify this.
$  docker run -it --rm quick-start-aux-image:v1 ls -l /auxiliary
total 0
drwxr-x---    1 oracle   oracle          56 Mar  2 19:12 imagetool
drwxr-xr-x    1 oracle   oracle          74 Mar  2 19:12 models
[dave@fedora k8s]$ docker run -it --rm quick-start-aux-image:v1 ls -l /auxiliary/models
total 12
-rw-r-----    1 oracle   oracle        2092 Mar  2 19:12 archive.zip
-rw-r-----    1 oracle   oracle          94 Mar  2 19:12 model.properties
-rw-r-----    1 oracle   oracle        1057 Mar  2 19:12 model.yaml

weblogic-deploy
$ docker run -it --rm quick-start-aux-image:v1 ls -l /auxiliary/weblogic-deploy
total 8
-rw-r-----    1 oracle   oracle        1839 Mar  2 19:27 LICENSE.txt
-rw-r-----    1 oracle   oracle          29 Mar  2 19:27 VERSION.txt
drwxr-x---    1 oracle   oracle         826 Mar  2 19:27 bin
drwxr-x---    1 oracle   oracle          36 Mar  2 19:27 etc
drwxr-x---    1 oracle   oracle         298 Mar  2 19:27 lib
drwxr-x---    1 oracle   oracle          96 Mar  2 19:27 samples

Create the domain model file Check deployed app in Weblogic console
Quick start app URL 





Viewing all articles
Browse latest Browse all 181

Trending Articles