Class KubernetesClusterService

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.cluster.CamelClusterService, org.apache.camel.cluster.CamelPreemptiveClusterService, org.apache.camel.Ordered, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasId, org.apache.camel.spi.IdAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    @DeferredContextBinding
    public class KubernetesClusterService
    extends org.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>
    implements org.apache.camel.cluster.CamelPreemptiveClusterService
    A Kubernetes based cluster service leveraging Kubernetes optimistic locks on resources (specifically ConfigMaps).
    • Constructor Detail

      • KubernetesClusterService

        public KubernetesClusterService()
      • KubernetesClusterService

        public KubernetesClusterService​(org.apache.camel.CamelContext camelContext,
                                        KubernetesConfiguration configuration)
    • Method Detail

      • getView

        public KubernetesClusterView getView​(String namespace)
                                      throws Exception
        Specified by:
        getView in interface org.apache.camel.cluster.CamelClusterService
        Specified by:
        getView in interface org.apache.camel.cluster.CamelPreemptiveClusterService
        Overrides:
        getView in class org.apache.camel.support.cluster.AbstractCamelClusterService<KubernetesClusterView>
        Throws:
        Exception
      • getMasterUrl

        public String getMasterUrl()
      • setMasterUrl

        public void setMasterUrl​(String masterUrl)
        Set the URL of the Kubernetes master (read from Kubernetes client properties by default).
      • getConnectionTimeoutMillis

        public Integer getConnectionTimeoutMillis()
      • setConnectionTimeoutMillis

        public void setConnectionTimeoutMillis​(Integer connectionTimeout)
        Connection timeout in milliseconds to use when making requests to the Kubernetes API server.
      • getKubernetesNamespace

        public String getKubernetesNamespace()
      • setKubernetesNamespace

        public void setKubernetesNamespace​(String kubernetesNamespace)
        Set the name of the Kubernetes namespace containing the pods and the configmap (autodetected by default)
      • setConfigMapName

        @Deprecated
        public void setConfigMapName​(String kubernetesResourceName)
        Set the name of the ConfigMap used to do optimistic locking (defaults to 'leaders').
        Parameters:
        kubernetesResourceName - the resource name
      • setLeaseResourceType

        public void setLeaseResourceType​(LeaseResourceType type)
        Set the lease resource type used in Kubernetes (defaults to 'Lease', from coordination.k8s.io).
      • getKubernetesResourceName

        public String getKubernetesResourceName()
      • setKubernetesResourceName

        public void setKubernetesResourceName​(String kubernetesResourceName)
        Set the name of the lease resource used to do optimistic locking (defaults to 'leaders'). Resource name is used as prefix when the underlying Kubernetes resource can mange a single lock.
      • getPodName

        public String getPodName()
      • setPodName

        public void setPodName​(String podName)
        Set the name of the current pod (autodetected from container host name by default).
      • setClusterLabels

        public void setClusterLabels​(Map<String,​String> clusterLabels)
        Set the labels used to identify the pods composing the cluster.
      • addToClusterLabels

        public void addToClusterLabels​(String key,
                                       String value)
      • getJitterFactor

        public double getJitterFactor()
      • setJitterFactor

        public void setJitterFactor​(double jitterFactor)
        A jitter factor to apply in order to prevent all pods to call Kubernetes APIs in the same instant.
      • getLeaseDurationMillis

        public long getLeaseDurationMillis()
      • setLeaseDurationMillis

        public void setLeaseDurationMillis​(long leaseDurationMillis)
        The default duration of the lease for the current leader.
      • getRenewDeadlineMillis

        public long getRenewDeadlineMillis()
      • setRenewDeadlineMillis

        public void setRenewDeadlineMillis​(long renewDeadlineMillis)
        The deadline after which the leader must stop its services because it may have lost the leadership.
      • getRetryPeriodMillis

        public long getRetryPeriodMillis()
      • setRetryPeriodMillis

        public void setRetryPeriodMillis​(long retryPeriodMillis)
        The time between two subsequent attempts to check and acquire the leadership. It is randomized using the jitter factor.