Skip to content

Instantly share code, notes, and snippets.

@polvi
Last active May 22, 2018 03:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save polvi/40424ad5ffe426ba96802cc9df71c355 to your computer and use it in GitHub Desktop.
Save polvi/40424ad5ffe426ba96802cc9df71c355 to your computer and use it in GitHub Desktop.

kQuery

A jQuery like library for manipulating kubernetes objects across various popular kubernetes platforms.

Problems that kQuery addresses:

  • Easy to use client library that is accessible to a wide range of developers (javascript/jQuery)
  • Consistent client library across inconsistent kubernetes implementations (abstracts the differences between EKS/AKS/GKE/Tectonic etc)
  • Simplify building long running custom controllers or operators on k8s

Examples

// jQuery like selector syntax
var pod = $('pod[name=my-pod]');

// supports events
pod.on( 'status-change', function( event ) {
  $('service', {
    name: 'expose-pod',
    label-selector: 'name=my-pod'
  )).create(event.namespace);
});

// supports chaining
$('namespace[name=default]').find('pod').delete();

// is aware of cluster compatibility 
if ( $.kubernetes.tectonic ) {
  console.log('this is CoreOS Tectonic!');
} else if ( $.kubernetes.aks ) {
  console.log('Azure ftw!');
} 
@lpabon
Copy link

lpabon commented Jan 31, 2018

This is a really cool idea. I have seen lots of users, developers, and customers just use kubectl and shell scripts as a poor man's version of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment