Skip to content

Commit

Permalink
CRIB-317 - Use the kyverno's label instead of kube-janitor's annotati…
Browse files Browse the repository at this point in the history
…on for clean up (#1080)
  • Loading branch information
rafaelfelix authored Aug 21, 2024
1 parent 6f61d6a commit 3e7c014
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion k8s/TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const (
```golang
// Config is an environment common configuration, labels, annotations, connection types, readiness check, etc.
type Config struct {
// TTL is time to live for the environment, used with kube-janitor
// TTL is time to live for the environment, used with kyverno
TTL time.Duration
// NamespacePrefix is a static namespace prefix
NamespacePrefix string
Expand Down
5 changes: 3 additions & 2 deletions k8s/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type ConnectedChart interface {

// Config is an environment common configuration, labels, annotations, connection types, readiness check, etc.
type Config struct {
// TTL is time to live for the environment, used with kube-janitor
// TTL is time to live for the environment, used with kyverno
TTL time.Duration
// NamespacePrefix is a static namespace prefix
NamespacePrefix string
Expand Down Expand Up @@ -272,11 +272,12 @@ func (m *Environment) initApp() error {
}
}

m.Cfg.Labels = append(m.Cfg.Labels, fmt.Sprintf("%s=%s", pkg.TTLLabelKey, *a.ShortDur(m.Cfg.TTL)))
nsLabels, err := a.ConvertLabels(m.Cfg.Labels)
if err != nil {
return err
}
defaultNamespaceAnnotations[pkg.TTLLabelKey] = a.ShortDur(m.Cfg.TTL)

m.root = cdk8s.NewChart(m.App, ptr.Ptr(fmt.Sprintf("root-chart-%s", m.Cfg.Namespace)), &cdk8s.ChartProps{
Labels: nsLabels,
Namespace: ptr.Ptr(m.Cfg.Namespace),
Expand Down
2 changes: 1 addition & 1 deletion k8s/pkg/alias/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"
)

// ShortDur is a helper method for kube-janitor duration format
// ShortDur is a helper method for kyverno duration format
func ShortDur(d time.Duration) *string {
s := d.String()
if strings.HasSuffix(s, "m0s") {
Expand Down
2 changes: 1 addition & 1 deletion k8s/pkg/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "github.com/smartcontractkit/chainlink-testing-framework/utils/ptr"

// Common labels for k8s envs
const (
TTLLabelKey = "janitor/ttl"
TTLLabelKey = "cleanup.kyverno.io/ttl"
NamespaceLabelKey = "namespace"
)

Expand Down

0 comments on commit 3e7c014

Please sign in to comment.