mirror of
https://github.com/lukaszraczylo/kubernetes-images-sync-operator.git
synced 2026-06-05 22:53:39 +00:00
fixup! fixup! fixup! fixup! fixup! General improvements
This commit is contained in:
+2
-2
@@ -10,9 +10,9 @@ description: |
|
||||
|
||||
type: application
|
||||
|
||||
version: 0.2.29
|
||||
version: 0.2.30
|
||||
|
||||
appVersion: "0.2.29"
|
||||
appVersion: "0.2.30"
|
||||
|
||||
home: https://github.com/lukaszraczylo/kubernetes-images-sync-operator
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ sa:
|
||||
- ALL
|
||||
image:
|
||||
repository: ghcr.io/lukaszraczylo/kubernetes-images-sync-operator
|
||||
tag: 0.2.29
|
||||
tag: 0.2.30
|
||||
resources:
|
||||
limits:
|
||||
cpu: 500m
|
||||
|
||||
+24
-2
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"flag"
|
||||
"os"
|
||||
@@ -25,7 +26,9 @@ import (
|
||||
// to ensure that exec-entrypoint and run can make use of them.
|
||||
_ "k8s.io/client-go/plugin/pkg/client/auth"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
@@ -150,10 +153,29 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err = (&raczylocomcontroller.ClusterImageExportReconciler{
|
||||
// Get controller pod annotations
|
||||
ctx := context.Background()
|
||||
podName := os.Getenv("POD_NAME")
|
||||
podNamespace := os.Getenv("POD_NAMESPACE")
|
||||
var podAnnotations map[string]string
|
||||
if podName != "" && podNamespace != "" {
|
||||
pod := &corev1.Pod{}
|
||||
if err := mgr.GetAPIReader().Get(ctx, types.NamespacedName{
|
||||
Name: podName,
|
||||
Namespace: podNamespace,
|
||||
}, pod); err == nil {
|
||||
podAnnotations = pod.Annotations
|
||||
} else {
|
||||
setupLog.Error(err, "unable to get controller pod annotations")
|
||||
}
|
||||
}
|
||||
|
||||
exportController := &raczylocomcontroller.ClusterImageExportReconciler{
|
||||
Client: mgr.GetClient(),
|
||||
Scheme: mgr.GetScheme(),
|
||||
}).SetupWithManager(mgr); err != nil {
|
||||
}
|
||||
exportController.InjectPodAnnotations(podAnnotations)
|
||||
if err = exportController.SetupWithManager(mgr); err != nil {
|
||||
setupLog.Error(err, "unable to create controller", "controller", "ClusterImageExport")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ import (
|
||||
type ClusterImageExportReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
podAnnotations map[string]string
|
||||
}
|
||||
|
||||
func (r *ClusterImageExportReconciler) InjectPodAnnotations(annotations map[string]string) {
|
||||
r.podAnnotations = annotations
|
||||
}
|
||||
|
||||
// +kubebuilder:rbac:groups=raczylo.com,resources=*,verbs=get;list;watch;create;update;patch;delete
|
||||
@@ -320,12 +325,21 @@ func (r *ClusterImageExportReconciler) runCleanupJob(ctx context.Context, cluste
|
||||
backoffLimit := int32(2) // 3 total attempts (initial + 2 retries)
|
||||
ttlSecondsAfterFinished := int32(30) // Delete job 30 seconds after completion
|
||||
|
||||
// Merge controller pod annotations with job annotations
|
||||
mergedAnnotations := make(map[string]string)
|
||||
for k, v := range r.podAnnotations {
|
||||
mergedAnnotations[k] = v
|
||||
}
|
||||
for k, v := range clusterImageExport.Spec.JobAnnotations {
|
||||
mergedAnnotations[k] = v
|
||||
}
|
||||
|
||||
jobParams := shared.JobParams{
|
||||
Name: normalisedImageName,
|
||||
Namespace: clusterImageExport.Namespace,
|
||||
Image: shared.BACKUP_JOB_IMAGE,
|
||||
Commands: defaultCommands,
|
||||
Annotations: clusterImageExport.Spec.JobAnnotations,
|
||||
Annotations: mergedAnnotations,
|
||||
ServiceAccount: "",
|
||||
ImagePullSecrets: clusterImageExport.Spec.ImagePullSecrets,
|
||||
BackoffLimit: &backoffLimit,
|
||||
|
||||
Reference in New Issue
Block a user