protected int getReplicaCount ( KubernetesListBuilder builder , ResourceConfig xmlResourceConfig , int defaultValue ) { if ( xmlResourceConfig != null ) { List < HasMetadata > items = builder . buildItems ( ) ; for ( HasMetadata item : items ) { if ( item instanceof Deployment ) { if ( ( ( Deployment ) item ) . getSpec ( ) . getReplicas ( ) != null ) { return ( ( Deployment ) item ) . getSpec ( ) . getReplicas ( ) ; } } if ( item instanceof DeploymentConfig ) { if ( ( ( DeploymentConfig ) item ) . getSpec ( ) . getReplicas ( ) != null ) { return ( ( DeploymentConfig ) item ) . getSpec ( ) . getReplicas ( ) ; } } } return xmlResourceConfig . getReplicas ( ) > 0 ? xmlResourceConfig . getReplicas ( ) : defaultValue ; } return defaultValue ; }
This method just makes sure that the replica count provided in XML config overrides the default option ; and resource fragments are always given topmost priority .