Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 committed Dec 21, 2024
1 parent a5564fb commit 3bb163d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ final class FixedPortsK3sContainer extends K3sContainer {
* Command to use when starting rancher. Without "server" option, traefik is not
* installed
*/
private static final String RANCHER_COMMAND = "server";
private static final String RANCHER_COMMAND = "server --disable=metric-server";

static final K3sContainer CONTAINER = new FixedPortsK3sContainer(DockerImageName.parse(RANCHER_VERSION))
.configureFixedPorts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;

import io.fabric8.kubernetes.api.model.APIService;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.api.model.Pod;
Expand Down Expand Up @@ -210,6 +211,21 @@ public void createNamespace(String name) {

public void deleteNamespace(String name) {
try {

// sometimes we get errors like :

// "message": "Discovery failed for some groups,
// 1 failing: unable to retrieve the complete list of server APIs:
// metrics.k8s.io/v1beta1: stale GroupVersion discovery: metrics.k8s.io/v1beta1"

// but even when it works OK, the finalizers are slowing down the deletion
List<APIService> apiServices = client.apiServices().list().getItems();
apiServices.stream()
.map(apiService -> apiService.getMetadata().getName())
.filter(apiServiceName -> apiServiceName.contains("metrics.k8s.io"))
.findFirst()
.ifPresent(apiServiceName -> client.apiServices().withName(apiServiceName).delete());

client.namespaces()
.resource(new NamespaceBuilder().withNewMetadata().withName(name).and().build())
.delete();
Expand Down

0 comments on commit 3bb163d

Please sign in to comment.