Public Repository

Last pushed: 8 months ago
Short Description
Node script that gets the URI of a Kubernetes service and writes it to a file
Full Description

Kubernetes Get Service URI

Node script that gets the URI of a Kubernetes service and writes it to a file. Supports only services of type "LoadBalancer" or "NodePort"

Environment Variables

Key Description Default Value
FILE_NAME File name of the file to where the URI is written 'service-uri.txt'
INITIAL_DELAY Time in seconds to wait before polling starts 0
ITERATION_DELAY Time in seconds to wait between each poll 3
KUBE_CONFIG_DIR Directory that contains the kubeconfig file '/.kube'
KUBE_CONFIG_NAME File name of the kubeconfig file 'config'
KUBE_MASTER_ENDPOINT URL of the K8s API server Attempts to read the kubeconfig
KUBE_API_VERSION K8s API version to use '/api/v1'
NAMESPACE Namespace to use for K8s API 'default'
PASSWORD HTTP basic auth password used to authenticate to the K8s API Attempts to read the kubeconfig file
PORT_NAME If the service has multiple ports, the name of the port to use in the URI. No need to specify if only one port. First port on the service
SERVICE_NAME Name of K8s service to check null
STRICT_SSL If set to true, the client tries to validate the SSL certificate of the K8s API server false
TIMEOUT Total time in seconds to poll before exiting the process with an error (Does not include INITIAL_DELAY) 90
TOKEN API bearer token used to authenticate to the K8s API Attempts to read the kubeconfig file
USERNAME HTTP basic auth username used to authenticate to the K8s API Attempts to read the kubeconfig file

Authentication

Authentication credentials are chosen in a cascading manner using the following order (highest to lowest priority):

TOKEN EnvVar > USERNAME/PASSWORD EnvVars > kubeconfig token > kubeconfig username/password > kubeconfig inline certificates (client-certificate-data key) > kubeconfig external certificates (client-certificate key)

Example Usage

docker run -it --rm -e "NAMESPACE=customer" -e "SERVICE_NAME=profilesvc-app-service" -e "INITIAL_DELAY=5" -e "USERNAME=user1" -e "PASSWORD=supersecretpw" -e "PORT_NAME=https-port" -v $(pwd):/usr/src/app/output lifeway/kube-get-svc-uri
Docker Pull Command
Owner
lifeway

Comments (0)