Skip to content

Commit

Permalink
fix: apply workload annotations to pod specs
Browse files Browse the repository at this point in the history
Signed-off-by: Suleyman Akbas <sakbas@redhat.com>
  • Loading branch information
suleymanakbas91 committed Dec 11, 2023
1 parent ffdeabc commit 2baabe2
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 31 deletions.
1 change: 0 additions & 1 deletion bundle/manifests/lvms-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ metadata:
"lvmvolumegroups.lvm.topolvm.io", "lvmvolumegroupnodestatuses.lvm.topolvm.io"]'
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/openshift/lvm-operator
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
operatorframework.io/arch.amd64: supported
operatorframework.io/arch.arm64: supported
Expand Down
2 changes: 0 additions & 2 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ kind: Deployment
metadata:
name: operator
namespace: system
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions config/default/manager_config_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ kind: Deployment
metadata:
name: controller-manager
namespace: system
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions config/default/manager_custom_env.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ kind: Deployment
metadata:
name: operator
namespace: system
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions config/default/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ kind: Deployment
metadata:
name: operator
namespace: system
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
template:
spec:
Expand Down
2 changes: 0 additions & 2 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ kind: Deployment
metadata:
name: operator
namespace: system
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
app.kubernetes.io/name: lvms-operator
spec:
Expand Down
1 change: 0 additions & 1 deletion config/manifests/bases/clusterserviceversion.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ metadata:
operators.openshift.io/infrastructure-features: '["disconnected"]'
operators.openshift.io/valid-subscription: '["OpenShift Container Platform", "OpenShift Platform Plus"]'
operators.operatorframework.io/internal-objects: '["logicalvolumes.topolvm.io", "lvmvolumegroups.lvm.topolvm.io", "lvmvolumegroupnodestatuses.lvm.topolvm.io"]'
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
operatorframework.io/arch.amd64: supported
operatorframework.io/arch.arm64: supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ metadata:
operators.openshift.io/infrastructure-features: '["disconnected"]'
operators.openshift.io/valid-subscription: '["OpenShift Container Platform", "OpenShift Platform Plus"]'
operators.operatorframework.io/internal-objects: '["logicalvolumes.topolvm.io", "lvmvolumegroups.lvm.topolvm.io", "lvmvolumegroupnodestatuses.lvm.topolvm.io"]'
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
operatorframework.io/arch.amd64: supported
operatorframework.io/arch.arm64: supported
Expand Down
19 changes: 12 additions & 7 deletions controllers/topolvm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func (c topolvmController) setTopolvmControllerDesiredState(existing, desired *a
existing.ObjectMeta.Annotations[key] = value
}

initMapIfNil(&existing.Spec.Template.Annotations)
for key, value := range desired.Spec.Template.Annotations {
existing.Spec.Template.Annotations[key] = value
}

return nil
}

Expand Down Expand Up @@ -162,10 +167,9 @@ func getControllerDeployment(lvmCluster *lvmv1alpha1.LVMCluster, namespace strin

controllerDeployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: TopolvmControllerDeploymentName,
Namespace: namespace,
Annotations: annotations,
Labels: labels,
Name: TopolvmControllerDeploymentName,
Namespace: namespace,
Labels: labels,
},
Spec: appsv1.DeploymentSpec{
Replicas: &replicas,
Expand All @@ -174,9 +178,10 @@ func getControllerDeployment(lvmCluster *lvmv1alpha1.LVMCluster, namespace strin
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: TopolvmControllerDeploymentName,
Namespace: namespace,
Labels: labels,
Name: TopolvmControllerDeploymentName,
Namespace: namespace,
Annotations: annotations,
Labels: labels,
},
Spec: corev1.PodSpec{
InitContainers: initContainers,
Expand Down
17 changes: 11 additions & 6 deletions controllers/topolvm_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ func (n topolvmNode) ensureCreated(r *LVMClusterReconciler, ctx context.Context,
ds.ObjectMeta.Annotations[key] = value
}

initMapIfNil(&ds.Spec.Template.Annotations)
for key, value := range dsTemplate.Spec.Template.Annotations {
ds.Spec.Template.Annotations[key] = value
}

return nil
})

Expand Down Expand Up @@ -194,10 +199,9 @@ func getNodeDaemonSet(lvmCluster *lvmv1alpha1.LVMCluster, namespace string, init
}
nodeDaemonSet := &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: TopolvmNodeDaemonsetName,
Namespace: namespace,
Annotations: annotations,
Labels: labels,
Name: TopolvmNodeDaemonsetName,
Namespace: namespace,
Labels: labels,
},
Spec: appsv1.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
Expand All @@ -206,8 +210,9 @@ func getNodeDaemonSet(lvmCluster *lvmv1alpha1.LVMCluster, namespace string, init
},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: lvmCluster.Name,
Labels: labels,
Name: lvmCluster.Name,
Annotations: annotations,
Labels: labels,
},
Spec: corev1.PodSpec{
ServiceAccountName: TopolvmNodeServiceAccount,
Expand Down
5 changes: 5 additions & 0 deletions controllers/vgmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func (v vgManager) ensureCreated(r *LVMClusterReconciler, ctx context.Context, l
ds.ObjectMeta.Annotations[key] = value
}

initMapIfNil(&ds.Spec.Template.Annotations)
for key, value := range dsTemplate.Spec.Template.Annotations {
ds.Spec.Template.Annotations[key] = value
}

// containers
ds.Spec.Template.Spec.Containers = dsTemplate.Spec.Template.Spec.Containers

Expand Down
10 changes: 5 additions & 5 deletions controllers/vgmanager_daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,16 @@ func newVGManagerDaemonset(lvmCluster *lvmv1alpha1.LVMCluster, namespace string,
}
ds := appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: VGManagerUnit,
Namespace: namespace,
Annotations: annotations,
Labels: labels,
Name: VGManagerUnit,
Namespace: namespace,
Labels: labels,
},
Spec: appsv1.DaemonSetSpec{
Selector: &metav1.LabelSelector{MatchLabels: labels},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: labels,
Annotations: annotations,
Labels: labels,
},

Spec: corev1.PodSpec{
Expand Down

0 comments on commit 2baabe2

Please sign in to comment.