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

Missing labels on kubecostChecks #761

Closed
pierluigilenoci opened this issue Feb 2, 2021 · 11 comments
Closed

Missing labels on kubecostChecks #761

pierluigilenoci opened this issue Feb 2, 2021 · 11 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@pierluigilenoci
Copy link

Describe the bug
The pods of the kubecostCheck cronjob don't have unique labels that allow them to be identified.
It is therefore difficult to create NetworkPolicy with the pods.

Ref: #743

To Reproduce
Deploy the package with NP enabled with a policy like this:

---
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: deny-all-ingress-traffic
  namespace: <yournamespace>
spec:
  podSelector: {}
  policyTypes:
    - Ingress

Try to create a Network Policy to allow kubecostCheck to reach other Kubecost pods.

Example:

---
kind: NetworkPolicy
apiVersion: networking.k8s.io/v1
metadata:
  name: allow-kubecostcheck-to-cost-analyzer
  namespace: <yournamespace>
spec:
  podSelector:
    matchLabels:
      app.kubernetes.io/name: cost-analyzer
  ingress:
    - from:
        - podSelector:
            matchLabels:
              app.kubernetes.io/name: kubecostcheck # or any other label you like more
        - namespaceSelector:
            matchLabels:
              name: <yournamespace>
  policyTypes:
    - Ingress

Expected behavior
The pod is launched with proper labels.

Example:

  labels:
    app: cost-analyzer
    app.kubernetes.io/instance: cost-analyzer
    app.kubernetes.io/name: kubecostcheck # or any other label you like more
@pierluigilenoci pierluigilenoci added the bug Something isn't working label Feb 2, 2021
@pierluigilenoci pierluigilenoci changed the title Missing annotations on kubecostChecks Missing labels on kubecostChecks Feb 2, 2021
@pierluigilenoci
Copy link
Author

If it's not too much to ask, it would be really valuable to be able to define arbitrary labels and annotations to all possible pods that should be launched.

@dwbrown2 dwbrown2 added the good first issue Good for newcomers label Feb 3, 2021
@dwbrown2
Copy link
Contributor

dwbrown2 commented Feb 3, 2021

This seems like a straightforward addition. Any blockers that you see @AjayTripathy?

@AjayTripathy
Copy link
Contributor

No, we can add this.

@AjayTripathy
Copy link
Contributor

Went ahead and did #777 @pierluigilenoci to support additional labels on all pods created by kubecost-- the subcharts should already support these options. Let us know what you think!

@pierluigilenoci
Copy link
Author

@AjayTripathy I am very pleased that you have provided the possibility to add custom labels and annotations. But I think following the recommendations [1] is still a good thing.

[1] https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/

@pierluigilenoci
Copy link
Author

pierluigilenoci commented Feb 24, 2021

@AjayTripathy what do you think about this? #761 (comment)

@AjayTripathy I am very pleased that you have provided the possibility to add custom labels and annotations. But I think following the recommendations [1] is still a good thing.

@pierluigilenoci
Copy link
Author

@AjayTripathy this is still not working because commonLabels and additionalLabels are in the wrong manifest level. To make the pod inherit them, they must be put at this level: spec.jobTemplate.spec.template.metadata.labels

@pierluigilenoci
Copy link
Author

@dwbrown2 @AjayTripathy any news on this topic?

@AjayTripathy
Copy link
Contributor

Should be done in #827

@AjayTripathy
Copy link
Contributor

Actually, checks pod will get deprecated in 1.79.0, so we may just close this.

@dwbrown2
Copy link
Contributor

Note this functionality will be moved into the core kubecost pod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants