Kubernetes 1.22+ breaks docsonnet
Closed this issue · 4 comments
EDIT: seems to be since Kubernetes 1.22 release: https://jsonnet-libs.github.io/k8s-libsonnet/1.22/ and the deprecation of extensions/v1beta1
This commit 5e702db broke the docsonnet keys;
when merging the libraries with the root object (which we do), the output is no longer empty; see below as example:
(import 'github.com/jsonnet-libs/k8s-libsonnet/1.23/main.libsonnet')
+ {}
results in
tk eval output
{
"extensions": {
"v1beta1": {
"daemonSet": {
"#new": {
"function": {
"args": [
{
"default": null,
"name": "name",
"type": "string"
},
{
"default": null,
"name": "containers",
"type": "array"
},
{
"default": {},
"name": "podLabels",
"type": "object"
}
]
}
}
},
"deployment": {
"#new": {
"function": {
"args": [
{
"default": null,
"name": "name",
"type": "string"
},
{
"default": 1,
"name": "replicas",
"type": "number"
},
{
"default": null,
"name": "containers",
"type": "array"
},
{
"default": {},
"name": "podLabels",
"type": "object"
}
]
}
}
},
"statefulSet": {
"#new": {
"function": {
"args": [
{
"default": null,
"name": "name",
"type": "string"
},
{
"default": 1,
"name": "replicas",
"type": "number"
},
{
"default": null,
"name": "containers",
"type": "array"
},
{
"default": [],
"name": "volumeClaims",
"type": "array"
},
{
"default": {},
"name": "podLabels",
"type": "object"
}
]
}
}
}
}
}
}
nvm maybe it did not
Quick fix for this:
Append to lib/k.libsonnet
:
+ {
// disable deprecated API until https://github.com/jsonnet-libs/k8s/issues/132 is fixed
extensions:: null
}
Hi @irizzant
when merging the libraries with the root object (which we do), the output is no longer empty; see below as example:
(import 'github.com/jsonnet-libs/k8s-libsonnet/1.23/main.libsonnet') + {}
I assume this is so you can do?
(import 'github.com/jsonnet-libs/k8s-libsonnet/1.23/main.libsonnet')
+ {
deployment: $.apps.v1.deployment.new(),
}
I would strongly discourage that as this is the same as using 'globals' in any other
language.
The better way would be to do this:
local k = (import 'github.com/jsonnet-libs/k8s-libsonnet/1.23/main.libsonnet');
{
deployment: k.apps.v1.deployment.new(),
}
It ensures that k
isn't modified along the way and doesn't cause any suprises like the
one you are bringing up in this issue.
The fact that you have to propose several changes upstream is a consequence of using this
library in an unintended way. Please try to follow the proposed pattern to prevent any
future conflict.