airshipit / airshipctl

A CLI for managing declarative infrastructure.
Apache License 2.0
43 stars 49 forks source link

Develop new kubeconfig workflow #666

Open raliev12 opened 3 years ago

raliev12 commented 3 years ago

Problem description (if applicable) Current kubeconfig management and workflow in airshipctl has outdone itself. There are several common problems that we have with kubeconfigs right now:

  1. kubeconfigs are generated and dumped to filesystem per each phase, however it only slows deployment process and adds unnecessary complication since most of the time kubeconfig remains the same and we need to update or merge it only on demand;
  2. it's unclear which particular kubeconfig will be generated and used in a phase since kubeconfigs are retrieved iteratively using all the defined sources in cluster map. This approach makes delays and it's inconvenient for the end user to define a kubeconfig and its sources in a separate entity; also the information stored in clustermap has no practical benefit since it duplicates itself.
  3. since we generate kubeconfigs each time per phase we should carry kubeconfig entrypoint within phase config manifests, therefore we decrypt kubeconfig from manifests even if we don't need it. Thus all airshipctl subcommands doesn't work at all without defined in env SOPS decrypt keys and it makes it slow. There are already PS in downstream with workarounds solving that problem (by removing kubeconfig entrypoint from phase bundle) since it become really annoying for colleagues who use airshipctl every day;
  4. we don't have integration with all common kubernetes cli tools which support KUBECONFIG env var and --kubeconfig flag (it was removed from airshipctl in favor of cluster map);
  5. we still don't have handy and reliable approach to merge kubeconfigs - Kubeconfig interface in airshipctl doesn't provide functionality to do that properly and engineers make attempts to workaround this use-case using toolbox container and custom bash scripts with kubectl under the hood (for instance, capd phase plan).
  6. we work mostly with cluster names instead of contexts, assuming if they are not equal then the appropriate information should be stored in cluster map. However there are no verifications or enforcement of that. Kubernetes client which is beneficiary of kubeconfig information works with contexts instead of clusters, so we should either use context or enforce that defined context for cluster has a relation for that cluster.
  7. Kubeconfig and builder interfaces in airshipctl are bulky, non-efficient and most of their part aren't even used.

Proposed change To solve described problems we should move forward and use completely different approach which must be:

  1. simple
  2. easy to understand
  3. fast
  4. reliable
  5. predictable

We have the following use cases to cover:

The proposal of new kubeconfig workflow is the following:

Potential impacts Improved performance and user experience.

raliev12 commented 3 years ago

The issue can be assigned to me.

eak13 commented 3 years ago

Review on next design call.