Commit a941e5ad authored by 黎博's avatar 黎博

新增删除namespace list接口

parent 1762e363
...@@ -717,4 +717,17 @@ public class K8sController { ...@@ -717,4 +717,17 @@ public class K8sController {
resultMap.put("success", true); resultMap.put("success", true);
return resultMap; return resultMap;
} }
/**
* 删除namespace缓存
* @return
*/
@GetMapping("/clearNsCache")
public JsonResult clearNamespaceListCache() {
boolean clearCacheResult = k8sService.deleteNamespaceListCache();
if (clearCacheResult) {
return JsonResult.buildSuccessResult("Namespace列表缓存删除成功!", true);
}
return JsonResult.buildErrorStateResult("Namespace列表缓存删除失败!", false);
}
} }
...@@ -2334,6 +2334,31 @@ public class K8sService { ...@@ -2334,6 +2334,31 @@ public class K8sService {
return envMap; return envMap;
} }
/**
* 删除namespace列表缓存
*/
public boolean deleteNamespaceListCache() {
try {
String NS_PREFIX = "k8s:namespace:";
if (redisUtils.get(NS_PREFIX + "all") != null) {
log.info("删除所有环境列表缓存!");
redisUtils.del(NS_PREFIX + "all");
}
if (redisUtils.get(NS_PREFIX + "dev") != null) {
log.info("删除开发环境列表缓存!");
redisUtils.del(NS_PREFIX + "dev");
}
if (redisUtils.get(NS_PREFIX + "test") != null) {
log.info("删除测试环境列表缓存!");
redisUtils.del(NS_PREFIX + "test");
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public void podTest() { public void podTest() {
Map<String, String> labels = new HashMap<>(); Map<String, String> labels = new HashMap<>();
labels.put("qcloud-app", "cherry-ui"); labels.put("qcloud-app", "cherry-ui");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment