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

fix: workaround to support multiple kubernetes clusters #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rophy
Copy link

@rophy rophy commented Mar 24, 2024

See #170 for the issue description.

This PR leverages the fact that the plugin actually works for multiple kubernetes clusters if kubernetes:config_file is avaiable in node attribute.

If config_file does not exist and url + token exists, plugin now generates a config_file in project var tmp dir, and sets that in node attribute.

Tested using kind:

$ env | grep RD_ | sort
RD_CONFIG_ATTRIBUTES=
RD_CONFIG_NAMESPACE=kube-system
RD_CONFIG_TAGS=tag.selector=default:status
RD_CONFIG_TOKEN=***
RD_CONFIG_URL=https://127.0.0.1:38287
RD_PLUGIN_VARDIR=/tmp

$ python contents/pods-resource-model.py 
INFO: kubernetes-model-source: ------
INFO: kubernetes-model-source: container-name:coredns
INFO: kubernetes-model-source: pod-container-name:coredns
INFO: kubernetes-model-source: Generated /tmp/tmp/a59e74c1b8100831
INFO: kubernetes-model-source: ------
INFO: kubernetes-model-source: container-name:coredns
INFO: kubernetes-model-source: pod-container-name:coredns
...
[
    {
        "default:container_id": "containerd://069c6a2413c36c466d9023bf3b9853524d675b66f8af55d248b289d8367caa42",
        "default:container_name": "coredns",
        ...
        "kubernetes:config_file": "/tmp/tmp/a59e74c1b8100831",
        "labels:k8s-app": "kube-dns",
        "labels:pod-template-hash": "6d4b75cb6d",
        "nodename": "coredns-6d4b75cb6d-2trxl-coredns",
        "status": "running",
        "tags": "pods,running",
        "terminated": false
    },
    ...
]

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.

1 participant