Skip to content

Conversation

bernielomax
Copy link
Contributor

@bernielomax bernielomax commented Aug 26, 2025

Summary

Works towards Airbyte dataplane installation and management. Adds abctl config init command to bootstrap abctl configuration from existing Airbyte Kubernetes deployments. Auto-detects Airbyte ConfigMaps ending with -airbyte-env suffix and extracts API endpoints and auth settings. It is envisioned that Abctl installation will automatically create the Abctl configmap during installation. Though I have added ample test coverage, and put some thought into this PR, there will might be some gaps. I'm hoping I can address these issues in future PRs before cutting a new release.

What's New

abctl config init Command

  • Auto-detects source ConfigMap using -airbyte-env suffix pattern
  • Extracts AIRBYTE_API_HOST, AIRBYTE_URL, and auth endpoints
  • Creates abctl ConfigMap with the extracted config
  • --from-configmap to specify source manually
  • --force to overwrite existing config

Better Kubeconfig Handling

  • DefaultK8s() now respects KUBECONFIG env var when no explicit path given
  • Falls back to ~/.kube/config as expected
  • Backward compatible

K8s Client Extensions

Added ConfigMap operations: Get, List, Create, Update

Config Utilities

  • AbctlConfigFromData() - extracts config from ConfigMap data
  • GetAbctlConfig() - fetches abctl config from k8s

Usage

Auto-detect and init

abctl config init -n airbyte

Manual source

abctl config init -n airbyte --from-configmap my-airbyte-env

Force overwrite

  abctl config init -n airbyte --force

Note

The bernielomax/feat/auth-login-logout branch adds GetCurrentNamespace() for better namespace detection from kubeconfig context - pairs nicely with this init command. It also introduces the auth login auth logout command which builds upon this PR.

Tests

Full test coverage for ConfigMap operations, config extraction, and kubeconfig resolution.

- Add ConfigMapGet, ConfigMapCreate, and ConfigMapUpdate methods to Client interface
- Implement methods in DefaultK8sClient using Kubernetes clientset
- Add comprehensive unit tests for all three methods with happy path and error cases
- Maintains consistency with existing Secret operations
Enable DefaultK8s to use Kubernetes' standard configuration resolution
when an empty kubeconfig path is provided. This allows the function to
automatically respect the KUBECONFIG environment variable and fall back
to ~/.kube/config, matching kubectl's behavior.

Why: The init command needs to connect to external Kubernetes clusters
using standard kubeconfig resolution, while other commands continue to
use the explicit kind cluster configuration.

How: When kubecfg is empty, use clientcmd.NewDefaultClientConfigLoadingRules()
which implements the standard Kubernetes config search order. Otherwise,
maintain backward compatibility by using the explicit path.
Add a new 'abctl init' command that extracts configuration from an
existing Airbyte installation and creates an abctl ConfigMap for
future operations.

Why: Enable abctl to work with existing Airbyte deployments by reading
their configuration and storing it in a standardized format.

How: The command reads the airbyte-env ConfigMap, extracts the Airbyte
API host, then creates an abctl ConfigMap with this configuration for
subsequent abctl operations.
Add unit tests for the AbctlConfigFromData function and update the
mock k8s client to support ConfigMap operations needed by the init
command.
@bernielomax bernielomax requested a review from a team as a code owner August 26, 2025 16:51
@colesnodgrass
Copy link
Member

Should this be under the local sub-commands? I.e. abctl local init?

@bernielomax
Copy link
Contributor Author

This is more aimed at not local (but will work for local and remote). The commands that will use this feature will be more for API interactions, like get dataplanes, etc. Ideally I would like to clean up and set more into VERB NOUN, but given the time constraints, it will be a little mixed for the interim.


const suffix = "-airbyte-env"
for _, cm := range configMaps.Items {
if len(cm.Name) >= len(suffix) && cm.Name[len(cm.Name)-len(suffix):] == suffix {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has this be replaced with strings.HasSuffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I can fix that up.

@colesnodgrass
Copy link
Member

This is more aimed at not local (but will work for local and remote). The commands that will use this feature will be more for API interactions, like get dataplanes, etc. Ideally I would like to clean up and set more into VERB NOUN, but given the time constraints, it will be a little mixed for the interim.

I do wonder if there is a sub-command (or namespace) we could throw this under. I'm reluctant to introduce a root command to abctl without thinking through all the use cases for it.

@bernielomax
Copy link
Contributor Author

We did talk about having a completely separate executable, or using a command like abctl <dataplane or something> .... The abctl name is more aligned with what we are trying to achieve and less with local Airbyte installations. I’m just hoping to land the feature, and we can refactor the command structure (if needed) before release.

@bernielomax
Copy link
Contributor Author

bernielomax commented Aug 26, 2025

As discussed with @colesnodgrass . I have added a fixup commit that moves abctl init command to abctl config init. - 9611531

I also addressed comment regarding strings.HasSuffix.

@bernielomax bernielomax changed the title feat: init command feat: abctl config init command Aug 26, 2025
@bernielomax bernielomax merged commit 471141c into main Aug 26, 2025
4 checks passed
@bernielomax bernielomax deleted the bernielomax/feat/init-command branch August 26, 2025 19:29
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.

2 participants