Skip to content

Commit

Permalink
feat: remove hardcoded k8sgpt image repository
Browse files Browse the repository at this point in the history
Signed-off-by: JuHyung-Son <[email protected]>
  • Loading branch information
JuHyung-Son committed Nov 21, 2023
1 parent 0898941 commit cf9387a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions controllers/k8sgpt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ func (r *K8sGPTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr

// Check the version of the deployment image matches the version set in the K8sGPT CR
imageURI := deployment.Spec.Template.Spec.Containers[0].Image
imageVersion := strings.Split(imageURI, ":")[1]
if imageVersion != k8sgptConfig.Spec.Version {
imageTag := strings.Split(imageURI, ":")[1]
if imageTag != k8sgptConfig.Spec.Image.Tag {
// Update the deployment image
deployment.Spec.Template.Spec.Containers[0].Image = fmt.Sprintf("%s:%s",
strings.Split(imageURI, ":")[0], k8sgptConfig.Spec.Version)
strings.Split(imageURI, ":")[0], k8sgptConfig.Spec.Image.Tag)
err = r.Update(ctx, &deployment)
if err != nil {
k8sgptReconcileErrorCount.Inc()
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/k8sgpt.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func GetDeployment(config v1alpha1.K8sGPT) (*appsv1.Deployment, error) {
{
Name: "k8sgpt",
ImagePullPolicy: corev1.PullAlways,
Image: "ghcr.io/k8sgpt-ai/k8sgpt:" + config.Spec.Version,
Image: config.Spec.Image.Repository + ":" + config.Spec.Image.Tag,
Args: []string{
"serve",
},
Expand Down

0 comments on commit cf9387a

Please sign in to comment.