Thursday, December 26, 2019

Continuous Deployment (CD) with Jenkins and Kubernetes on Google Cloud

Jenkins on Kubernetes Engine

https://cloud.google.com/solutions/jenkins-on-kubernetes-engine

https://cloud.google.com/solutions/jenkins-on-kubernetes-engine-tutorial

Provision a Jenkins environment on a Kubernetes Engine Cluster, using the Helm Package Manager.
Google Kubernetes Engine (GKE) is the hosted version of Kubernetes on Google Cloud Platform (GCP).

Create k8s cluster

gcloud container clusters create jenkins-cd \

  --num-nodes 2 \

  --machine-type n1-standard-2 \

  --cluster-version 1.13 \

  --service-account "jenkins-sa@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com"


 Jenkins Kubernetes plugin
https://wiki.jenkins-ci.org/display/JENKINS/Kubernetes+Plugin 

Scale

kubectl --namespace=production scale deployment gceme-frontend-production --replicas=4


Port forward

export DEV_POD_NAME=$(kubectl get pods -n new-feature -l "app=gceme,env=dev,role=frontend" -o jsonpath="{.items[0].metadata.name}")

kubectl port-forward -n new-feature $DEV_POD_NAME 8001:80 >> /dev/null &




export FRONTEND_SERVICE_IP=$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].ip}" --namespace=production services gceme-frontend)


while true; do curl http://$FRONTEND_SERVICE_IP/version; sleep 1; done






Application deployment into Google Kubernetes Engine on Google Cloud

Kubernetes https://kubernetes.io/

Google Kubernetes Engine  https://cloud.google.com/container-engine

Sample app https://github.com/kelseyhightower/app
 It's a 12-Factor application with the following Docker images:
  • Monolith: includes auth and hello services.
  • Auth microservice: generates JWT tokens for authenticated users.
  • Hello microservice: greets authenticated users.
  • nginx: frontend to the auth and hello services.
 

Tools

The gcloud command-line interface is a tool that provides the primary CLI to Google Cloud Platform.
https://cloud.google.com/sdk/gcloud/

Access the Kubernetes pods


Pods are allocated a private IP address by default that cannot be reached outside of the cluster. Use the kubectl port-forward command to map a local port to a port inside the monolith pod.

kubectl port-forward myapp  9999:80  
 
  
 
TOKEN=$(curl http://127.0.0.1:9999/login -u user|jq -r '.token') 
 
  
 
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:9999/secure  


Run shell inside pod

kubectl exec myapp --stdin --tty -c myapp /bin/sh


This uploads cert files from the local directory tls/ and stores them in a secret called tls-certs.

kubectl create secret generic tls-certs --from-file tls/

kubectl create configmap nginx-proxy-conf --from-file nginx/proxy.conf


more nginx/proxy.conf

server {

  listen 443;

  ssl    on;

 
  ssl_certificate     /etc/tls/cert.pem;

  ssl_certificate_key /etc/tls/key.pem;

 
  location / {

    proxy_pass http://127.0.0.1:80;

  }

}


Setup firewall
gcloud compute firewall-rules create allow-myapp-nodeport --allow=tcp:31000



NAME                     NETWORK  DIRECTION  PRIORITY  ALLOW      DENY  DISABLED

allow-myapp-nodeport  default  INGRESS    1000      tcp:31000        False


Get pods with secure=enabled

kubectl get pods -l "app=myapp,secure=enabled"


Get endpoints

kubectl get endpoints monolith




Sunday, November 17, 2019

Deploying microservices to Kubernetes using OpenLiberty


OpenLiberty sample github
https://github.com/OpenLiberty/guide-kubernetes-intro

OpenLiberty tutorial
https://openliberty.io/guides/kubernetes-intro.html#what-youll-learn

MiniKubernetes installation guide
https://github.com/kubernetes/minikube#installation

Minikube Linux install
https://minikube.sigs.k8s.io/docs/start/linux/

Fedora Getting started with virtualization
https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-virtualization/


Dependencies resolved. 
================================================================================================================================================== 
 Package                                      Architecture                Version                               Repository                   Size 
================================================================================================================================================== 
Installing group/module packages: 
 virt-install                                 noarch                      2.2.1-2.fc31                          fedora                       64 k 
 virt-manager                                 noarch                      2.2.1-2.fc31                          fedora                      543 k 
 virt-viewer                                  x86_64                      8.0-3.fc31                            fedora                      404 k 
Installing dependencies: 
 autogen-libopts                              x86_64                      5.18.16-3.fc31                        fedora                       75 k 
 gnutls-dane                                  x86_64                      3.6.10-1.fc31                         fedora                       27 k 
 gnutls-utils                                 x86_64                      3.6.10-1.fc31                         fedora                      341 k 
 libgovirt                                    x86_64                      0.3.4-9.fc30                          fedora                       71 k 
 libvirt-bash-completion                      x86_64                      5.6.0-4.fc31                          fedora                       12 k 
 libvirt-client                               x86_64                      5.6.0-4.fc31                          fedora                      343 k 
 python3-libvirt                              x86_64                      5.6.0-1.fc31                          fedora                      294 k 
 virt-manager-common                          noarch                      2.2.1-2.fc31                          fedora                      1.0 M 
Installing Groups: 
 Virtualization            


dave@localhost finish]$ sudo systemctl start libvirtd
[dave@localhost finish]$ sudo systemctl enable libvirtd
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd.socket → /usr/lib/systemd/system/libvirtd.socket.
Created symlink /etc/systemd/system/sockets.target.wants/libvirtd-ro.socket → /usr/lib/systemd/system/libvirtd-ro.socket.
[dave@localhost finish]$ lsmod | grep kvm
kvm_intel             299008  0
kvm                   770048  1 kvm_intel
irqbypass              16384  1 kvm


Some errors appear in virt validation

[dave@localhost finish]$ virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
  QEMU: Checking if device /dev/net/tun exists                               : PASS
  QEMU: Checking for cgroup 'cpu' controller support                         : WARN (Enable 'cpu' in kernel Kconfig file or mount/enable cgroup controller in your system)
  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS
  QEMU: Checking for cgroup 'cpuset' controller support                      : WARN (Enable 'cpuset' in kernel Kconfig file or mount/enable cgroup controller in your system)
  QEMU: Checking for cgroup 'memory' controller support                      : PASS
  QEMU: Checking for cgroup 'devices' controller support                     : WARN (Enable 'devices' in kernel Kconfig file or mount/enable cgroup controller in your system)
  QEMU: Checking for cgroup 'blkio' controller support                       : WARN (Enable 'blkio' in kernel Kconfig file or mount/enable cgroup controller in your system)
  QEMU: Checking for device assignment IOMMU support                         : PASS
  QEMU: Checking if IOMMU is enabled by kernel                               : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments)
   LXC: Checking for Linux >= 2.6.26                                         : PASS
   LXC: Checking for namespace ipc                                           : PASS
   LXC: Checking for namespace mnt                                           : PASS
   LXC: Checking for namespace pid                                           : PASS
   LXC: Checking for namespace uts                                           : PASS
   LXC: Checking for namespace net                                           : PASS
   LXC: Checking for namespace user                                          : PASS
   LXC: Checking for cgroup 'cpu' controller support                         : FAIL (Enable 'cpu' in kernel Kconfig file or mount/enable cgroup controller in your system)
   LXC: Checking for cgroup 'cpuacct' controller support                     : PASS
   LXC: Checking for cgroup 'cpuset' controller support                      : FAIL (Enable 'cpuset' in kernel Kconfig file or mount/enable cgroup controller in your system)
   LXC: Checking for cgroup 'memory' controller support                      : PASS
   LXC: Checking for cgroup 'devices' controller support                     : FAIL (Enable 'devices' in kernel Kconfig file or mount/enable cgroup controller in your system)
   LXC: Checking for cgroup 'freezer' controller support                     : FAIL (Enable 'freezer' in kernel Kconfig file or mount/enable cgroup controller in your system)
   LXC: Checking for cgroup 'blkio' controller support                       : FAIL (Enable 'blkio' in kernel Kconfig file or mount/enable cgroup controller in your system)
   LXC: Checking if device /sys/fs/fuse/connections exists                   : PASS


[root@localhost ~]# sudo dnf config-manager --add-repo=https://download.docker.com/linux/fedora/docker-ce.repo

Adding repo from: https://download.docker.com/linux/fedora/docker-ce.repo

 


After Docker installtion all tests pass

[root@localhost ~]# virt-host-validate

  QEMU: Checking for hardware virtualization                                 : PASS

  QEMU: Checking if device /dev/kvm exists                                   : PASS

  QEMU: Checking if device /dev/kvm is accessible                            : PASS

  QEMU: Checking if device /dev/vhost-net exists                             : PASS

  QEMU: Checking if device /dev/net/tun exists                               : PASS

  QEMU: Checking for cgroup 'cpu' controller support                         : PASS

  QEMU: Checking for cgroup 'cpuacct' controller support                     : PASS

  QEMU: Checking for cgroup 'cpuset' controller support                      : PASS

  QEMU: Checking for cgroup 'memory' controller support                      : PASS

  QEMU: Checking for cgroup 'devices' controller support                     : PASS

  QEMU: Checking for cgroup 'blkio' controller support                       : PASS

  QEMU: Checking for device assignment IOMMU support                         : PASS

  QEMU: Checking if IOMMU is enabled by kernel                               : WARN (IOMMU appears to be disabled in kernel. Add intel_iommu=on to kernel cmdline arguments)

   LXC: Checking for Linux >= 2.6.26                                         : PASS

   LXC: Checking for namespace ipc                                           : PASS

   LXC: Checking for namespace mnt                                           : PASS

   LXC: Checking for namespace pid                                           : PASS

   LXC: Checking for namespace uts                                           : PASS

   LXC: Checking for namespace net                                           : PASS

   LXC: Checking for namespace user                                          : PASS

   LXC: Checking for cgroup 'cpu' controller support                         : PASS

   LXC: Checking for cgroup 'cpuacct' controller support                     : PASS

   LXC: Checking for cgroup 'cpuset' controller support                      : PASS

   LXC: Checking for cgroup 'memory' controller support                      : PASS

   LXC: Checking for cgroup 'devices' controller support                     : PASS

   LXC: Checking for cgroup 'freezer' controller support                     : PASS

   LXC: Checking for cgroup 'blkio' controller support                       : PASS

   LXC: Checking if device /sys/fs/fuse/connections exists                   : PASS

 


Install minikube
https://minikube.sigs.k8s.io/docs/start/linux/



 
Download and install minikube to /usr/local/bin:

 
 curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \

   && sudo install minikube-linux-amd64 /usr/local/bin/minikube

 
 


Start minukube

[dave@localhost ~]$ minikube start --vm-driver=kvm2

😄  minikube v1.5.2 on Fedora 31

✨  Automatically selected the 'kvm2' driver (alternates: [none])

💾  Downloading driver docker-machine-driver-kvm2:

    > docker-machine-driver-kvm2.sha256: 65 B / 65 B [-------] 100.00% ? p/s 0s

    > docker-machine-driver-kvm2: 13.87 MiB / 13.87 MiB  100.00% 8.94 MiB p/s 2

💿  Downloading VM boot image ...

    > minikube-v1.5.1.iso.sha256: 65 B / 65 B [--------------] 100.00% ? p/s 0s

    > minikube-v1.5.1.iso: 143.76 MiB / 143.76 MiB [-] 100.00% 17.68 MiB p/s 9s

🔥  Creating kvm2 VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...

 

dave@localhost ~]$ minikube start

😄  minikube v1.5.2 on Fedora 31

💡  Tip: Use 'minikube start -p <name>' to create a new cluster, or 'minikube delete' to delete this one.

🏃  Using the running kvm2 "minikube" VM ...

⌛  Waiting for the host to be provisioned ...

🐳  Preparing Kubernetes v1.16.2 on Docker '18.09.9' ...

💾  Downloading kubeadm v1.16.2

💾  Downloading kubelet v1.16.2

🔄  Relaunching Kubernetes using kubeadm ... 

 

Need to work on virtual host configuration

🔄  Relaunching Kubernetes using kubeadm ... 

  
💣  Error restarting cluster: waiting for apiserver: apiserver process never appeared

 


Need to download and install Fedora 31 image

Create storage

dd if=/dev/zero of=/var/lib/libvirt/images/guest.img bs=1M count=20480


Download ISO image at https://getfedora.org/en/workstation/download/

 root@localhost ~]# cp /home/dave/Downloads/Fedora-Workstation-Live-x86_64-31-1.9.iso /var/lib/libvirt/images/Fedora-Workstation-31/
 root@localhost ~]# virt-install --name Fedora31 --description 'Fedora 31 Workstation' --ram 4096 --vcpus 2 --disk path=/var/lib/libvirt/images/Fedora-Workstation-31/Fedora-Workstation-31-20180518.0.x86_64.qcow2,size=20 --os-type linux --os-variant fedora31 --network bridge=virbr0 --graphics vnc,listen=127.0.0.1,port=5901 --cdrom /var/lib/libvirt/images/Fedora-Workstation-31/Fedora-Workstation-Live-x86_64-31-1.9.iso --noautoconsole

Install Kubernetes client
[root@localhost ~]# dnf install kubernetes-client

 


dave@localhost ~]$  kubectl get po -A

NAMESPACE     NAME                               READY   STATUS    RESTARTS   AGE

kube-system   coredns-5644d7b6d9-hgfrq           1/1     Running   0          3m27s

kube-system   coredns-5644d7b6d9-rh2wp           1/1     Running   0          3m27s

kube-system   etcd-minikube                      1/1     Running   0          2m24s

kube-system   kube-addon-manager-minikube        1/1     Running   0          3m37s

kube-system   kube-apiserver-minikube            1/1     Running   0          2m16s

kube-system   kube-controller-manager-minikube   1/1     Running   0          2m24s

kube-system   kube-proxy-brljs                   1/1     Running   0          3m26s

kube-system   kube-scheduler-minikube            1/1     Running   0          2m18s

kube-system   storage-provisioner                1/1     Running   0          3m25s

 

[dave@localhost guide-kubernetes-intro]$ ls

finish  LICENSE  README.adoc  scripts  start

[dave@localhost guide-kubernetes-intro]$ cd finish/

[dave@localhost finish]$ kubectl get nodes

NAME       STATUS   ROLES    AGE     VERSION

minikube   Ready    master   5m24s   v1.16.2

 


Follow the OpenLiberty guide

 https://openliberty.io/guides/kubernetes-intro.html#building-and-containerizing-the-microservices


https://openliberty.io/guides/kubernetes-intro.html#building-and-containerizing-the-microservices

[INFO] Reactor Summary for guide-kubernetes-intro 1.0-SNAPSHOT:

[INFO] 

[INFO] guide-kubernetes-intro ............................. SUCCESS [  0.114 s]

[INFO] system ............................................. SUCCESS [ 56.164 s]

[INFO] inventory .......................................... SUCCESS [  3.497 s]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time:  01:01 min

[INFO] Finished at: 2019-11-23T14:51:32+01:00

[INFO] ------------------------------------------------------------------------

 



Build Docker images

[dave@localhost finish]$ docker build -t system:1.0-SNAPSHOT system/.

Sending build context to Docker daemon  173.1MB

Step 1/2 : FROM open-liberty

latest: Pulling from library/open-liberty

7ddbc47eeb70: Pull complete 

c1bbdc448b72: Pull complete 

8c3b70e39044: Pull complete 

45d437916d57: Pull complete 

da4c04c54fa4: Pull complete 

8f6c6858a836: Pull complete 

5d00a703c295: Pull complete 

cb8753aefdab: Pull complete 

973c4edce328: Pull complete 

768f5576235d: Pull complete 

03125c94a5ec: Pull complete 

Digest: sha256:c23b036bed7bd0dec141db5bbde186fb617fd67f4d2db4c1a7793eb483354fc9

Status: Downloaded newer image for open-liberty:latest

 ---> 33db8778e38a

Step 2/2 : ADD --chown=1001:0 target/system.tar.gz /opt/ol

 ---> 63fb2879e723

Successfully built 63fb2879e723

Successfully tagged system:1.0-SNAPSHOT

 


Build inventory image
[dave@localhost finish]$ docker build -t inventory:1.0-SNAPSHOT inventory/.

Sending build context to Docker daemon    174MB

Step 1/2 : FROM open-liberty

 ---> 33db8778e38a

Step 2/2 : ADD --chown=1001:0 target/inventory.tar.gz /opt/ol

 ---> c2f7faff812d

Successfully built c2f7faff812d

Successfully tagged inventory:1.0-SNAPSHOT

 


List of Docker images

[dave@localhost finish]$ docker images

REPOSITORY                                TAG                 IMAGE ID            CREATED              SIZE

inventory                                 1.0-SNAPSHOT        c2f7faff812d        44 seconds ago       393MB

system                                    1.0-SNAPSHOT        63fb2879e723        About a minute ago   393MB

open-liberty                              latest              33db8778e38a        2 weeks ago          392MB

k8s.gcr.io/kube-proxy                     v1.16.2             8454cbe08dc9        5 weeks ago          86.1MB

k8s.gcr.io/kube-controller-manager        v1.16.2             6e4bffa46d70        5 weeks ago          163MB

k8s.gcr.io/kube-apiserver                 v1.16.2             c2c9a0406787        5 weeks ago          217MB

k8s.gcr.io/kube-scheduler                 v1.16.2             ebac1ae204a2        5 weeks ago          87.3MB

k8s.gcr.io/etcd                           3.3.15-0            b2756210eeab        2 months ago         247MB

k8s.gcr.io/coredns                        1.6.2               bf261d157914        3 months ago         44.1MB

k8s.gcr.io/kube-addon-manager             v9.0.2              bd12a212f9dc        4 months ago         83.1MB

k8s.gcr.io/kube-addon-manager             v9.0                119701e77cbc        10 months ago        83.1MB

k8s.gcr.io/kubernetes-dashboard-amd64     v1.10.1             f9aed6605b81        11 months ago        122MB

k8s.gcr.io/k8s-dns-sidecar-amd64          1.14.13             4b2e93f0133d        14 months ago        42.9MB

k8s.gcr.io/k8s-dns-kube-dns-amd64         1.14.13             55a3c5209c5e        14 months ago        51.2MB

k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64    1.14.13             6dc8ef8287d3        14 months ago        41.4MB

k8s.gcr.io/pause                          3.1                 da86e6ba6ca1        23 months ago        742kB

gcr.io/k8s-minikube/storage-provisioner   v1.8.1              4689081edb10        2 years ago          80.8MB

 


kubernetes.yaml
apiVersion: apps/v1

kind: Deployment

metadata:

  name: system-deployment

  labels:

    app: system

spec:

  selector:

    matchLabels:

      app: system

  template:

    metadata:

      labels:

        app: system

    spec:

      containers:

      - name: system-container

        image: system:1.0-SNAPSHOT

        ports:

        - containerPort: 9080

---

apiVersion: apps/v1

kind: Deployment

metadata:

  name: inventory-deployment

  labels:

    app: inventory

spec:

  selector:

    matchLabels:

      app: inventory

  template:

    metadata:

      labels:

        app: inventory

    spec:

      containers:

      - name: inventory-container

        image: inventory:1.0-SNAPSHOT

        ports:

        - containerPort: 9080

---

apiVersion: v1

kind: Service

metadata:

  name: system-service

spec:

  type: NodePort

  selector:

    app: system

  ports:

  - protocol: TCP

    port: 9080

    targetPort: 9080

    nodePort: 31000

---

apiVersion: v1

kind: Service

metadata:

  name: inventory-service

spec:

  type: NodePort

  selector:

    app: inventory

  ports:

  - protocol: TCP

    port: 9080

    targetPort: 9080

    nodePort: 32000


[dave@localhost finish]$ kubectl apply -f kubernetes.yaml

deployment.apps/system-deployment created

deployment.apps/inventory-deployment created

service/system-service created

service/inventory-service created

 



get pods

[dave@localhost finish]$ kubectl get pods

NAME                                    READY   STATUS    RESTARTS   AGE

inventory-deployment-759769c979-tzq9b   1/1     Running   0          24s

system-deployment-94895d89d-6dpp6       1/1     Running   0          24s

[dave@localhost finish]$ 

 


Describe pods
[dave@localhost finish]$ kubectl describe pods

Name:           inventory-deployment-759769c979-tzq9b

Namespace:      default

Priority:       0

Node:           minikube/192.168.39.189

Start Time:     Sat, 23 Nov 2019 14:55:44 +0100

Labels:         app=inventory

                pod-template-hash=759769c979

Annotations:    <none>

Status:         Running

IP:             172.17.0.5

Controlled By:  ReplicaSet/inventory-deployment-759769c979

Containers:

  inventory-container:

    Container ID:   docker://255c6a483511976cc861a644e3c83049411c9dfb9deb39694ed2f456f821a0bf

    Image:          inventory:1.0-SNAPSHOT

    Image ID:       docker://sha256:c2f7faff812d29712919e170acb72ce64192ba9fee543ce1b56a3f3271c59ae1

    Port:           9080/TCP

    Host Port:      0/TCP

    State:          Running

      Started:      Sat, 23 Nov 2019 14:55:45 +0100

    Ready:          True

    Restart Count:  0

    Environment:    <none>

    Mounts:

      /var/run/secrets/kubernetes.io/serviceaccount from default-token-z9cp2 (ro)

Conditions:

  Type              Status

  Initialized       True 

  Ready             True 

  ContainersReady   True 

  PodScheduled      True 

Volumes:

  default-token-z9cp2:

    Type:        Secret (a volume populated by a Secret)

    SecretName:  default-token-z9cp2

    Optional:    false

QoS Class:       BestEffort

Node-Selectors:  <none>

Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s

                 node.kubernetes.io/unreachable:NoExecute for 300s

Events:

  Type    Reason     Age        From               Message

  ----    ------     ----       ----               -------

  Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned default/inventory-deployment-759769c979-tzq9b to minikube

  Normal  Pulled     49s        kubelet, minikube  Container image "inventory:1.0-SNAPSHOT" already present on machine

  Normal  Created    49s        kubelet, minikube  Created container inventory-container

  Normal  Started    48s        kubelet, minikube  Started container inventory-container

 
 
Name:           system-deployment-94895d89d-6dpp6

Namespace:      default

Priority:       0

Node:           minikube/192.168.39.189

Start Time:     Sat, 23 Nov 2019 14:55:44 +0100

Labels:         app=system

                pod-template-hash=94895d89d

Annotations:    <none>

Status:         Running

IP:             172.17.0.4

Controlled By:  ReplicaSet/system-deployment-94895d89d

Containers:

  system-container:

    Container ID:   docker://eaaaa4976cd8ec0218872276faacf9bd52dcfac125ab2a1ce372ab692d88b859

    Image:          system:1.0-SNAPSHOT

    Image ID:       docker://sha256:63fb2879e723f56f74af3ec4ad6f4672ba3dbe8db3b162a5cb80b7496703f1c2

    Port:           9080/TCP

    Host Port:      0/TCP

    State:          Running

      Started:      Sat, 23 Nov 2019 14:55:45 +0100

    Ready:          True

    Restart Count:  0

    Environment:    <none>

    Mounts:

      /var/run/secrets/kubernetes.io/serviceaccount from default-token-z9cp2 (ro)

Conditions:

  Type              Status

  Initialized       True 

  Ready             True 

  ContainersReady   True 

  PodScheduled      True 

Volumes:

  default-token-z9cp2:

    Type:        Secret (a volume populated by a Secret)

    SecretName:  default-token-z9cp2

    Optional:    false

QoS Class:       BestEffort

Node-Selectors:  <none>

Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s

                 node.kubernetes.io/unreachable:NoExecute for 300s

Events:

  Type    Reason     Age        From               Message

  ----    ------     ----       ----               -------

  Normal  Scheduled  <unknown>  default-scheduler  Successfully assigned default/system-deployment-94895d89d-6dpp6 to minikube

  Normal  Pulled     49s        kubelet, minikube  Container image "system:1.0-SNAPSHOT" already present on machine

  Normal  Created    49s        kubelet, minikube  Created container system-container

  Normal  Started    48s        kubelet, minikube  Started container system-container

 


Get ip
[dave@localhost finish]$ minikube ip 

192.168.39.189

 



Test  endpoint
[dave@localhost finish]$ curl http://192.168.39.189:31000/system/properties

{"java.vendor":"Eclipse OpenJ9","default.https.port":"9443","sun.java.launcher":"SUN_STANDARD","shared.resource.dir":"/opt/ol/wlp/usr/shared/resources/","os.name":"Linux","kernel.launch.time":"809693252842","sun.boot.class.path":"/opt/java/openjdk/lib/amd64/compressedrefs/jclSC180/vm.jar:/opt/java/openjdk/lib/se-service.jar:/opt/java/openjdk/lib/rt.jar:/opt/java/openjdk/lib/resources.jar:/opt/java/openjdk/lib/jsse.jar:/opt/java/openjdk/lib/charsets.jar:/opt/java/openjdk/lib/jce.jar","default.http.port":"9080","java.vm.specification.vendor":"Oracle Corporation","shared.app.dir":"/opt/ol/wlp/usr/shared/apps/","java.runtime.version":"1.8.0_232-b09","wlp.lib.dir":"/opt/ol/wlp/lib/","wlp.workarea.dir":"workarea/","user.name":"default","java.compiler":"j9jit29","os.encoding":"UTF-8","com.ibm.util.extralibs.properties":"","com.ibm.jcl.checkClassPath":"","server.tmp.dir":"/opt/ol/wlp/output/defaultServer/workarea/tmp/","user.language":"en","jdk.attach.allowAttachSelf":"true","com.ibm.oti.vm.bootstrap.library.path":"/opt/java/openjdk/lib/amd64/compressedrefs:/opt/java/openjdk/lib/amd64","sun.boot.library.path":"/opt/java/openjdk/lib/amd64/compressedrefs:/opt/java/openjdk/lib/amd64","wlp.install.dir":"/opt/ol/wlp/","server.output.dir":"/opt/ol/wlp/output/defaultServer/","jdk.extensions.version":"8.0.232.0","java.util.logging.manager":"com.ibm.ws.kernel.boot.logging.WsLogManager","java.version":"1.8.0_232","user.timezone":"GMT","com.ibm.system.agent.path":"/opt/java/openjdk/lib/amd64","sun.arch.data.model":"64","com.ibm.zero.version":"2","java.endorsed.dirs":"/opt/java/openjdk/lib/endorsed","com.ibm.oti.vm.library.version":"29","sun.jnu.encoding":"UTF-8","file.encoding.pkg":"sun.io","file.separator":"/","java.specification.name":"Java Platform API Specification","java.class.version":"52.0","user.country":"US","java.home":"/opt/java/openjdk","java.vm.info":"JRE 1.8.0 Linux amd64-64-Bit Compressed References 20191017_442 (JIT enabled, AOT enabled)\nOpenJ9   - 77c1cf708\nOMR      - 20db4fbc\nJCL      - 97b5ec8f383 based on jdk8u232-b09","os.version":"4.19.76","java.awt.fonts":"","path.separator":":","org.apache.aries.blueprint.preemptiveShutdown":"false","java.vm.version":"openj9-0.17.0","user.variant":"","wlp.user.dir.isDefault":"true","ibm.cds.suppresserrors":"true","java.awt.printerjob":"sun.print.PSPrinterJob","jdk.extensions.name":"Extensions for OpenJDK for Eclipse OpenJ9","sun.io.unicode.encoding":"UnicodeLittle","awt.toolkit":"sun.awt.X11.XToolkit","ibm.signalhandling.sigint":"true","org.apache.cxf.stax.allowInsecureParser":"1","user.home":"/home/default","com.ibm.cpu.endian":"little","java.specification.vendor":"Oracle Corporation","ibm.signalhandling.sigchain":"true","org.jboss.weld.xml.disableValidating":"true","java.library.path":"/opt/java/openjdk/lib/amd64/compressedrefs:/opt/java/openjdk/lib/amd64:/usr/lib64:/usr/lib","java.vendor.url":"http://www.eclipse.org/openj9","java.vm.vendor":"Eclipse OpenJ9","java.fullversion":"1.8.0_232-b09\nJRE 1.8.0 Linux amd64-64-Bit Compressed References 20191017_442 (JIT enabled, AOT enabled)\nOpenJ9   - 77c1cf708\nOMR      - 20db4fbc\nJCL      - 97b5ec8f383 based on jdk8u232-b09","java.runtime.name":"OpenJDK Runtime Environment","sun.net.http.retryPost":"false","sun.java.command":"/opt/ol/wlp/bin/tools/ws-server.jar defaultServer","java.class.path":"/opt/ol/wlp/bin/tools/ws-server.jar:/opt/ol/wlp/bin/tools/ws-javaagent.jar:/opt/ol/wlp/bin/tools/ws-javaagent.jar","server.config.dir":"/opt/ol/wlp/usr/servers/defaultServer/","wlp.user.dir":"/opt/ol/wlp/usr/","java.vm.specification.name":"Java Virtual Machine Specification","sun.java.launcher.pid":"1","java.vm.specification.version":"1.8","sun.cpu.endian":"little","java.awt.headless":"true","java.io.tmpdir":"/tmp","ibm.system.encoding":"UTF-8","shared.config.dir":"/opt/ol/wlp/usr/shared/config/","os.arch":"amd64","java.awt.graphicsenv":"sun.awt.X11GraphicsEnvironment","ibm.signalhandling.rs":"false","java.ext.dirs":"/opt/java/openjdk/lib/ext","user.dir":"/opt/ol/wlp/output/defaultServer","line.separator":"\n","java.vm.name":"Eclipse OpenJ9 VM","com.ibm.oti.shared.enabled":"true","com.ibm.vm.bitmode":"64","wlp.process.type":"server","javax.management.builder.initial":"com.ibm.ws.kernel.boot.jmx.internal.PlatformMBeanServerBuilder","file.encoding":"UTF-8","java.specification.version":"1.8","com.ibm.oti.configuration":"scar","wlp.server.name":"defaultServer"}


Scale deployment
[dave@localhost finish]$ kubectl scale deployment/system-deployment --replicas=3

deployment.apps/system-deployment scaled

[dave@localhost finish]$ kubectl get pods

NAME                                    READY   STATUS    RESTARTS   AGE

inventory-deployment-759769c979-tzq9b   1/1     Running   0          11m

system-deployment-94895d89d-58mlq       1/1     Running   0          5s

system-deployment-94895d89d-6dpp6       1/1     Running   0          11m

system-deployment-94895d89d-9q9xz       1/1     Running   0          5s

 


Run tests

[INFO] -------------------------------------------------------

[INFO]  T E S T S

[INFO] -------------------------------------------------------

[INFO] Running it.io.openliberty.guides.inventory.InventoryEndpointTest

