Skip to content

Commit

Permalink
modify endpoint operator
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <chuyang@redhat.com>
  • Loading branch information
clyang82 committed Feb 6, 2024
1 parent 80495be commit b47a261
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
7 changes: 2 additions & 5 deletions operators/endpointmetrics/pkg/util/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ var (
)

var (
log = ctrl.Log.WithName("util")
)

const (
hubKubeConfigPath = "/spoke/hub-kubeconfig/kubeconfig"
log = ctrl.Log.WithName("util")
hubKubeConfigPath = os.Getenv("HUB_KUBECONFIG")
)

// GetOrCreateOCPClient get an existing hub client or create new one if it doesn't exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,16 @@ func createManifestWorks(

log.Info(fmt.Sprintf("Cluster: %+v, Spec.NodeSelector (after): %+v", clusterName, spec.NodeSelector))
log.Info(fmt.Sprintf("Cluster: %+v, Spec.Tolerations (after): %+v", clusterName, spec.Tolerations))
if clusterName != clusterNamespace {
spec.Volumes = []corev1.Volume{}
spec.Containers[0].VolumeMounts = []corev1.VolumeMount{}
for i, env := range spec.Containers[0].Env {
if env.Name == "HUB_KUBECONFIG" {
spec.Containers[0].Env[i].Value = ""
break
}
}
}
dep.Spec.Template.Spec = spec
manifests = injectIntoWork(manifests, dep)
// replace the pull secret and addon components image
Expand Down Expand Up @@ -436,9 +446,11 @@ func createManifestWorks(

func createUpdateResources(c client.Client, manifests []workv1.Manifest) error {
for _, manifest := range manifests {
err := c.Create(context.TODO(), manifest.RawExtension.Object.(client.Object))
obj := manifest.RawExtension.Object.(client.Object)
obj.SetNamespace(config.GetDefaultNamespace())
err := c.Create(context.TODO(), obj)
if err != nil && !k8serrors.IsAlreadyExists(err) {
log.Error(err, "Failed to create resource", "kind", manifest.RawExtension.Object.GetObjectKind().GroupVersionKind().Kind)
log.Error(err, "Failed to create resource", "kind", obj.GetObjectKind().GroupVersionKind().Kind)
return err
}
}
Expand Down

0 comments on commit b47a261

Please sign in to comment.