-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use the configured kubernetes dev service flavor instead of trying to detect it from the image #38154
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! The title of your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
...nt/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java
Outdated
Show resolved
Hide resolved
...nt/src/main/java/io/quarkus/kubernetes/client/deployment/DevServicesKubernetesProcessor.java
Outdated
Show resolved
Hide resolved
public Map<String, String> getKubeconfig() { | ||
var image = getContainerInfo().getConfig().getImage(); | ||
if (image.contains("rancher/k3s")) { | ||
return getKubernetesClientConfigFromKubeConfig( | ||
return switch (flavor) { | ||
case k3s -> getKubernetesClientConfigFromKubeConfig( | ||
KubeConfigUtils.parseKubeConfig(KubeConfigUtils.replaceServerInKubeconfig(containerAddress.getUrl(), | ||
getFileContentFromContainer(K3S_KUBECONFIG)))); | ||
} else if (image.contains("kindest/node")) { | ||
return getKubernetesClientConfigFromKubeConfig( | ||
case kind -> getKubernetesClientConfigFromKubeConfig( | ||
KubeConfigUtils.parseKubeConfig(KubeConfigUtils.replaceServerInKubeconfig(containerAddress.getUrl(), | ||
getFileContentFromContainer(KIND_KUBECONFIG)))); | ||
} else if (image.contains("k8s.gcr.io/kube-apiserver") || | ||
image.contains("registry.k8s.io/kube-apiserver")) { | ||
return getKubernetesClientConfigFromKubeConfig(getKubeconfigFromApiContainer(containerAddress.getUrl())); | ||
} | ||
|
||
// this can happen only if the user manually start | ||
// a DEV_SERVICE_LABEL labeled container with an invalid image name | ||
throw new RuntimeException("The container with the label '" + DEV_SERVICE_LABEL | ||
+ "' is not compatible with Dev Services for Kubernetes. Stop it or disable Dev Services for Kubernetes."); | ||
case api_only -> | ||
getKubernetesClientConfigFromKubeConfig(getKubeconfigFromApiContainer(containerAddress.getUrl())); | ||
default -> throw new RuntimeException("The container with the label '" + DEV_SERVICE_LABEL | ||
+ "' is not compatible with Dev Services for Kubernetes. Stop it or disable Dev Services for Kubernetes."); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use Java 17 language flavors in existing code, as it makes backports hard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time has passed and I think we are now fine with it as I don't expect us to backport this to 3.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense
Thanks a lot for the contribution! I added some small comments |
I should also note that when the issues are addressed, we'll need the commits to be squashed |
Can you please squash the commits and rebase onto the latest main? Thanks |
Instead of trying to detect it from the image. Fixes quarkusio#38152
@geoand I rebased/squashed and fixed the formatting. I let you review if things are all good for you as I haven't checked the rationale of this patch. |
I have to admit I am struggling to understand the change. @metacosm you know more about this so maybe you can chime in |
Status for workflow
|
Fixes #38152