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

in-memory kubeconfig rather than file #139

Closed
hassenius opened this issue Jun 17, 2021 · 2 comments · Fixed by #212
Closed

in-memory kubeconfig rather than file #139

hassenius opened this issue Jun 17, 2021 · 2 comments · Fixed by #212
Labels
has_pr type/enhancement New feature or request

Comments

@hassenius
Copy link

SUMMARY

Have a method to use non-file-based kubeconfig

ISSUE TYPE

Feature or documentation improvement if already possible

COMPONENT NAME

kubernetes.core.k8s

ADDITIONAL INFORMATION

In our case we store the relevant kubernetes auth information in an external secret store, so we can easily retrieve the content of a kubeconfig file which has all the relevant information to connect to the cluster.
It appears that the kubernetes.core.k8s component expects to find kubeconfig as a file: https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html#parameter-kubeconfig
with no way to feed ca/client_cert/key in as direct values.

This means for us we'd need to save the relevant information to temporary files after retrieving them from external secret store.

@abikouo
Copy link
Contributor

abikouo commented Jun 17, 2021

@hassenius thanks for taking the time to report this new feature request.
As mentioned for now to connect to the cluster using kubeconfig you will need a file, but if you have the username, password and host information (or api_key) you can feed them directly to the kubernetes.core.k8s module.
As a workaround you can use the ansible.builtin.tempfile module to create the kubeconfig file.

@abikouo abikouo added the type/enhancement New feature or request label Jun 17, 2021
@bigfleet
Copy link

e.g.

- name: Store kube/config in tempfile
  ansible.builtin.tempfile:
    state: file
  register: aks_kubeconfig_tmpfile
- name: Place kubeconfig onto filesystem temporarily
  copy: 
    content: "{{ azure_aks_cluster.kube_config }}"
    dest: "{{ aks_kubeconfig_tmpfile.path }}"
    mode: '0600'
- name: Get Cluster information
  kubernetes.core.k8s_info:
    kind: namespace
    kubeconfig: "{{ aks_kubeconfig_tmpfile.path }}"

@abikouo abikouo added the has_pr label Aug 26, 2021
ansible-zuul bot pushed a commit that referenced this issue Aug 30, 2021
add support for in-memory kubeconfig

SUMMARY

k8s module support now authentication with kubeconfig parameter as file and dict.

Closes #139
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ADDITIONAL INFORMATION

Reviewed-by: Mike Graves <mgraves@redhat.com>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has_pr type/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants