Skip to content
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

Add cmd for importing Kubernetes API schemas #194

Merged
merged 2 commits into from
Sep 22, 2023
Merged

Conversation

stefanprodan
Copy link
Owner

@stefanprodan stefanprodan commented Sep 21, 2023

ℹ️ This command was renamed to timoni mod vendor k8s in #197

This PR adds a new command for simplifying the import and generation of CUE schemas for Kubernetes APIs.

The timoni mod import k8s along with timoni mod import crd improve the UX of developing and maintaining app modules.

Motivation

Currently module authors have to install Go, create a dummy Go module, run go get for all the Kubernetes API Go packages for a specific Kubernetes version, then run cue get go for each API group to generate CUE schemas out of the Go types. Keeping this schemas up to date with the Kubernetes releases is a tedious process, since the Go types depend on each other e.g. k8s.io/api/apps/v1@0.28.2 depends on k8s.io/api/core/v1 which depends various packages under k8s.io/apimachinery.

Solution

Timoni offers a simple command for importing and updating all the Kubernetes builtin APIs for a specific minor version.

$ timoni mod import k8s -h
Import Kubernetes API CUE schemas

Usage:
  timoni mod import k8s [MODULE PATH] [flags]

Examples:
  # Import the latest Kubernetes API schemas
  timoni mod import k8s

  # Import s specific minor version of the Kubernetes API schemas
  timoni mod import k8s -v 1.28

The timoni mod import k8s command pulls the CUE schemas from GitHub Container Registry. These schemas are generated after each Kubernetes minor release in the kubernetes-cue-schema repository and published as OCI artifacts at ghcr.io/stefanprodan/timoni/kubernetes-schema.

For each Kubernetes minor version, a dedicated set of CUE schemas are generated for the following Kubernetes GA APIs:

  • k8s.io/api/admission/v1
  • k8s.io/api/admissionregistration/v1
  • k8s.io/api/apps/v1
  • k8s.io/api/authentication/v1
  • k8s.io/api/authorization/v1
  • k8s.io/api/autoscaling/v2
  • k8s.io/api/autoscaling/v1
  • k8s.io/api/batch/v1
  • k8s.io/api/certificates/v1
  • k8s.io/api/coordination/v1
  • k8s.io/api/core/v1
  • k8s.io/api/discovery/v1
  • k8s.io/api/events/v1
  • k8s.io/api/networking/v1
  • k8s.io/api/node/v1
  • k8s.io/api/policy/v1
  • k8s.io/api/rbac/v1
  • k8s.io/api/scheduling/v1
  • k8s.io/api/storage/v1

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
@stefanprodan stefanprodan added area/ux In pursuit of a delightful user experience area/cli CLI related issues and pull requests labels Sep 21, 2023
@stefanprodan stefanprodan merged commit 62216e2 into main Sep 22, 2023
4 checks passed
@stefanprodan stefanprodan deleted the import-k8s-api branch September 22, 2023 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cli CLI related issues and pull requests area/ux In pursuit of a delightful user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant