11/12 free views
Script
Script
Cloud Security

k8s-wait-for

by groundnuty

611stars
131forks
14watchers
Updated 10 months ago
About

A simple script that waits for Kubernetes services, jobs, or pods to reach a desired state to facilitate deployment and automation workflows.

A simple script that allows to wait for a k8s service, job or pods to enter a desired state

Primary Use Case

This tool is primarily used by Kubernetes administrators and DevOps engineers to automate and streamline deployment processes by waiting for specific Kubernetes resources to become ready or complete. It helps ensure that dependent services or jobs have reached their expected states before proceeding with further automation or deployment steps.

Key Features
  • Waits for Kubernetes jobs, pods, or services to enter desired states such as Ready, Succeeded, or Failed
  • Supports label selectors for targeting multiple resources
  • Provides variants to wait for all or at least one resource to reach the desired state
  • Compatible with Kubernetes versions <=1.23 using specific versions
  • Available as a container image for easy execution within clusters
  • Includes built-in help and usage examples
  • Integrates with Kubernetes CLI (kubectl) for seamless operation

Installation

  • Run the tool directly on a Kubernetes cluster using kubectl with the provided container image:
  • kubectl run k8s-wait-for --rm -it --image ghcr.io/groundnuty/k8s-wait-for:v2.0 --restart Never --command /bin/sh
  • Use the built-in help command to explore usage options:
  • / > wait_for.sh -h

Usage

>_ wait_for.sh job [<job name> | -l<kubectl selector>]

Waits for all pods in the specified job to reach the 'Succeeded' state.

>_ wait_for.sh pod [<pod name> | -l<kubectl selector>]

Waits for all pods matching the name or label selector to enter the 'Ready' state.

>_ wait_for.sh service [<service name> | -l<kubectl selector>]

Waits for the specified Kubernetes service to become ready.

>_ wait_for.sh pod -lapp=develop-volume-gluster-krakow

Waits for all pods with the label 'app=develop-volume-gluster-krakow' to enter the 'Ready' state.

>_ wait_for.sh pod -l"release in (develop), chart notin (cross-support-job-3p)"

Waits for all pods matching a complex label selector to enter the 'Ready' state.

>_ wait_for.sh pod-we -lapp=develop-volume-gluster-krakow

Waits for all pods with the label 'app=develop-volume-gluster-krakow' to enter either 'Ready' or 'Error' state.

>_ wait_for.sh pod-wr -lapp=develop-volume-gluster-krakow

Waits for at least one pod with the label 'app=develop-volume-gluster-krakow' to enter the 'Ready' state, ignoring others in 'Error' state.

>_ wait_for.sh job-we develop-volume-s3-krakow-init

Waits for all pods in the specified job to reach either 'Succeeded' or 'Failed' state.

>_ wait_for.sh job-wr develop-volume-s3-krakow-init

Waits for at least one pod in the specified job to reach 'Succeeded' state, ignoring some 'Failed' pods.

Security Frameworks
TA0007
TA0005
TA0040
Usage Insights
  • Integrate this script into CI/CD pipelines to automate deployment gating based on Kubernetes resource readiness, reducing deployment errors.
  • Use in blue team playbooks to automate detection of abnormal pod or job states that may indicate compromise or misconfiguration.
  • Combine with Kubernetes audit logs and monitoring tools to enhance situational awareness of cluster state changes.
  • Leverage the containerized version to run within Kubernetes clusters for seamless integration with existing automation workflows.
  • Extend the script to trigger automated remediation or alerting when resources fail to reach desired states within expected timeframes.

Docs Take 2 Hours. AI Takes 10 Seconds.

Ask anything about k8s-wait-for. Installation? Config? Troubleshooting? Get answers trained on real docs and GitHub issues—not generic ChatGPT fluff.

This tool hasn't been indexed yet. Request indexing to enable AI chat.

Admin will review your request within 24 hours

Security Profile
Red Team30%
Blue Team70%
Purple Team60%
Details
LicenseMIT License
LanguageShell
Open Issues40
Topics
helm
kubernetes
dependencies
synchronization
init-containers
chart