Installing Martini Server Runtime on Kubernetes
Martini Runtime leverages the Fabric8.io Kubernetes client to establish connections with Kubernetes-managed clusters, enabling seamless interaction and management of resources within the cluster. This integration allows developers to easily deploy and manage microservices, utilize Kubernetes features like service discovery and scaling, and automate CI/CD processes, all while enhancing the overall developer experience.
Prerequisites
You can either set up an on-premises Kubernetes cluster or use a cloud-hosted service.
On-Premise Kubernetes Distributions
- Official Kubernetes: The standard upstream version of Kubernetes, maintained by the Kubernetes community.
- Openshift: A distribution of Kubernetes by Red Hat, designed for enterprise use with a focus on developer experience and security.
- Rancher: A complete container management platform that includes a Kubernetes distribution called RKE (Rancher Kubernetes Engine).
- MicroK8s: A minimal, lightweight Kubernetes distribution developed by Canonical, the company behind Ubuntu.
- K3s: A lightweight Kubernetes distribution designed for resource-constrained environments, such as edge computing and IoT.
Cloud-Hosted Kubernetes Services
- Google Kubernetes Engine (GKE): A fully managed Kubernetes service that automates cluster management tasks such as upgrades, scaling, and monitoring.
- Amazon Elastic Kubernetes Service (EKS): A managed service that makes it easy to run Kubernetes on AWS without needing to install and operate your own control plane.
- Azure Kubernetes Service (AKS): A managed Kubernetes service that simplifies the deployment and management of Kubernetes clusters on Azure.
Martini Configuration
-
Configure Martini's connection properties in the
<martini-home>/conf/overrides/override.properties
. There are two ways to configure Martini. These properties represent the bare minimum requirements needed to get started with the application. Using kubeconfig:1 2 3
# The file path of the kube config. # By using "default" it uses the kube config from ~/.kube/config kubernetes.config-location=default
Using URL:
1 2
# The URL of your kubernetes node kubernetes.master-url=https://[HOST]:6443
For authentication in the Martini Server Runtime, you can choose from three methods: bearer token, client certificate, or basic authentication. These configurations are relevant when using the
kubernetes.master-url=
property to connect to your Kubernetes cluster.1 2
# Bearer Token kubernetes.bearer-token=
1 2 3 4
# Client Certificate kubernetes.client-certificate= kubernetes.client-key= kubernetes.trust-certificate=
1 2 3
# Basic auth kubernetes.username= kubernetes.password=
-
Restart Martini Server Runtime to apply the changes.
-
Verify by checking your leases on your Kubernetes cluster. You should see
martini-runtime-endpoint
.
Leadership Election
Martini Server Runtime facilitates leadership election by enabling multiple instances to collaborate effectively. To implement this, you need to set up two or more Martini Server Runtime instances either inside or connected to different nodes on Kubernetes, ensuring that each instance has a unique identity. By default, the system assigns a random UUID string to each instance. However, you can customize this by assigning a specific identity name, which will replace the automatically generated UUID. To do this, set the following property in your configuration:
1 2 3 |
|
By defining a unique identity, such as toroMartini-1
, you enhance the reliability of the leadership election process, allowing the Martini Server Runtime to maintain consistent coordination and task management across your distributed environment. This ensures that each instance can participate in the election process without confusion, contributing to the overall stability and efficiency of your system.
To verify if the leadership election is functioning correctly, you can shut down the Martini instance that holds the Kubernetes lease. Upon shutting down this instance, you should observe that the other Martini instance seamlessly takes over the leadership role. This transition will be indicated by a log message similar to the following:
1 |
|
This message confirms that the newly elected instance has successfully assumed leadership, ensuring continued operation and coordination within your distributed environment. By performing this test, you can validate the resilience and effectiveness of the leadership election mechanism within the Martini Server Runtime setup.
Advanced properties
These properties are advanced settings for configuring Martini Runtime. Adjust them according to the needs of your applications. This can be set in the <martini-home>/conf/overrides/override.properties
.
1 2 3 4 |
|
1 2 3 |
|
1 2 3 4 |
|
1 2 3 |
|
1 2 3 |
|
1 2 3 4 5 |
|