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

feat: add hostname, uptime and gateway count providers #40

Merged
merged 1 commit into from
Aug 9, 2022

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Aug 8, 2022

This PR adds more providers, specifically:

  • hostname provider
  • uptime provider (counting time since provider's creation time)
  • gateways count provider

Open questions/issues

For some bizarre reason I can't get gateway counting to work in testing (mocked) environment.

When I don't register the custom GatewayList type as seen in tests in this PR, I get the following error:

panic: coding error: you must register resource to list kind for every resource you're going to LIST when creating the client.  See NewSimpleDynamicClientWithCustomListKinds or register the list into the scheme: gateway.networking.k8s.io/v1beta1, Resource=gateways out of map[/, Resource=:List /v1, Resource=apigroups:APIGroupList /v1, Resource=apiresources:APIResourceList /v1, Resource=componentstatuses:ComponentStatusList /v1, Resource=configmaps:ConfigMapList /v1, Resource=endpoints:EndpointsList /v1, Resource=events:EventList /v1, Resource=limitranges:LimitRangeList /v1, Resource=namespaces:NamespaceList /v1, Resource=nodes:NodeList /v1, Resource=persistentvolumeclaims:PersistentVolumeClaimList /v1, Resource=persistentvolumes:PersistentVolumeList /v1, Resource=pods:PodList /v1, Resource=podtemplates:PodTemplateList /v1, Resource=replicationcontrollers:ReplicationControllerList /v1, Resource=resourcequotas:ResourceQuotaList /v1, Resource=secrets:SecretList /v1, Resource=serviceaccounts:ServiceAccountList /v1
, Resource=services:ServiceList admissionregistration.k8s.io/v1, Resource=mutatingwebhookconfigurations:MutatingWebhookConfigurationList admissionregistration.k8s.io/v1, Resource=validatingwebhookconfigurations:ValidatingWebhookConfigurationList admissionregistration.k8s.io/v1beta1, Resource=mutatingwebhookconfigurations:MutatingWebhookConfigurationList admissionregistration.k8s.io/v1beta1, Resource=validatingwebhookconfigurations:ValidatingWebhookConfigurationList apps/v1, Resource=controllerrevisions:ControllerRevisionList apps/v1, Resource=daemonsets:DaemonSetList apps/v1, Resource=deployments:DeploymentList apps/v1, Resource=replicasets:ReplicaSetList apps/v1, Resource=statefulsets:StatefulSetList apps/v1beta1, Resource=controllerrevisions:ControllerRevisionList apps/v1beta1, Resource=deployments:DeploymentList apps/v1beta1, Resource=statefulsets:StatefulSetList apps/v1beta2, Resource=controllerrevisions:ControllerRevisionList apps/v1beta2, Resource=daemonsets:DaemonSetList apps/v1beta2, Resource=deployme
nts:DeploymentList apps/v1beta2, Resource=replicasets:ReplicaSetList apps/v1beta2, Resource=statefulsets:StatefulSetList autoscaling/v1, Resource=horizontalpodautoscalers:HorizontalPodAutoscalerList autoscaling/v2, Resource=horizontalpodautoscalers:HorizontalPodAutoscalerList autoscaling/v2beta1, Resource=horizontalpodautoscalers:HorizontalPodAutoscalerList autoscaling/v2beta2, Resource=horizontalpodautoscalers:HorizontalPodAutoscalerList batch/v1, Resource=cronjobs:CronJobList batch/v1, Resource=jobs:JobList batch/v1beta1, Resource=cronjobs:CronJobList certificates.k8s.io/v1, Resource=certificatesigningrequests:CertificateSigningRequestList certificates.k8s.io/v1beta1, Resource=certificatesigningrequests:CertificateSigningRequestList coordination.k8s.io/v1, Resource=leases:LeaseList coordination.k8s.io/v1beta1, Resource=leases:LeaseList discovery.k8s.io/v1, Resource=endpointslices:EndpointSliceList discovery.k8s.io/v1beta1, Resource=endpointslices:EndpointSliceList events.k8s.io/v1, Resource=events:EventList
 events.k8s.io/v1beta1, Resource=events:EventList extensions/v1beta1, Resource=daemonsets:DaemonSetList extensions/v1beta1, Resource=deployments:DeploymentList extensions/v1beta1, Resource=ingresses:IngressList extensions/v1beta1, Resource=networkpolicies:NetworkPolicyList extensions/v1beta1, Resource=podsecuritypolicies:PodSecurityPolicyList extensions/v1beta1, Resource=replicasets:ReplicaSetList flowcontrol.apiserver.k8s.io/v1alpha1, Resource=flowschemas:FlowSchemaList flowcontrol.apiserver.k8s.io/v1alpha1, Resource=prioritylevelconfigurations:PriorityLevelConfigurationList flowcontrol.apiserver.k8s.io/v1beta1, Resource=flowschemas:FlowSchemaList flowcontrol.apiserver.k8s.io/v1beta1, Resource=prioritylevelconfigurations:PriorityLevelConfigurationList flowcontrol.apiserver.k8s.io/v1beta2, Resource=flowschemas:FlowSchemaList flowcontrol.apiserver.k8s.io/v1beta2, Resource=prioritylevelconfigurations:PriorityLevelConfigurationList gateway.networking.k8s.io/v1beta1, Resource=gatewaies:GatewayList gateway.network
ing.k8s.io/v1beta1, Resource=gatewayclasses:GatewayClassList gateway.networking.k8s.io/v1beta1, Resource=httproutes:HTTPRouteList internal.apiserver.k8s.io/v1alpha1, Resource=storageversions:StorageVersionList networking.k8s.io/v1, Resource=ingressclasses:IngressClassList networking.k8s.io/v1, Resource=ingresses:IngressList networking.k8s.io/v1, Resource=networkpolicies:NetworkPolicyList networking.k8s.io/v1beta1, Resource=ingressclasses:IngressClassList networking.k8s.io/v1beta1, Resource=ingresses:IngressList node.k8s.io/v1, Resource=runtimeclasses:RuntimeClassList node.k8s.io/v1alpha1, Resource=runtimeclasses:RuntimeClassList node.k8s.io/v1beta1, Resource=runtimeclasses:RuntimeClassList policy/v1, Resource=poddisruptionbudgets:PodDisruptionBudgetList policy/v1beta1, Resource=poddisruptionbudgets:PodDisruptionBudgetList policy/v1beta1, Resource=podsecuritypolicies:PodSecurityPolicyList rbac.authorization.k8s.io/v1, Resource=clusterrolebindings:ClusterRoleBindingList rbac.authorization.k8s.io/v1, Resource=cl
usterroles:ClusterRoleList rbac.authorization.k8s.io/v1, Resource=rolebindings:RoleBindingList rbac.authorization.k8s.io/v1, Resource=roles:RoleList rbac.authorization.k8s.io/v1alpha1, Resource=clusterrolebindings:ClusterRoleBindingList rbac.authorization.k8s.io/v1alpha1, Resource=clusterroles:ClusterRoleList rbac.authorization.k8s.io/v1alpha1, Resource=rolebindings:RoleBindingList rbac.authorization.k8s.io/v1alpha1, Resource=roles:RoleList rbac.authorization.k8s.io/v1beta1, Resource=clusterrolebindings:ClusterRoleBindingList rbac.authorization.k8s.io/v1beta1, Resource=clusterroles:ClusterRoleList rbac.authorization.k8s.io/v1beta1, Resource=rolebindings:RoleBindingList rbac.authorization.k8s.io/v1beta1, Resource=roles:RoleList scheduling.k8s.io/v1, Resource=priorityclasses:PriorityClassList scheduling.k8s.io/v1alpha1, Resource=priorityclasses:PriorityClassList scheduling.k8s.io/v1beta1, Resource=priorityclasses:PriorityClassList storage.k8s.io/v1, Resource=csidrivers:CSIDriverList storage.k8s.io/v1, Resource=
csinodes:CSINodeList storage.k8s.io/v1, Resource=csistoragecapacities:CSIStorageCapacityList storage.k8s.io/v1, Resource=storageclasses:StorageClassList storage.k8s.io/v1, Resource=volumeattachments:VolumeAttachmentList storage.k8s.io/v1alpha1, Resource=csistoragecapacities:CSIStorageCapacityList storage.k8s.io/v1alpha1, Resource=volumeattachments:VolumeAttachmentList storage.k8s.io/v1beta1, Resource=csidrivers:CSIDriverList storage.k8s.io/v1beta1, Resource=csinodes:CSINodeList storage.k8s.io/v1beta1, Resource=csistoragecapacities:CSIStorageCapacityList storage.k8s.io/v1beta1, Resource=storageclasses:StorageClassList storage.k8s.io/v1beta1, Resource=volumeattachments:VolumeAttachmentList]

