-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ksonnet to generate examples #9
Conversation
Here is the process I took to ensure the generated json is equivalent to yaml:
|
I would love input on what to do with the YAML. I'm not convinced deleting it is the best path forward because in my experience people would prefer reading YAML. If they are looking for a way to get started, it would be nice to have the YAML available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small fixes, plus maybe want @hausdorff to review the jsonnet (I'm a little out of my expertise here)
Makefile
Outdated
$(MAKE) -C build/systemd-logs clean | ||
rm -f /examples/quickstart/*.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't want to rm -r /examples
, but ./examples
?
docs/building-examples.md
Outdated
|
||
The JSON files are generated with the `make generate-examples` command. To get this to work you must have ksonnet-lib installed in `/usr/local/lib/jsonnet/ksonnet-lib`. After that, `make generate-examples` will build the JSON files that are checked into this repository. | ||
|
||
0: https://ksonnet.heptio.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTTPS doesn't work on this site, link needs fixing
} | ||
}, | ||
{ | ||
"apiVersion": "rbac.authorization.k8s.io/v1beta1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow option wrap rbac with a default of true but allow for disabled generation per other issue filed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not easy right now, but it's certainly on the roadmap for the CLI.
One way to do it right now is to use ext vars, which are passed in via command line. Your build process would involve interrogating the API server, getting capabilities, and passing a flag --ext-str
with a value to indicate as such.
{ | ||
"apiVersion": "v1", | ||
"data": { | ||
"config.json": "{\"Description\": \"EXAMPLE\", \"Filters\": {\"LabelSelector\": \"\", \"Namespaces\": \".*\"}, \"PluginNamespace\": \"heptio-sonobuoy\", \"Plugins\": [{\"name\": \"systemd_logs\"}, {\"name\": \"e2e\"}], \"Resources\": [\"CertificateSigningRequests\", \"ClusterRoleBindings\", \"ClusterRoles\", \"ComponentStatuses\", \"Nodes\", \"PersistentVolumes\", \"PodSecurityPolicies\", \"ServerVersion\", \"StorageClasses\", \"ThirdPartyResources\", \"ConfigMaps\", \"DaemonSets\", \"Deployments\", \"Endpoints\", \"Events\", \"HorizontalPodAutoscalers\", \"Ingresses\", \"Jobs\", \"LimitRanges\", \"PersistentVolumeClaims\", \"Pods\", \"PodLogs\", \"PodDisruptionBudgets\", \"PodPresets\", \"PodTemplates\", \"ReplicaSets\", \"ReplicationControllers\", \"ResourceQuotas\", \"RoleBindings\", \"Roles\", \"ServiceAccounts\", \"Services\", \"StatefulSets\"], \"ResultsDir\": \"/tmp/sonobuoy\", \"Server\": {\"advertiseaddress\": \"sonobuoy-master:8080\", \"bindaddress\": \"0.0.0.0\", \"bindport\": 8080, \"timeoutseconds\": 3600}, \"Version\": \"v0.8.0\"}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This almost makes it unreadable...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use kubecfg
here, and generate YAML instead of JSON. kubecfg
natively emits multi-line strings all prettified.
} | ||
}, | ||
{ | ||
"apiVersion": "rbac.authorization.k8s.io/v1beta1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not easy right now, but it's certainly on the roadmap for the CLI.
One way to do it right now is to use ext vars, which are passed in via command line. Your build process would involve interrogating the API server, getting capabilities, and passing a flag --ext-str
with a value to indicate as such.
examples/quickstart/00-rbac.jsonnet
Outdated
|
||
}; | ||
|
||
local namespace = local ns = k.core.v1.namespace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super tiny micro nit, when jsonnet fmt
matures, this local will get indented below. AFAIK that's actively being worked on by Dave's intern.
{ | ||
"apiVersion": "v1", | ||
"data": { | ||
"config.json": "{\"Description\": \"EXAMPLE\", \"Filters\": {\"LabelSelector\": \"\", \"Namespaces\": \".*\"}, \"PluginNamespace\": \"heptio-sonobuoy\", \"Plugins\": [{\"name\": \"systemd_logs\"}, {\"name\": \"e2e\"}], \"Resources\": [\"CertificateSigningRequests\", \"ClusterRoleBindings\", \"ClusterRoles\", \"ComponentStatuses\", \"Nodes\", \"PersistentVolumes\", \"PodSecurityPolicies\", \"ServerVersion\", \"StorageClasses\", \"ThirdPartyResources\", \"ConfigMaps\", \"DaemonSets\", \"Deployments\", \"Endpoints\", \"Events\", \"HorizontalPodAutoscalers\", \"Ingresses\", \"Jobs\", \"LimitRanges\", \"PersistentVolumeClaims\", \"Pods\", \"PodLogs\", \"PodDisruptionBudgets\", \"PodPresets\", \"PodTemplates\", \"ReplicaSets\", \"ReplicationControllers\", \"ResourceQuotas\", \"RoleBindings\", \"Roles\", \"ServiceAccounts\", \"Services\", \"StatefulSets\"], \"ResultsDir\": \"/tmp/sonobuoy\", \"Server\": {\"advertiseaddress\": \"sonobuoy-master:8080\", \"bindaddress\": \"0.0.0.0\", \"bindport\": 8080, \"timeoutseconds\": 3600}, \"Version\": \"v0.8.0\"}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use kubecfg
here, and generate YAML instead of JSON. kubecfg
natively emits multi-line strings all prettified.
}; | ||
|
||
local plugins = { | ||
"systemdlogs.yaml": 'name: systemd_logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, it seems to me you could write this as a normal JSON object and then call std.toString(systemdLogs)
on it to get a string? Am I missing something crucial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately the plugin loader only knows how to read YAML.
I'll make an issue and this issue will depend on that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chuckha Is YAML not a superset of JSON, though? So it seems like we should be able to use JSON here and be ok.
If not, kubecfg
allows you to import YAML files, as well manifestYAML
, which pretty-prints an object as YAML.
Or perhaps I am missing something?
k.core.v1.list.new([ | ||
sonobuoyConfig, | ||
pluginConfigs, | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny, tiny microest of nits, you might consider putting newlines at the end so that diffs are cleaner.
So I'm inclined to hold off on this unless it is strictly cleaner and more concise, that is the bar we should be holding here. |
@timothysc Your comment here makes me wonder if there is anything beyond the comments listed you'd like to see changed? Changing to YAML will make it cleaner and more concise, but it's not a change to the Jsonnet code itself, which is where I'd expect the bulk of cleanliness changes to go. |
@hausdorff Right now I think the biggest detractor is the readability. I'd also like to get to the point where we can generate the plugin definitions, and perhaps use that as a mixin to the quickstart .yaml. |
@timothysc Strongly agree about the plugin definitions, which I think are doable with I think my main question, though, is that it's not clear (to me, at least) what else needs to change to meet the readability bar. Just the string pretty printing? |
Eliminate the nested structure string escaping. |
Closes issue #5. - Adds jsonnet to generate the quickstart examples - Removes the YAML - Adds the generated JSON - Docs are updated to reflect JSON files vs YAML - Adds a Makefile target, `generate-examples` Signed-off-by: Chuck Ha <[email protected]>
I believe all issues have been addressed in #52 |
Closes issue #5.
generate-examples
Signed-off-by: Chuck Ha [email protected]