Easiest solution is to work with two container definitions. One with CF_INSTANCE_INDEX=0 and one with CF_INSTANCE_INDEX=1, the latter is the only one you scale… Example k8s implementation: https://github.com/MXClyde/mendix-kubernetes-azure/blob/master/manifests/kubernetes/kubernetes.yaml
Also interested in this! Anyone?
I have this problem too.
The docker-mendix-buildpack source code shows that It will determines the master instance by some environment’s values if you are using k8s. But I can’t figure out how to generate a POD’s name to satisfy the regular expression.
def export_k8s_instance():
logging.debug("Checking Kubernetes environment...")
kubernetes_host = os.environ.get('KUBERNETES_SERVICE_HOST')
if kubernetes_host is not None:
hostname = os.environ.get('HOSTNAME')
instance_match = re.search('(?<=-)[0-9]+$', hostname)
if instance_match is not None:
instance_number = instance_match.group(0)
logging.info("Setting CF_INSTANCE_INDEX to {0} based on hostname {1}"
.format(instance_number, hostname))
os.environ['CF_INSTANCE_INDEX'] = instance_number