Add grain for current kubernetes_version
Change-Id: I7612d9c158f12f43ff62d9c6132d74466fac37a3
diff --git a/_grains/kubernetes.py b/_grains/kubernetes.py
new file mode 100644
index 0000000..4118b39
--- /dev/null
+++ b/_grains/kubernetes.py
@@ -0,0 +1,15 @@
+import salt.modules.cmdmod
+import re
+from salt.exceptions import CommandExecutionError
+
+
+def main():
+ grains = {}
+ try:
+ raw_k8s_ver = salt.modules.cmdmod._run_quiet('hyperkube --version')
+ ver = re.search('(v[0-9.-]+)', raw_k8s_ver)
+ if ver:
+ grains['kubernetes_version'] = ver.group(1)
+ except CommandExecutionError:
+ pass
+ return grains