carvel-dev / carvel-dev/kbld

Consider adding annotations to the pod template

Open
#441 4 comments 0 reactions 0 assignees View on GitHub
discussion enhancement
Dominant language
Go
Stars
329
Forks
52
PR merge metrics
No merged PRs in 30d

Description

Hi! We've been using kbld for over two years now with huge success. Thanks! There is just a tiny thing that is bugging us:

**Describe the problem/challenge you have**
As it is usually done, we scrape our **pods** to collect metrics from them. When using `kbld`, the deployed image-**tag** cannot be retrieved just by looking at the pods. Unfortunately, kbld adds its annotations to the owning object (Deployment, StatefulSet, ...) only, but not to its pod template.

Concrete example: We have this manifest:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: opa
spec:
template:
spec:
containers:
- image: docker.io/openpolicyagent/opa:0.55.0
name: opa
```

When feeding it to kbld, it resolves the tags and adds its annotations:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kbld.k14s.io/images: |
- origins:
- resolved:
tag: 0.55.0
url: docker.io/openpolicyagent/opa:0.55.0
url: docker.io/openpolicyagent/opa@sha256:b40919fc5eaf22b70437e81e6575841ad1b034f46b1150873e55fa446cd9f0ca
name: opa
spec:
template:
spec:
containers:
- image: docker.io/openpolicyagent/opa@sha256:b40919fc5eaf22b70437e81e6575841ad1b034f46b1150873e55fa446cd9f0ca
name: opa
```

Instead, I would like to see the annotations *also* (or exclusively, maybe guarded by an option) added to the pod template:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kbld.k14s.io/images: |
- origins:
- resolved:
tag: 0.55.0
url: docker.io/openpolicyagent/opa:0.55.0
url: docker.io/openpolicyagent/opa@sha256:b40919fc5eaf22b70437e81e6575841ad1b034f46b1150873e55fa446cd9f0ca
name: opa
spec:
template:
metadata:
annotations:
kbld.k14s.io/images: |
- origins:
- resolved:
tag: 0.55.0
url: docker.io/openpolicyagent/opa:0.55.0
url: docker.io/openpolicyagent/opa@sha256:b40919fc5eaf22b70437e81e6575841ad1b034f46b1150873e55fa446cd9f0ca
spec:
containers:
- image: docker.io/openpolicyagent/opa@sha256:b40919fc5eaf22b70437e81e6575841ad1b034f46b1150873e55fa446cd9f0ca
name: opa
```

I don't really care about the annotations on the outer Manifest. Maybe it should be an option to add the annotations to the pod-template *only*.

**Describe the solution you'd like**
I don't really care if this proposed behaviour gets enabled by default or if this would be opt-in using some kind of option. Maybe this could be configured using a new annotation on the outer manifest, like so:

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kbld.k14s.io/add-pod-annotations: 'true'
```

---
Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.