[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.188 s - in it.io.openliberty.guides.inventory.InventoryEndpointTest

[INFO] 

[INFO] Results:

[INFO] 

[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] 

[INFO] 

[INFO] --- liberty-maven-plugin:3.0.M1:test-stop-server (test-stop-server) @ inventory ---

[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:RELEASE:zip.

[INFO] CWWKM2102I: Using installDirectory : /git/guide-kubernetes-intro/finish/inventory/target/liberty/wlp.

[INFO] CWWKM2102I: Using serverName : defaultServer.

[INFO] CWWKM2102I: Using serverDirectory : /git/guide-kubernetes-intro/finish/inventory/target/liberty/wlp/usr/servers/defaultServer.

[INFO] CWWKM2152I: Stopping server defaultServer.

[INFO] CWWKM2001I: server.config.dir is /git/guide-kubernetes-intro/finish/inventory/target/liberty/wlp/usr/servers/defaultServer.

[INFO] CWWKM2001I: server.output.dir is /git/guide-kubernetes-intro/finish/inventory/target/liberty/wlp/usr/servers/defaultServer.

[INFO] CWWKM2001I: Invoke command is [/git/guide-kubernetes-intro/finish/inventory/target/liberty/wlp/bin/server, stop, defaultServer].

[INFO] 

[INFO] Stopping server defaultServer.

[INFO] Server defaultServer stopped.

[INFO] 

[INFO] --- maven-failsafe-plugin:3.0.0-M1:verify (verify-results) @ inventory ---

[INFO] ------------------------------------------------------------------------

[INFO] Reactor Summary for guide-kubernetes-intro 1.0-SNAPSHOT:

[INFO] 

[INFO] guide-kubernetes-intro ............................. SUCCESS [  0.003 s]

[INFO] system ............................................. SUCCESS [  8.917 s]

[INFO] inventory .......................................... SUCCESS [  9.144 s]

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

 


Resource usage


Virtual machine manager

[root@localhost ~]# virt-manager




Sunday, October 27, 2019

Deploy Java EE7 app into Weblogic Docker domain using Maven

Weblogic 12.2.1.4

General HOWTO

 Create Weblogic Docker image

See blogpost https://danielveselka.blogspot.com/2017/10/build-weblogic-docker-image.html

Create Weblogic generic Docker domain
See sample  from Oracle
https://github.com/oracle/docker-images/tree/master/OracleWebLogic/samples/12213-domain

Weblogic installers
https://www.oracle.com/middleware/technologies/weblogic-server-installers-downloads.html
12.2.1.4 now also has SLIM image  - interesting for Kubernetes deployment

 The WebLogic slim image is supported for development and production deployment of WebLogic configurations using Docker. In order to reduce image size, it contains a subset of the binaries included in the WebLogic generic image. The WebLogic console, WebLogic examples, WebLogic clients, Maven plug-ins and Java DB have been removed - all binaries that remain included are the same as those in the WebLogic generic image. The WebLogic slim image is primarily intended for WebLogic domains managed with the WebLogic Kubernetes Operator, when WLS console-based monitoring and configuration is not required, and a smaller image size than the generic image is preferred. If there are requirements to monitor the WebLogic configuration, they should be addressed using Prometheus and Grafana or other alternatives. All servers within a domain managed with the Operator will use the same WebLogic image. Support is also provided for environments where Kubernetes and/or the WebLogic Kubernetes Operator is not being used.

Get the sample code


Clone the modified code from https://github.com/dveselka/weblogic

 https://github.com/dveselka/weblogic/tree/master/docker-domain

Install generic Weblogic - required for Oracle Maven  repo configuration
[dave@localhost Downloads]$ java -jar fmw_12.2.1.4.0_wls.jar


Configure Oracle Maven  repository


https://blogs.oracle.com/weblogicserver/docker,-java-ee-7,-and-maven-with-weblogic-1213-v2

https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wlprg/maven.html#GUID-C6FC7582-2D1C-4EA5-B000-71AE9A2F2B05
 cd ./oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1

[dave@localhost 12.2.1]$ mvn install:install-file -DpomFile=oracle-maven-sync-12.2.1.pom -Dfile=oracle-maven-sync-12.2.1.jar
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /app/weblogic/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1/oracle-maven-sync-12.2.1.jar to /home/dave/.m2/repository/com/oracle/maven/oracle-maven-sync/12.2.1-4-0/oracle-maven-sync-12.2.1-4-0.jar
[INFO] Installing /app/weblogic/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.2.1/oracle-maven-sync-12.2.1.pom to /home/dave/.m2/repository/com/oracle/maven/oracle-maven-sync/12.2.1-4-0/oracle-maven-sync-12.2.1-4-0.pom

mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/app/weblogic

[INFO] SUMMARY
[INFO] ------------------------------------------------------------------------
[INFO] PUSH SUMMARY - ARTIFACTS PROCESSED SUCCESSFULLY
[INFO] ------------------------------------------------------------------------
[INFO] Number of artifacts pushed: 1267
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] PUSH SUMMARY - ERRORS ENCOUNTERED
[INFO] ------------------------------------------------------------------------
[INFO] No issues encountered.
[INFO] 
[INFO] IMPORTANT NOTE
[INFO] This operation may have added/updated archetypes in your repository.
[INFO] To update your archetype catalog, you should run:
[INFO] 'mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml'


[dave@localhost 12.2.1]$ find /home/dave/.m2/repository/com/oracle -name weblogic-maven-plugin
/home/dave/.m2/repository/com/oracle/weblogic/weblogic-maven-plugin

[dave@localhost 12.2.1]$ ls -l /home/dave/.m2/repository/com/oracle/weblogic/weblogic-maven-plugin
total 16
drwxrwxr-x. 2 dave dave 4096 Oct 27 12:40 12.2.1-0-0
drwxrwxr-x. 2 dave dave 4096 Oct 27 12:01 12.2.1-2-0
drwxrwxr-x. 2 dave dave 4096 Oct 27 12:38 12.2.1-4-0

Validate the installed Weblogic Maven plugin

mvn help:describe -DgroupId=com.oracle.weblogic -DartifactId=weblogic-maven-plugin -Dversion=12.2.1-4-0



Name: weblogic-maven-plugin
Description: The Oracle WebLogic Server 12.2.1 Maven plugin
Group Id: com.oracle.weblogic
Artifact Id: weblogic-maven-plugin
Version: 12.2.1-4-0
Goal Prefix: weblogic

This plugin has 23 goals:

weblogic:appc
  Description: This goal is a wrapper for the weblogic.appc compiler.

weblogic:create-domain
  Description: Create a domain for WebLogic Server using the default domain
    template. For more complex domain creation use the WLST goal. Note:
    Starting in WLS 12.2.1, there is a single unified version of WLST that
    automatically includes the WLST environment from all products in the
    ORACLE_HOME.

weblogic:deploy
  Description: Deploys an application to WebLogic Server (supports all
    formats WAR, JAR, RAR, EAR, etc.)

weblogic:distribute-app
  Description: Prepares deployment files for deployment by copying deployment
    files to target servers and validating them.

weblogic:install
  Description: Installs WebLogic Server

weblogic:list-apps
  Description: Lists the deployment names for applications and stand-alone
    modules deployed distributed, or installed to the domain

weblogic:purge-tasks
  Description: Flushes out retired deployment tasks

weblogic:redeploy
  Description: Redeploys a running application or part of a running
    application

weblogic:remove-domain
  Description: This class provides basic capabilities to remove a domain
    directory.

weblogic:start-app
  Description: Starts an application

weblogic:start-server
  Description: Starts WebLogic Server.

weblogic:stop-app
  Description: Stops an application

weblogic:stop-server
  Description: This goals run a stop script to stop WebLogic Server.

weblogic:undeploy
  Description: Stops the deployment unit and removes staged files from target
    servers

weblogic:uninstall
  Description: Uninstalls WebLogic Server

weblogic:update-app
  Description: Updates an application's deployment plan by redistributing the
    plan files and reconfiguring the application based on the new plan
    contents.

weblogic:wlst
  Description: This goal is a wrapper for the WLST scripting tool.
    Note: Starting in WLS 12.2.1, there is a single unified version of WLST
    that automatically includes the WLST environment from all products in the
    ORACLE_HOME.

weblogic:wlst-client
  Description: WLST wrapper for Maven that does not require a server install
    for WLST online commands.

weblogic:ws-clientgen
  Description: A Maven goal to generate client web service artifacts from a
    WSDL Note the differences between clientgen Ant task and Maven goal:
    clientgen goal only generates JAXWS web service artifacts, while Ant task
    has JAXRPC as the default. At the moment there is no way to direct
    clientgen goal to also compile and package generated artifacts.
  Deprecated. No reason given

weblogic:ws-jwsc
  Description: This goal builds a JAX-WS web service, generates source code,
    data binding artifacts, deployment descriptors, and so on into an output
    directory.
  Deprecated. No reason given

weblogic:ws-wsdlc
  Description: This goal generates, from an existing WSDL file, a set of
    artifacts that together provide a partial Java implementation of the Web
    Service described by the WSDL file.
  Deprecated. No reason given

weblogic:wsgen
  Description: Reads a JAX-WS service endpoint implementation class and
    generates all of the portable artifacts for a JAX-WS web service.

weblogic:wsimport
  Description: Parses wsdl and binding files and generates Java code needed
    to access it.

For more information, run 'mvn help:describe [...] -Ddetail'


Configure the properties for the Docker Weblogic domain


Set the weblogic Admin user/password in
./docker-domain/OracleWebLogic/samples/12214-domain-generic/properties/domain_security.properties


Create the domain using ./docker-domain/OracleWebLogic/samples/12214-domain-generic/build.sh

docker build -f Dockerfile -t 12214-weblogic-domain-generic .


This creates Docker image

[dave@localhost weblogic]$ docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED             SIZE
12214-weblogic-domain-generic   latest              0c7c40704362        43 minutes ago      1.26GB


Change the domain Docker image name in run_admin_server.sh script
./docker-domain/OracleWebLogic/samples/12214-domain-generic/run_admin_server.sh

[dave@localhost weblogic]$ grep 12214-weblogic-domain-generic ./docker-domain/OracleWebLogic/samples/12214-domain-generic/run_admin_server.sh
echo "docker run -d -p 9001:7001 -p 9002:9002 --name ${adminhost} --hostname ${adminhost} -v ${scriptDir}/properties:/u01/oracle/properties -v ${domainhostvol}:/u01/oracle/user_projects/domains ${ENV_ARG} 12214-weblogic-domain-generic"
docker run -d -p 9001:7001 -p 9002:9002 --name ${adminhost} --hostname ${adminhost} -v ${scriptDir}/properties:/u01/oracle/properties -v ${domainhostvol}:/u01/oracle/user_projects/domains ${ENV_ARG} 12214-weblogic-domain-generic



List of required images
[dave@localhost 12214-domain-generic]$ docker images
REPOSITORY                      TAG                 IMAGE ID            CREATED              SIZE
12214-weblogic-domain-generic   latest              93dc22395c42        14 seconds ago       1.26GB
oracle/weblogic                 12.2.1.4-generic    b67e91a22473        46 seconds ago       1.26GB
<none>                          <none>              ba227fc7cf16        About a minute ago   2.99GB
oracle/serverjre                8                   639ea570f133        4 hours ago          356MB
oraclelinux                     7-slim              874477adb545        2 months ago         118MB


Create directory on localhost where the Docker domain volume will be mapped - in our test /app/domains/

Run the domain


[dave@localhost 12213-domain]$ ./run_admin_server.sh 
Context for docker build is /git/docker-images/OracleWebLogic/samples/12213-domain
Export environment variables from the /git/docker-images/OracleWebLogic/samples/12213-domain/properties/domain.properties properties file
 env_arg: CUSTOM_DOMAIN_NAME=daveDomain
 env_arg: CUSTOM_ADMIN_NAME=admin
 env_arg: CUSTOM_ADMIN_PORT=7001
 env_arg: CUSTOM_ADMIN_HOST=AdminContainer
 env_arg: CUSTOM_MANAGED_SERVER_PORT=8001
 env_arg: CUSTOM_MANAGED_SERVER_NAME_BASE=MS
 env_arg: CUSTOM_CONFIGURED_MANAGED_SERVER_COUNT=2
 env_arg: CUSTOM_CLUSTER_NAME=clusterdave
 env_arg: CUSTOM_CLUSTER_TYPE=DYNAMIC
 env_arg: CUSTOM_PRODUCTION_MODE_ENABLED=true
 env_arg: CUSTOM_DOMAIN_HOST_VOLUME=/app/domains/
The domain configuration will get persisted in the host volume: /app/domains/
docker run -d -p 9001:7001 -p 9002:9002 --name AdminContainer --hostname AdminContainer -v /git/docker-images/OracleWebLogic/samples/12213-domain/properties:/u01/oracle/properties -v /app/domains/:/u01/oracle/user_projects/domains  -e CUSTOM_DOMAIN_NAME=daveDomain -e CUSTOM_ADMIN_NAME=admin -e CUSTOM_ADMIN_PORT=7001 -e CUSTOM_ADMIN_HOST=AdminContainer -e CUSTOM_ADMIN_HOST=AdminContainer -e CUSTOM_MANAGED_SERVER_PORT=8001 -e CUSTOM_MANAGED_SERVER_NAME_BASE=MS -e CUSTOM_CONFIGURED_MANAGED_SERVER_COUNT=2 -e CUSTOM_CLUSTER_NAME=clusterdave -e CUSTOM_CLUSTER_TYPE=DYNAMIC -e CUSTOM_PRODUCTION_MODE_ENABLED=true 12214-weblogic-domain-slim
42999c43bffe7bd381031c07567d4aa9893a23247190cbdb18659cae9c228b33
[dave@localhost 12213-domain]$ docker ps
CONTAINER ID        IMAGE                        COMMAND                  CREATED             STATUS              PORTS                                            NAMES
42999c43bffe        12214-weblogic-domain-slim   "/u01/oracle/contain…"   5 seconds ago       Up 3 seconds        0.0.0.0:9002->9002/tcp, 0.0.0.0:9001->7001/tcp   AdminContainer
[dave@localhost 12213-domain]$ pgrep -a java
7367 /usr/java/jdk-8/bin/java -server -Djava.security.egd=file:/dev/./urandom -cp /u01/oracle/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=admin -Djava.security.policy=/u01/oracle/wlserver/server/lib/weblogic.policy -Doracle.jdbc.fanEnabled=false -Dweblogic.StdoutDebugEnabled=false -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -javaagent:/u01/oracle/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/u01/oracle/wlserver/server -Dweblogic.home=/u01/oracle/wlserver/server weblogic.Server
[dave@localhost 12213-domain]$ ls /app/domains/
daveDomain


Deploy the application code using Maven


Set the latest version of weblogic-maven-plugin

 <plugin>
        <groupId>com.oracle.weblogic</groupId>
        <artifactId>weblogic-maven-plugin</artifactId>
        <version>12.2.1-4-0</version>


Maven plugin goals

 https://docs.oracle.com/en/middleware/fusion-middleware/weblogic-server/12.2.1.4/wlprg/maven.html#GUID-CE12CFF4-EB0C-4E92-A13A-676AAD854663

SSH into container to check upload
docker exec -it  2f1af983d72d /bin/bash


Configure upload in Maven weblogic plugin

WAR is uploaded into Docker domain
[oracle@AdminContainer /]$ find . -name "rs-api.war" 2>/dev/null
./u01/oracle/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/rs-api/m49v6j/META-INF/.WL_internal/cache/rs-api.war
./u01/oracle/user_projects/domains/daveDomain/servers/admin/upload/rs-api/app/rs-api.war
./u01/oracle/user_projects/domains/daveDomain/servers/admin/tmp/.appmergegen_1572188440153_rs-api.war/META-INF/.WL_internal/cache/rs-api.war
./u01/oracle/user_projects/domains/daveDomain/servers/admin/tmp/.appmergegen_1572188440153/rs-api.war
./u01/oracle/user_projects/domains/daveDomain/servers/admin/tmp/_WL_user/rs-api/w7yf0e/META-INF/.WL_internal/cache/rs-api.war



Without upload you get following error
ERROR] Failed to execute goal com.oracle.weblogic:weblogic-maven-plugin:12.2.1-4-0:deploy (default) on project rs-api: weblogic.management.ManagementException: [Deployer:149003]Unable to access application source information in "/app/domains/apps/rs-api.war" for application "rs-api". The specific error is: No application files exist.
[ERROR]     at weblogic.deploy.internal.adminserver.operations.OperationHelper.validateSource(OperationHelper.java:358)
[ERROR]     at weblogic.deploy.internal.adminserver.operations.OperationHelper.getArchiveVersionIdFromSource(OperationHelper.java:168)
[ERROR]     at weblogic.deploy.internal.adminserver.operations.OperationHelper.getAndValidateVersionIdWithSrc(OperationHelper.java:206)


in case of unreachable admin you can try to add JAVA Option with the flag “-Dweblogic.rjvm.enableprotocolswitch=true
See also https://github.com/oracle/docker-images/issues/575


<plugin>
        <groupId>com.oracle.weblogic</groupId> 
        <artifactId>weblogic-maven-plugin</artifactId> 
        <version>12.2.1-4-0</version> 
        <!--
        You can find and redefine the following variables in the parent pom file arccording to your environment.
  
        oracleMiddlewareHome
        oracleServerUrl
        oracleUsername
        oraclePassword
        oracleServerName
        -->
        <configuration> 
          <middlewareHome>${oracleMiddlewareHome}</middlewareHome>
        </configuration> 
        <executions>
          <!--Deploy the application to the server-->
          <execution>
            <phase>pre-integration-test</phase> 
            <goals> 
              <goal>deploy</goal> 
            </goals>
            <configuration> 
              <!--The admin URL where the app is deployed. Here use the plugin's default value t3://localhost:7001-->
              <adminurl>${oracleServerUrl}</adminurl>
              <user>${oracleUsername}</user> 
              <password>${oraclePassword}</password>
              <!--The location of the file or directory to be deployed-->
              <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
              <!--The target servers where the application is deployed. Here use the plugin's default value AdminServer-->
              <!--targets>${oracleServerName}</targets-->
              <verbose>true</verbose> 
              <!--The deployment name of the application-->
              <name>${project.build.finalName}</name>
              <upload>true</upload>
            </configuration> 
          </execution> 
        </executions>
      </plugin>


 