goroutine 38 [running]:
k8s.io/client-go/dynamic/fake.(*dynamicResourceClient).List(0x140004fec60, {0x10367b698?, 0x140005440c0?}, {{{0x0, 0x0}, {0x0, 0x0}}, {0x0, 0x0}, {0x0, ...}, ...})
        /Users/[email protected]/.gvm/pkgsets/go1.19/global/pkg/mod/k8s.io/[email protected]/dynamic/fake/simple.go:353 +0x808
github.com/kong/kubernetes-telemetry/pkg/provider.(*k8sObjectCount).Provide(0x140004fecc0, {0x10367b698, 0x140005440c0})
        /Users/[email protected]/code_/kubernetes-telemetry/pkg/provider/k8sobjectcountprovider.go:33 +0x94
github.com/kong/kubernetes-telemetry/pkg/telemetry.(*workflow).Execute.func1()
        /Users/[email protected]/code_/kubernetes-telemetry/pkg/telemetry/workflow.go:72 +0x7c
github.com/gammazero/workerpool.startWorker(0x0?, 0x1400052c2a0)
        /Users/[email protected]/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/gammazero/[email protected]/workerpool.go:233 +0x28
created by github.com/gammazero/workerpool.(*WorkerPool).dispatch
        /Users/[email protected]/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/gammazero/[email protected]/workerpool.go:195 +0x1e8

where a sharp eye can spot Resource=gatewaies:GatewayList gateway.network ing.k8s.io/v1beta1 which to me should be gateways (?).

Quick google search shows an issue in kubernetes/client-go#1082 (comment).

EDIT: It seems there's a fix for the above: kubernetes/kubernetes#110053.
If I understand it correctly this will require https://github.com/kubernetes/kubernetes/tree/master/staging 's apimachinery dir to be synced out to https://github.com/kubernetes/apimachinery and then a release of that.

@pmalek pmalek requested a review from a team as a code owner August 8, 2022 18:09
@pmalek pmalek self-assigned this Aug 8, 2022
Copy link
Contributor

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

Make sure TODOs are resolved by either making the relevant changes, OR creating and linking a follow-up issue so they don't end up untracked and then LGTM.

@pmalek pmalek merged commit fe6d3b8 into main Aug 9, 2022
@pmalek pmalek deleted the add-more-providers branch August 9, 2022 19:46
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