Comments (7)
Since there is no build system yet - just do a PR and we can go from that?
from k8s.
I was planning to automate it through Github actions for now. I'm not familiar with Bazel.
from k8s.
The github actions are now in place.
The most common way to pull in jsonnet libraries is currently through jsonnet-bundler, this also does leverages the http-archive afaik. Maybe a jsonnet_bundler
bazel rule could be a thing? Or maybe the jsonnet_library
could build-in the http_archive
rule?
My main question is: why put the burden of integrating into someone else's CI system on the source files?
from k8s.
There is no need to put Bazel rules into the repository.
@Geethree you can put the following into your WORKSPACE file:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
new_git_repository(
name = "com_github_jsonnet-libs_k8s-libsonnet",
remote = "https://github.com/jsonnet-libs/k8s-libsonnet",
commit = "f47562c4e3bfaf46a5a5bc6a9e1e76a4fc76c18e",
build_file_content = """
load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_library")
jsonnet_library(
name = "1.20",
srcs = glob(["1.20/**/*.libsonnet"]),
visibility = ["//visibility:public"],
imports = ["."],
)
""",
You can now use it in your BUILD files like this:
jsonnet_to_json(
name = "statefulset",
src = "statefulset.jsonnet",
outs = ["statefulset.json"],
deps = [
"@com_github_jsonnet-libs_k8s-libsonnet//:1.20",
],
)
My example Jsonnet file looks like this:
local k = import "1.20/main.libsonnet";
{
cockroachdb: {
statefulset: k.apps.v1.statefulSet.new(
name="cockroachdb",
replicas=1,
containers=[
k.core.v1.container.new("cockroachdb", "cockroachdb/cockroach")
]
)
}
}
Personally I do not like that I have to use the path 1.20
when importing, but I couldn't find a better way yet.
from k8s.
Update: to get rid of the 1.20
in the import path, you can write a small wrapper and import that instead.
Wrapper content:
(import '1.20/main.libsonnet')
This also offers the benefit that you can add additional functionality like Grafana did (https://github.com/grafana/jsonnet-libs/tree/master/ksonnet-util).
The import line in other packages will then look like this:
local k = import "path/to/wrapper.libsonnet";
from k8s.
It is a common pattern to have this wrapper in lib/k.libsonnet
, for example this works well with ksonnet-util on which quite a bit of libraries depend upon.
from k8s.
Judging on above discussion, I believe the original question was answered with a suggested solution by @0xIDANT. I think we can close it based on that.
from k8s.
Related Issues (20)
- With fluent/fluenbit-operator, generator fails with: Expected token IDENTIFIER but got "null" while parsing parameter HOT 1
- (k8s-libsonnet) inconsistent inclusion of labelSelector HOT 3
- Kubernetes 1.22+ breaks docsonnet HOT 4
- Feature request: add prefix for downloaded library to avoid same version number conflict with other library HOT 4
- Kubernetes 1.22+ breaks docsonnet HOT 5
- generate k8s-libsonnet 1.24
- Can't create a deployment without specifying replicas HOT 5
- escapeKey does not escape / (forward slash) HOT 1
- HPA `withScaleTargetRef` custom function returns error
- volume-mount helpers only target containers and exclude initContainers
- How to dynamically create volume for a deployment HOT 1
- Kubernetes 1.26 support
- Version discovery and automated updates HOT 4
- Better documentation and explanation of object shapes
- Generator can not properly handle keys/values with operand characters (ie $) HOT 2
- k8s-libsonnet: Text block's first line must start with whitespace HOT 1
- mapContainer doesn't work on pod. HOT 1
- Unable to create a service without defining a selector. HOT 6
- New generator to support CloudFormation resources HOT 6
- Problems importing CRDs with Helm variables in metadata - Linkerd HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from k8s.