Skip to content

Conversation

batistein
Copy link
Contributor

Overview: The document explores methods to read from a yaml file and apply Kubernetes objects to the API. It deliberates on whether to adopt a generic approach for arbitrary CRDs or a specific approach for known CRDs, with the former being preferred.

Background: For cluster stacks, the need is to apply Helm charts without knowing a priori the Kubernetes objects contained. The operator in the system must read yaml configurations and apply these objects.

Reading from yaml files:

  • Unstructured Approach: Utilizes unstructured.Unstructured from Kubernetes' client-go library. It offers flexibility, version agnosticism, and generic handling.
  • Structured Approach: Involves predefined Go structs for Kubernetes resources. This approach offers type safety, auto-completion, and clearer code.

Schemes in Kubernetes:

  • Unstructured.UnstructuredJSONScheme: Provides generality without prior knowledge of specific API types. It simplifies initialization and allows dynamic data manipulation.
  • Specific Schemes for CRDs: Offers type safety, clarity, rich features, and better performance by working with specific Go types.

Applying Objects to Kubernetes:

  • Static Client: Useful for well-defined resources and offers type safety, an intuitive API, and autocompletion. However, it's less flexible and more dependent on specific libraries.
  • Dynamic Client: Ideal for Custom Resources or CRDs, providing flexibility, version independence, and reduced dependencies. It might lack type safety and requires more verbose interactions.

This ADR underscores the importance of adopting a flexible, unstructured approach when handling dynamic Kubernetes resources, especially when the exact resources are unknown beforehand.

@jschoone jschoone linked an issue Aug 28, 2023 that may be closed by this pull request
@mbuechse
Copy link
Contributor

@jschoone @batistein Is this still relevant? I will close this PR if nothing happens by July 31st.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADR: Talking to Kubernetes API in Go

2 participants