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

poc of kubernetes entity provider #51

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

punkle
Copy link
Contributor

@punkle punkle commented Sep 29, 2023

No description provided.

await Promise.all(namespaces.items.map(async namespace => {
await Promise.all(this.opts.objectMappings.map(async objectMapping => {
if (namespace.metadata?.name) {
if (objectMapping.plural === 'pods') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the core api, I am only allow pods to be collected, in the ultimate version we would allow collecting any of the other core api resources.

}))
})
} catch (e: any) {
logger.info(`handling entity request failed: ${e}`);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We probably need better error handling here.

const brokerServer = process.env.BROKER_SERVER || 'http://localhost:7341';

RoadieAgent.fromConfig({
server: brokerServer,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The settings here will need to be provided from the outside.. and some of the settings should be defaulted in the implementation of fromConfig.

@@ -24,6 +24,9 @@
"build/types/**/*",
"config/accept.json"
],
"bin": {
"kubernetes-entity-provider": "./bin/kubernetes-entity-provider"
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be maybe better in a format like agent-entity-provider --variant kubernetes or something

createRoadieAgentEntityProvider({
name: 'kube',
handler: new KubernetesEntityProvider({
namespaceFilters: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these settings should be configurable with sensible defaults.

const namespaces = await this.listNamespaces();

await Promise.all(namespaces.items.map(async namespace => {
await Promise.all(this.opts.objectMappings.map(async objectMapping => {
Copy link
Contributor

Choose a reason for hiding this comment

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

await for...of probably easier to read here since you are mutating the external var already

const k8sCustomObjectsApi = this.kc.makeApiClient(CustomObjectsApi)
const namespaces = await this.listNamespaces();

await Promise.all(namespaces.items.map(async namespace => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think flatMapping should probably achieve the same things here, depending how you decide to modify the loop below

RUN npm install && npm install typescript -g
COPY . .
RUN yarn build
CMD ["node", "./bin/kubernetes-entity-provider"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need the ability to configure the entity provider entity mappings and the broker client server url and token.

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