A Quick Introduction to KubeAssert

What is KubeAssert

  • If a resource should or should not exist in the cluster;
  • If the status of a resource should or should not include an expected value;
  • if the instance number of a resource should be less than or no more than an expected value;

Install KubeAssert

krew install assert
curl -L https://raw.githubusercontent.com/morningspace/kubeassert/master/kubectl-assert.sh -o kubectl-assert
chmod +x kubectl-assert
mv ./kubectl-assert /usr/local/bin
kubectl assert
kubectl assert exist --help

Using KubeAssert

  • exist: Assert resource should exist.
  • not-exist: Assert resource should not exist.
  • exist-enhanced: Assert resource should exist using enhanced field selector.
  • not-exist-enhanced: Assert resource should not exist using enhanced field selector.
  • num: Assert the number of resource should match specified criteria.
  • pod-ready: Assert pod should be ready.
  • pod-not-terminating: Assert pod should not keep terminating.
  • pod-restarts: Assert pod restarts should match specified criteria.
  • apiservice-available: Assert API service should be available.
kubectl assert exist pods -l app=echo -n foo
kubectl assert pod-ready --all-namespaces
kubectl assert restarts pods -n foo -lt 10

Summary

--

--

--

Life is coding and writing! I am a software engineer who have been in IT field for 10+ years. I would love to write beautiful code and story for people.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Basic Linux Commands that You Should Know

The Agile Manifesto: what it means for our customers

Run your Android Automation tests over Wi-Fi

Why did I choose Rocket to type emojis quickly without selecting from the character viewer?

A Quick Beginners Guide to CSS

How to strip html tags from a string in Python

remove_tags

Are you a Developer? Want to get a Software Job in the UK?

StarryNift 200 NFT Airdrop Winner Announcement

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
MorningSpace

MorningSpace

Life is coding and writing! I am a software engineer who have been in IT field for 10+ years. I would love to write beautiful code and story for people.

More from Medium

Safely handle secrets on your GitOps flow using ArgoCD and Helm

Deep Dive Into Kubernetes: Way to know about Kubernetes

Announcing Our $25 Million Series A from Coatue to Grow Developer-Centric Community Around…

Allowlist Your IP Address to Security Connect to an OCI Compute Instance