require "kubernetes" require "../../kubernetes_client" module ContainerMom module KubernetesClient @@client : K8sClientWrapper? def self.client # Try to use the shared client from the main operator if available {% if flag?(:standalone) %} # When running in a pod, this will automatically find the right configuration @@client ||= begin if ENV["KUBERNETES_SERVICE_HOST"]? && ENV["KUBERNETES_SERVICE_PORT"]? K8sClientWrapper.new else # Fallback to kubeconfig if not in cluster K8sClientWrapper.new end end {% else %} begin ContainerMom::K8S_CLIENT rescue @@client ||= K8sClientWrapper.new end {% end %} end end end