Add the following code to your project's shard.yml under:
to use in production
- OR -
development_dependencies to use in development
This library contains generated classes for Kubernetes resources for various Kubernetes API versions, as well as a
Hashdiff module for comparing hashes of Kubernetes resources.
Add this to your application's
dependencies: k8s: github: spoved/k8s.cr
View the Documentation for the version you are using:
K8S.cr should support Kubernetes API from 1.11.0 and beyond. In order to use the bindings, you will want to include the VERSION that best maps to your k8s api version. Requiring more than one version at this time will result in an error.
Some examples on the easier methods to grab/set variables:
# Access a nested path resource.spec![:template, :metadata, :labels, :app] # Set a nested path resource.spec![:template, :metadata, :labels, :app] = "myapp" # Can use symbols or strings resource.spec![:template] resource.spec!["template"]
To generate resources for a CRD, you can use the crd_gen.cr file.
# First dump the CRDs to a file kubectl get crds -o yaml > crds.yaml # Then generate the resources ./lib/k8s/bin/gen_crd.cr -- ./crds.yaml <output directory>