Skip to content

Commit

Permalink
feat: update deployment on version change in CR (#119)
Browse files Browse the repository at this point in the history
* feat: first attempt at a simple overview dashboard

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

* feat: will roll out a new deployment on new version in the k8sgpt CR

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>

---------

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
AlexsJones committed May 24, 2023
1 parent 49fab66 commit 1bb8977
Show file tree
Hide file tree
Showing 2 changed files with 722 additions and 2 deletions.
20 changes: 18 additions & 2 deletions controllers/k8sgpt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,25 @@ func (r *K8sGPTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
}
}

// If the deployment is active, we will query it directly for analysis data
if deployment.Status.ReadyReplicas > 0 {
// Check if the client exists in the map

// 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 {
// Update the deployment image
deployment.Spec.Template.Spec.Containers[0].Image = fmt.Sprintf("%s:%s",
strings.Split(imageURI, ":")[0], k8sgptConfig.Spec.Version)
err = r.Update(ctx, &deployment)
if err != nil {
k8sgptReconcileErrorCount.Inc()
return r.finishReconcile(err, false)
}

return r.finishReconcile(nil, false)
}

// If the deployment is active, we will query it directly for analysis data
if _, ok := r.k8sGPTClients[k8sgptConfig.Name]; !ok {
// Create a new client
var address string
Expand Down
Loading

0 comments on commit 1bb8977

Please sign in to comment.