Skip to content

Toro Cloud Dev Center


Kubernetes

Martini makes use of the Fabric8io Kubernetes client to connect to a Kubernetes-managed cluster. The table below describes the application properties you can set in Martini to connect to a Kubernetes cluster:

Property Default Description
kubernetes.config-location The location of the kubeconfig file to use. If set to default, it will look for the kubeconfig file at $HOME/.kube/config.
kubernetes.namespace default The namespace of the virtual cluster.
kubernetes.identity random UUID string The name of your Martini instance. When using multiple Martini instances, you must provide a unique name. If left empty, a random UUID string will be assigned to the instance.
kubernetes.lease-duration 15s The amount of time non-leader candidates will wait after observing a leadership renewal until attempting to acquire leadership of a led but unrenewed leader slot. This is effectively the maximum duration that a leader can be stopped before it is replaced by another candidate.
kubernetes.renew-deadline 10s The interval between attempts by the acting master to renew a leadership slot before it stops leading. This must be less than or equal to the lease duration.
kubernetes.retry-period 2s The duration the clients should wait between attempting acquisition and renewal of a leadership. This is only applicable if leader election is enabled.
kubernetes.localized-cluster false A flag that can be set to true to make the Martini instance aware it is deployed inside a Kubernetes cluster.
kubernetes.selectors.<label> This property is used when kubernetes.localized-cluster is set to true. This configures a label selector attached to the Martini service that will be registered in the Kubernetes cluster. It will be used to specify which pod the registered Kubernetes service belongs to. You can specify multiple selectors. You can specify a label through the following format: kubernetes.selectors.<label>.
kubernetes.master-url The URL of the Kubernetes cluster. If kubernetes.config-location is not set, this will be used instead.

Enabling Kubernetes in Martini

The bare minimum required to have Martini work with Kubernetes is to configure either the kubernetes.config-location or the kubernetes.master-url property. If neither are configured, Martini will not use any Kubernetes-specific functionality.

If the Martini instance is deployed inside a Kubernetes cluster, it is recommended to set the kubernetes.localized-cluster to true for better performance. When deploying a Martini instance, ensure pod labels match the kubernetes.selectors.<label> values specified via application properties.

When a Martini instance is connected to Kubernetes and has gained leadership, the instance will log the following (if logging is enabled):

1
INFO  [KubernetesLeadershipElector] Leadership granted. Attempting to start endpoints