Skip to content

Commit

Permalink
Fix empty metadata.annotations causing sync issues
Browse files Browse the repository at this point in the history
Switching this component to server-side has the side effect that the last known state
is no longer tracked in the `metdata.annotations` field. If using a library to create
resources, like `kube.libsonnet`, will create empty `metadata.annotations` fields.
Which will then cause a sync issue with argocd.
  • Loading branch information
DebakelOrakel committed Mar 1, 2024
1 parent 0862794 commit 21112a4
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 33 deletions.
12 changes: 10 additions & 2 deletions component/instances.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ local namespacedName(name, namespace='') = {
local ArgoCD(name) =
local n = namespacedName(name);
kube._Object('argoproj.io/v1beta1', 'ArgoCD', n.name) {
metadata+: {
metadata: {
labels: {
name: n.name,
},
name: n.name,
namespace: n.namespace,
},
spec+: {
Expand All @@ -27,7 +31,11 @@ local ArgoCD(name) =
local AppProject(name) =
local n = namespacedName(name);
kube._Object('argoproj.io/v1alpha1', 'AppProject', n.name) {
metadata+: {
metadata: {
labels: {
name: n.name,
},
name: n.name,
namespace: n.namespace,
},
};
Expand Down
18 changes: 13 additions & 5 deletions component/monitoring.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ local params = inv.parameters.argocd;

local serviceMonitor(objname, name) =
kube._Object('monitoring.coreos.com/v1', 'ServiceMonitor', objname) {
metadata+: {
metadata: {
name: objname,
namespace: params.namespace,
labels+: {
labels: {
name: objname,
'app.kubernetes.io/name': name,
'app.kubernetes.io/part-of': 'argocd',
},
Expand All @@ -28,9 +30,11 @@ local serviceMonitor(objname, name) =

local alert_rules =
kube._Object('monitoring.coreos.com/v1', 'PrometheusRule', 'argocd') {
metadata+: {
metadata: {
name: 'argocd',
namespace: params.namespace,
labels+: {
labels: {
name: 'argocd',
role: 'alert-rules',
} + params.monitoring.prometheus_rule_labels,
},
Expand Down Expand Up @@ -88,8 +92,12 @@ local alert_rules =

local grafana_dashboard =
kube._Object('integreatly.org/v1alpha1', 'GrafanaDashboard', 'argocd') {
metadata+: {
metadata: {
name: 'argocd',
namespace: params.namespace,
labels: {
name: 'argocd',
},
},
spec: {
name: 'argocd',
Expand Down
12 changes: 8 additions & 4 deletions component/rbac.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ local custom_resources = {

local aggregated_rbac = [
kube.ClusterRole('syn-argocd-view') {
metadata+: {
labels+: {
metadata: {
name: 'syn-argocd-view',
labels: {
name: 'syn-argocd-view',
'rbac.authorization.k8s.io/aggregate-to-admin': 'true',
'rbac.authorization.k8s.io/aggregate-to-edit': 'true',
'rbac.authorization.k8s.io/aggregate-to-view': 'true',
Expand All @@ -30,8 +32,10 @@ local aggregated_rbac = [
],
},
kube.ClusterRole('syn-argocd-edit') {
metadata+: {
labels+: {
metadata: {
name: 'syn-argocd-edit',
labels: {
name: 'syn-argocd-edit',
'rbac.authorization.k8s.io/aggregate-to-admin': 'true',
'rbac.authorization.k8s.io/aggregate-to-edit': 'true',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-metrics
app.kubernetes.io/part-of: argocd
Expand All @@ -20,7 +19,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-server-metrics
app.kubernetes.io/part-of: argocd
Expand All @@ -39,7 +37,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-repo-server
app.kubernetes.io/part-of: argocd
Expand All @@ -58,7 +55,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
annotations: {}
labels:
cluster_id: c-green-test-1234
monitoring.syn.tools/enabled: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: syn-argocd-edit
rbac.authorization.k8s.io/aggregate-to-admin: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: syn-argocd-view
rbac.authorization.k8s.io/aggregate-to-admin: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-metrics
app.kubernetes.io/part-of: argocd
Expand All @@ -20,7 +19,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-server-metrics
app.kubernetes.io/part-of: argocd
Expand All @@ -39,7 +37,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-repo-server
app.kubernetes.io/part-of: argocd
Expand All @@ -58,7 +55,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
annotations: {}
labels:
cluster_id: c-green-test-1234
monitoring.syn.tools/enabled: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: syn-argocd-edit
rbac.authorization.k8s.io/aggregate-to-admin: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: syn-argocd-view
rbac.authorization.k8s.io/aggregate-to-admin: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-metrics
app.kubernetes.io/part-of: argocd
Expand All @@ -19,7 +18,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-server-metrics
app.kubernetes.io/part-of: argocd
Expand All @@ -37,7 +35,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
annotations: {}
labels:
app.kubernetes.io/name: syn-argocd-repo-server
app.kubernetes.io/part-of: argocd
Expand All @@ -55,7 +52,6 @@ spec:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
annotations: {}
labels:
cluster_id: c-green-test-1234
name: argocd
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: syn-argocd-edit
rbac.authorization.k8s.io/aggregate-to-admin: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations: {}
labels:
name: syn-argocd-view
rbac.authorization.k8s.io/aggregate-to-admin: 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
annotations: {}
labels:
name: some-argocd
name: some-argocd
Expand Down Expand Up @@ -30,7 +29,6 @@ spec:
apiVersion: argoproj.io/v1beta1
kind: ArgoCD
metadata:
annotations: {}
labels:
name: foo
name: foo
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
annotations: {}
labels:
name: other-project
name: other-project
Expand All @@ -17,7 +16,6 @@ spec:
apiVersion: argoproj.io/v1alpha1
kind: AppProject
metadata:
annotations: {}
labels:
name: some-project
name: some-project
Expand Down

0 comments on commit 21112a4

Please sign in to comment.