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

Refactoring is Good. Refactoring Stories are Not

Choose the right Firefox

My Professional life journey

Flipping N-dim Array in Constant Time `O(1)`

Solutions for storing state in a database

High Availability Architecture with AWS CLIv2

Rails Project about a Bank

Run your own public Ethereum testnet

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

Log4Hell — Just the beginning…

No! You shall not pass! Kyverno’s here!

Portability of applications across Kubernetes distributions, part 1

Practical tracing: a final recap