-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Examples | ||
|
||
## Quickstart | ||
|
||
The quickstart example is built with [ksonnet][0]. | ||
|
||
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: http://ksonnet.heptio.com |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
{ | ||
"apiVersion": "v1", | ||
"items": [ | ||
{ | ||
"apiVersion": "v1", | ||
"kind": "Namespace", | ||
"metadata": { | ||
"name": "heptio-sonobuoy" | ||
} | ||
}, | ||
{ | ||
"apiVersion": "v1", | ||
"kind": "ServiceAccount", | ||
"metadata": { | ||
"labels": { | ||
"component": "sonobuoy" | ||
}, | ||
"name": "sonobuoy-serviceaccount", | ||
"namespace": "heptio-sonobuoy" | ||
} | ||
}, | ||
{ | ||
"apiVersion": "rbac.authorization.k8s.io/v1beta1", | ||
"kind": "ClusterRoleBinding", | ||
"metadata": { | ||
"labels": { | ||
"component": "sonobuoy" | ||
}, | ||
"name": "sonobuoy-serviceaccount" | ||
}, | ||
"roleRef": { | ||
"apiGroup": "rbac.authorization.k8s.io", | ||
"kind": "ClusterRole", | ||
"name": "sonobuoy-serviceaccount" | ||
}, | ||
"subjects": [ | ||
{ | ||
"kind": "ServiceAccount", | ||
"name": "sonobuoy-serviceaccount", | ||
"namespace": "heptio-sonobuoy" | ||
} | ||
] | ||
}, | ||
{ | ||
"apiVersion": "rbac.authorization.k8s.io/v1beta1", | ||
"kind": "ClusterRole", | ||
"metadata": { | ||
"labels": { | ||
"component": "sonobuoy" | ||
}, | ||
"name": "sonobuoy-serviceaccount", | ||
"namespace": "heptio-sonobuoy" | ||
}, | ||
"rules": [ | ||
{ | ||
"apiGroups": [ | ||
"*" | ||
], | ||
"resources": [ | ||
"*" | ||
], | ||
"verbs": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"kind": "List" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Copyright 2017 Heptio Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
local k = import "ksonnet.beta.2/k.libsonnet"; | ||
|
||
local conf = { | ||
namespace: "heptio-sonobuoy", | ||
labels: { | ||
component: "sonobuoy", | ||
}, | ||
serviceAccount: { | ||
name: "sonobuoy-serviceaccount", | ||
}, | ||
|
||
# shared metadata | ||
metadata: { | ||
name: $.serviceAccount.name, | ||
labels: $.labels, | ||
}, | ||
|
||
}; | ||
|
||
local namespace = | ||
local ns = k.core.v1.namespace; | ||
ns.new() + | ||
ns.mixin.metadata.name(conf.namespace); | ||
|
||
local serviceaccount = | ||
local sa = k.core.v1.serviceAccount; | ||
sa.new() + | ||
sa.mixin.metadata.mixinInstance(conf.metadata) + | ||
sa.mixin.metadata.namespace(conf.namespace); | ||
|
||
local clusterRoleBinding = | ||
local crb = k.rbac.v1beta1.clusterRoleBinding; | ||
crb.new() + | ||
crb.mixin.metadata.mixinInstance(conf.metadata) + | ||
# TODO: replace with `crb.mixinroleRef.kind("ClusterRole") when https://github.com/ksonnet/ksonnet-lib/issues/53 closes. | ||
{roleRef: {kind: "ClusterRole"}} + | ||
crb.mixin.roleRef.apiGroup("rbac.authorization.k8s.io") + | ||
crb.mixin.roleRef.name(conf.serviceAccount.name) + | ||
crb.subjects([ | ||
# TODO: replace with `crb.subjectsType.kind("ServiceAccount")` when https://github.com/ksonnet/ksonnet-lib/issues/43 closes. | ||
{kind: "ServiceAccount"} + | ||
crb.subjectsType.name(conf.serviceAccount.name) + | ||
crb.subjectsType.namespace(conf.namespace), | ||
]); | ||
|
||
local clusterRole = | ||
local cr = k.rbac.v1beta1.clusterRole; | ||
cr.new() + | ||
cr.mixin.metadata.mixinInstance(conf.metadata) + | ||
cr.mixin.metadata.namespace(conf.namespace) + | ||
cr.rules([ | ||
cr.rulesType.apiGroups("*") + | ||
cr.rulesType.resources("*") + | ||
cr.rulesType.verbs("*"), | ||
]); | ||
|
||
k.core.v1.list.new([ | ||
namespace, | ||
serviceaccount, | ||
clusterRoleBinding, | ||
clusterRole,]) |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"apiVersion": "v1", | ||
"items": [ | ||
{ | ||
"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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I would use |
||
}, | ||
"kind": "ConfigMap", | ||
"metadata": { | ||
"labels": { | ||
"component": "sonobuoy" | ||
}, | ||
"name": "sonobuoy-config-cm", | ||
"namespace": "heptio-sonobuoy" | ||
} | ||
}, | ||
{ | ||
"apiVersion": "v1", | ||
"data": { | ||
"e2e.json": "{\"driver\": \"Job\", \"name\": \"e2e\", \"resultType\": \"e2e\", \"spec\": {\"containers\": [{\"env\": [{\"name\": \"E2E_FOCUS\", \"value\": \"Pods should be submitted and removed\"}], \"image\": \"gcr.io/heptio-images/kube-conformance:latest\", \"imagePullPolicy\": \"Always\", \"name\": \"e2e\", \"volumeMounts\": [{\"mountPath\": \"/tmp/results\", \"name\": \"results\"}]}, {\"command\": [\"sh\", \"-c\", \"/sonobuoy worker global -v 5 --logtostderr\"], \"env\": [{\"name\": \"NODE_NAME\", \"valueFrom\": {\"fieldPath\": \"spec.nodeName\", \"fieldRef\": {\"apiVersion\": \"v1\"}}}, {\"name\": \"RESULTS_DIR\", \"value\": \"/tmp/results\"}], \"image\": \"gcr.io/heptio-images/sonobuoy:latest\", \"imagePullPolicy\": \"Always\", \"name\": \"sonobuoy-worker\", \"volumeMounts\": [{\"mountPath\": \"/etc/sonobuoy\", \"name\": \"config\"}, {\"mountPath\": \"/tmp/results\", \"name\": \"results\"}]}], \"restartPolicy\": \"Never\", \"serviceAccountName\": \"sonobuoy-serviceaccount\", \"tolerations\": [{\"effect\": \"NoSchedule\", \"key\": \"node-role.kubernetes.io/master\", \"operator\": \"Exists\"}, {\"key\": \"CriticalAddonsOnly\", \"operator\": \"Exists\"}]}, \"volumes\": [{\"emptyDir\": \"{}\", \"name\": \"results\"}, {\"configMap\": {\"name\": \"__SONOBUOY_CONFIGMAP__\"}, \"name\": \"config\"}]}", | ||
"systemdlogs.json": "{\"driver\": \"DaemonSet\", \"name\": \"systemd_logs\", \"resultType\": \"systemd_logs\", \"spec\": {\"containers\": [{\"command\": [\"sh\", \"-c\", \"/get_systemd_logs.sh && sleep 3600\"], \"env\": [{\"name\": \"NODE_NAME\", \"valueFrom\": {\"fieldPath\": \"spec.nodeName\", \"fieldRef\": {\"apiVersion\": \"v1\"}}}, {\"name\": \"RESULTS_DIR\", \"value\": \"/tmp/results\"}, {\"name\": \"CHROOT_DIR\", \"value\": \"/node\"}], \"image\": \"gcr.io/heptio-images/sonobuoy-plugin-systemd-logs:latest\", \"imagePullPolicy\": \"Always\", \"name\": \"systemd-logs\", \"securityContext\": {\"privileged\": \"true\"}, \"volumeMounts\": [{\"mountPath\": \"/node\", \"name\": \"root\"}, {\"mountPath\": \"/tmp/results\", \"name\": \"results\"}, {\"mountPath\": \"/etc/sonobuoy\", \"name\": \"config\"}]}, {\"command\": [\"sh\", \"-c\", \"/sonobuoy worker single-node -v 5 --logtostderr && sleep 3600\"], \"env\": [{\"name\": \"NODE_NAME\", \"valueFrom\": {\"fieldPath\": \"spec.nodeName\", \"fieldRef\": {\"apiVersion\": \"v1\"}}}, {\"name\": \"RESULTS_DIR\", \"value\": \"/tmp/results\"}], \"image\": \"gcr.io/heptio-images/sonobuoy:latest\", \"imagePullPolicy\": \"Always\", \"name\": \"sonobuoy-worker\", \"securityContext\": {\"privileged\": \"true\"}, \"volumeMounts\": [{\"mountPath\": \"/tmp/results\", \"name\": \"results\"}, {\"mountPath\": \"/etc/sonobuoy\", \"name\": \"config\"}]}], \"dnsPolicy\": \"ClusterFirstWithHostNet\", \"hostIPC\": \"true\", \"hostNetwork\": \"true\", \"hostPID\": \"true\", \"tolerations\": [{\"effect\": \"NoSchedule\", \"key\": \"node-role.kubernetes.io/master\", \"operator\": \"Exists\"}, {\"key\": \"CriticalAddonsOnly\", \"operator\": \"Exists\"}]}, \"volumes\": [{\"hostPath\": {\"path\": \"/\"}, \"name\": \"root\"}, {\"emptyDir\": \"{}\", \"name\": \"results\"}, {\"configMap\": {\"name\": \"__SONOBUOY_CONFIGMAP__\"}, \"name\": \"config\"}]}" | ||
}, | ||
"kind": "ConfigMap", | ||
"metadata": { | ||
"labels": { | ||
"component": "sonobuoy" | ||
}, | ||
"name": "sonobuoy-plugins-cm", | ||
"namespace": "heptio-sonobuoy" | ||
} | ||
} | ||
], | ||
"kind": "List" | ||
} |
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.