Deploy the app into Docker Weblogic domain

Sample application code is here https://github.com/dveselka/weblogic/tree/master/rs-api

dave@localhost rs-api]$ mvn clean package pre-integration-test
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< com.dave:rs-api >---------------------------
[INFO] Building rs-api 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ rs-api ---
[INFO] Deleting /git/weblogic/rs-api/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rs-api ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /git/weblogic/rs-api/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ rs-api ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 4 source files to /git/weblogic/rs-api/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rs-api ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /git/weblogic/rs-api/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ rs-api ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rs-api ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ rs-api ---
[INFO] Packaging webapp
[INFO] Assembling webapp [rs-api] in [/git/weblogic/rs-api/target/rs-api]
[INFO] Processing war project
[INFO] Copying webapp resources [/git/weblogic/rs-api/src/main/webapp]
[INFO] Webapp assembled in [15 msecs]
[INFO] Building war: /git/weblogic/rs-api/target/rs-api.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rs-api ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /git/weblogic/rs-api/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ rs-api ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 4 source files to /git/weblogic/rs-api/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rs-api ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /git/weblogic/rs-api/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ rs-api ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rs-api ---
[INFO] No tests to run.
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] 
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ rs-api ---
[INFO] Packaging webapp
[INFO] Assembling webapp [rs-api] in [/git/weblogic/rs-api/target/rs-api]
[INFO] Processing war project
[INFO] Copying webapp resources [/git/weblogic/rs-api/src/main/webapp]
[INFO] Webapp assembled in [2 msecs]
[INFO] Building war: /git/weblogic/rs-api/target/rs-api.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] 
[INFO] --- weblogic-maven-plugin:12.2.1-4-0:deploy (default) @ rs-api ---
[INFO] Command flags are: -noexit -deploy -username myusername -password ******* -name rs-api -source /git/weblogic/rs-api/target/rs-api.war -upload -verbose -adminurl t3://localhost:9001
weblogic.Deployer invoked with options:  -noexit -deploy -username myusername -name rs-api -source /git/weblogic/rs-api/target/rs-api.war -upload -verbose -adminurl t3://localhost:9001
<Oct 27, 2019 2:12:33 PM CET> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating deploy operation for application, rs-api [archive: /git/weblogic/rs-api/target/rs-api.war], to configured targets.> 
Task 5 initiated: [Deployer:149026]deploy application rs-api on admin.
Task 5 completed: [Deployer:149026]deploy application rs-api on admin.
Target state: deploy completed on Server admin

Target Assignments:
+ rs-api  admin
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.768 s
[INFO] Finished at: 2019-10-27T14:12:34+01:00
[INFO] ------------------------------------------------------------------------

Check the running domain

[dave@localhost rs-api]$ docker ps
CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                                            NAMES
2f1af983d72d        12214-weblogic-domain-generic   "/u01/oracle/contain…"   22 minutes ago      Up 22 minutes       0.0.0.0:9002->9002/tcp, 0.0.0.0:9001->7001/tcp   AdminContainer
[dave@localhost rs-api]$ pgrep -a java
25383 /usr/java/jdk-8/bin/java -Djava.security.manager -Djava.security.policy=/u01/oracle/wlserver/common/derby/derbyServer.policy -Dderby.system.home=/u01/oracle/user_projects/domains/daveDomain/common/db -classpath /u01/oracle/wlserver/common/derby/lib/derby.jar:/u01/oracle/wlserver/common/derby/lib/derbynet.jar:/u01/oracle/wlserver/common/derby/lib/derbytools.jar:/u01/oracle/wlserver/common/derby/lib/derbyoptionaltools.jar:/u01/oracle/wlserver/common/derby/lib/derbyclient.jar org.apache.derby.drda.NetworkServerControl start
25384 /usr/java/jdk-8/bin/java -server -Djava.security.egd=file:/dev/./urandom -cp /u01/oracle/wlserver/server/lib/weblogic-launcher.jar -Dlaunch.use.env.classpath=true -Dweblogic.Name=admin -Djava.security.policy=/u01/oracle/wlserver/server/lib/weblogic.policy -Doracle.jdbc.fanEnabled=false -Dweblogic.StdoutDebugEnabled=false -Dweblogic.rjvm.enableprotocolswitch=true -Djava.system.class.loader=com.oracle.classloader.weblogic.LaunchClassLoader -javaagent:/u01/oracle/wlserver/server/lib/debugpatch-agent.jar -da -Dwls.home=/u01/oracle/wlserver/server -Dweblogic.home=/u01/oracle/wlserver/server weblogic.Server

Test the app


[dave@localhost rs-api]$ curl http://localhost:9001/rs-api/resources/persons
[{"age":50,"name":"dave"},{"age":30,"name":"abc"}