Thursday, October 17, 2019

Mocking rest services with Mockito and MockRestServiceServer in Spring

the code in the article is broken, here you find a fixed version.

It's very simple and elegant solution.

You see @InjectMocks and @Mock annotations in action. Here they are explained

Here the javadoc of

Tuesday, October 15, 2019

kubernetes "change-cause" to describe a deployment

$ kubectl run nginx --image=nginx --replicas=4

$ kubectl annotate deployment/nginx'initial deployment'
deployment.extensions/nginx annotated

$ kubectl set image deploy nginx nginx=nginx:1.7.9

$ kubectl annotate deployment/nginx'nginx:1.7.9'
deployment.extensions/nginx annotated

$ kubectl set image deploy nginx nginx=nginx:1.9.1

$ kubectl annotate deployment/nginx'nginx:1.9.1'
deployment.extensions/nginx annotated

$ kubectl rollout history deploy nginx

5 initial deployment
6 nginx:1.7.9
7 nginx:1.9.1

This seems to me a very good practice, to be able to trace all changes in PROD.

You can always trace what changed:

kubectl rollout history deploy nginx --revision=6

deployment.extensions/nginx with revision #6
Pod Template:
  Labels:       pod-template-hash=7b74859c78
    Image:      nginx:1.7.9
    Host Port:  

joy of Openshift SCC

if you do

oc describe project

you will see 2 annotations

Even if you specify a "USER 10001" in your Dockerfile, your actual uid will be remapped withing the range specified by those 2 annotations (the second parameter "/10000" is the block length! meaning that you can have 10000 different users starting from uid 1000800000 ) :

sh-4.2$ id
uid=1000800000(root) gid=0(root) groups=0(root),1000800000
sh-4.2$ id root
uid=0(root) gid=0(root) groups=0(root)

and in order for this new user to be a first class citizen in your Linux, you must run a uid_entrypoint script to append it to /etc/passwd

for more details:

Monday, October 7, 2019

kubernetes mount file on an existing folder

With ConfigMap and Secret you can "populate" a volume with files and "mount" that volume to a container, so that the application can access those files.

echo "one=1" >
echo "two=2" >
kubectl create configmap myconfig --from-file --from-file
kubectl describe configmaps myconfig

Name:         myconfig
Namespace:    default



Now I can mount the ConfigMap into a Pod, as described here

cat mypod.yml

apiVersion: v1
kind: Pod
  name: configmap-pod
    - name: test
      image: nginx
        - name: config-vol
          mountPath: /etc/config
    - name: config-vol
        name: myconfig
          - key:

kubectl create -f mypod.yml

kubectl exec -ti configmap-pod bash

cat /etc/config/

Now I change the image to vernetto/mynginx, which contains already a /etc/config/
The existing folder /etc/config/ is completely replaced by the volumeMount, so disappears!
Only /etc/config/ is there.

They claim that one can selectively mount only one file from the volume, and leave the original files in the base image: using subPath, but it is definitely not working for me.

Friday, October 4, 2019

Cisco CCNA 200-125


install 2.0.3 !

you can download IOS image here (download 7200 and 3745 )

in GNS3, go to Edit/Preferences/Dynamips/IOS routers/

also, GNS3 is a spiteful beast, I managed to make it work only by copying the "bin" files to C:\Users\Pierre-Luigi\GNS3\images\IOS and by running gns3server.exe in a cmd dos prompt. What a piece of crap!
Otherwise it will tell you

"Could not create IOS router: Error while setting up node: S:/pierre/downloads/c7200-advipservicesk9-mz.152-4.S5.bin is not allowed on this remote server. Please use only a filename in C:\Users\Pierre-Luigi\GNS3\images\IOS.
error while deleting : Node ID 4f03d98e-bcca-4623-a2dc-9d5095eefb64 doesn't exist
Could not create IOS router: Node ID 4f03d98e-bcca-4623-a2dc-9d5095eefb64 doesn't exist

GNS3 allows you to construct and test networks in a risk-free virtual environment without the need for network hardware

CISCO packet-tracer "a powerful network simulation software from Cisco Network Academy which can simulate/create a network without having a physical network" (with Netacademy you can take free course on Packet Tracer)
and download Packet Tracer here

Local Area Network
Wide Area Network

OSI Model (ISO standard): Application, Presentation, Session, Transport (Port), Network (IP -> ROUTER)), Datalink (MAC -> SWITCH), Physical
please do not throw sausage pizza away

TCP-IP stack: Application, Transport. Internet, Network access

PDU (protocol data unit): data, segment, packet, frame

Network Calculator EIGRP