[Bug]: Wrong deployment image processing
ultram4rine opened this issue · 2 comments
Checklist
- I've searched for similar issues and couldn't find anything matching
- I've included steps to reproduce the behavior
Affected Components
- K8sGPT (CLI)
- K8sGPT Operator
K8sGPT Version
v0.3.8
Kubernetes Version
v1.28.0
Host OS and its Version
No response
Steps to reproduce
Include port in repository in K8sGPT
object like <host>:<port>/<path>/<image>
.
Expected behaviour
Operator will create a deployment with normal image.
Actual behaviour
Operator will turn image in <host>:<tag>
, thus result into ImagePullBackOff
.
Additional Information
I've found the lines were this happens:
k8sgpt-operator/controllers/k8sgpt_controller.go
Lines 168 to 180 in db04fbd
Quick solution is to parse image like this:
image := strings.Split(imageURI, ":")
if len(image) == 2 {
imageRepository = image[0]
imageVersion = image[1]
} else {
imageRepository = fmt.Sprintf("%s:%s", image[0], image[1])
imageVersion = image[2]
}
or
image := strings.Split(imageURI, ":")
imageRepository := strings.Join(image[0:len(image)-1], ":")
imageVersion := image[len(image)-1]
Possible better solution is to use maybe net/url
or some other lib.
Btw, what is going on here:
k8sgpt-operator/controllers/k8sgpt_controller.go
Lines 175 to 179 in db04fbd
If image repo is not the same as in K8sGPT
CRD, it leaves it as is and updates only version.
Maybe it should update image repo to k8sgptConfig.Spec.Repository
?
Btw, what is going on here:
k8sgpt-operator/controllers/k8sgpt_controller.go
Lines 175 to 179 in db04fbd
If image repo is not the same as in
K8sGPT
CRD, it leaves it as is and updates only version.Maybe it should update image repo to
k8sgptConfig.Spec.Repository
?
yes that looks wrong 👍