Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] starting operator deployment #4

Merged
merged 1 commit into from
May 28, 2024

Conversation

nicolastakashi
Copy link
Collaborator

@nicolastakashi nicolastakashi commented May 14, 2024

I'm adding the foundations to deploy the operator manifests, it's working but at the moment it requires you manually apply the crds to the cluster.

I'll do the crds installation automatically in a up coming pr.

@nicolastakashi nicolastakashi force-pushed the chore/adding-k8s-client branch from fade119 to 2586048 Compare May 15, 2024 23:04
@nicolastakashi nicolastakashi requested review from ArthurSens and simonpasquier and removed request for ArthurSens and simonpasquier May 15, 2024 23:05
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wohoo, exciting to see progress here 🥳

Just have a few comments, but it looks almost ready

"k8s.io/client-go/tools/clientcmd"
)

func NewPrometheusOperatorV1(logger *slog.Logger, kubeConfig string) (*opClientv1.MonitoringV1Client, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this? Can't we reuse the client code from the operator repository?

Here's a code snippet showing how we use today:

https://github.com/prometheus-operator/prometheus-operator/blob/35340a6c4a97a9e6899f3d0319f6c47f781c2062/pkg/prometheus/server/operator.go#L111-L114

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a similar note, I'm also not sure if extra code is needed to set up a k8s client 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you were mentining this code snippet to create the k8s clientset and not the po client set right?

For the Prometheus ClientSet it's almost the same thing, the different is only the way we're building the rest.Config object.
The operator is expecting the API Server Address and here I'm reading a kubeconfig file where the user que provide one or we can discovery it automatically.

Regarding the Prometheus Operator ClientSet I don't see other way to do that, since we have two different client, one for v1 and other for alpha1, maybe I'm missing something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I meant both clients actually.

We already have abstractions to create both Kubernetes and Monitoring clients inside prometheus-operator codebase. I don't think we need this internal package here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok!
I'll review it carefully next week 🫶

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArthurSens I just open a PR on the operator doing the changes to allow use the NewClusterConfig function, meanwhile I changed the code to create the rest config on the poctl and use the clientset as you show in the example.

Do you think we can merge it and fix the TODO after the operator merge the changes?

cmd/stack.go Outdated Show resolved Hide resolved
@ArthurSens ArthurSens mentioned this pull request May 17, 2024
@nicolastakashi nicolastakashi force-pushed the chore/adding-k8s-client branch from 2586048 to dcc3aa1 Compare May 27, 2024 19:31
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
@nicolastakashi nicolastakashi force-pushed the chore/adding-k8s-client branch from dcc3aa1 to 537dbea Compare May 27, 2024 20:21
@nicolastakashi nicolastakashi requested a review from ArthurSens May 28, 2024 19:06
@nicolastakashi nicolastakashi merged commit 6ed20ab into main May 28, 2024
4 checks passed
@nicolastakashi nicolastakashi deleted the chore/adding-k8s-client branch May 28, 2024 19:49
Comment on lines +52 to +55
if err != nil {
logger.With("error", err.Error()).Error("error while getting kubeconfig")
os.Exit(1)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolastakashi, noticed just now 😬

The err handling here is duplicated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix in a following PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants