Commit 44f52017 authored by 黎博's avatar 黎博

Merge branch 'master' into k8s

parents 718daf2f c3656c97
......@@ -131,6 +131,9 @@ public class K8sController {
case "redis":
k8sService.createRedisService(namespace);
break;
case "redis5":
k8sService.createRedis5Service(namespace);
break;
case "redis-sentinel":
k8sService.createRedisSentinelService(namespace);
break;
......@@ -175,6 +178,9 @@ public class K8sController {
case "redis":
k8sService.createRedisDeployment(namespace, image);
break;
case "redis5":
k8sService.createRedis5Deployment(namespace, image);
break;
case "redis-sentinel":
k8sService.createRedisSentinelDeployment(namespace, image);
break;
......
......@@ -991,6 +991,53 @@ public class K8sService {
return kubernetesClient.services().inNamespace(namespace).create(redisService);
}
public Service createRedis5Service(String namespace) {
Service redisService = new Service();
ObjectMeta objectMeta = buildObjectMeta(namespace, "redis5", "base");
ServiceSpec serviceSpec = new ServiceSpec();
// 设置spec
List<ServicePort> portList = new ArrayList<>();
ServicePort servicePort1 = new ServicePort();
ServicePort servicePort2 = new ServicePort();
ServicePort servicePort3 = new ServicePort();
ServicePort servicePort4 = new ServicePort();
ServicePort servicePort5 = new ServicePort();
servicePort1.setName("6379");
servicePort1.setPort(6379);
servicePort2.setName("6380");
servicePort2.setPort(6380);
servicePort3.setName("6381");
servicePort3.setPort(6381);
servicePort4.setName("6382");
servicePort4.setPort(6382);
servicePort5.setName("6383");
servicePort5.setPort(6383);
portList.add(servicePort1);
portList.add(servicePort2);
portList.add(servicePort3);
portList.add(servicePort4);
portList.add(servicePort5);
Map<String, String> selector = new HashMap<>();
selector.put("qcloud-app", "redis5");
// 设置serviceSpec
serviceSpec.setType("NodePort");
serviceSpec.setPorts(portList);
serviceSpec.setSelector(selector);
// 设置service
redisService.setApiVersion("v1");
redisService.setKind("Service");
redisService.setMetadata(objectMeta);
redisService.setSpec(serviceSpec);
log.info("开始创建redis5 Service: {}", redisService.toString());
return kubernetesClient.services().inNamespace(namespace).create(redisService);
}
/**
* 创建redis container
*
......@@ -1174,6 +1221,82 @@ public class K8sService {
return kubernetesClient.apps().deployments().inNamespace(namespace).create(redisSentinelDeployment);
}
/**
* 创建redis5 deployment
*
* @param namespace
* @param image
* @return
*/
public Deployment createRedis5Deployment(String namespace, String image) {
Deployment redisDeployment = new Deployment();
// 设置meta
ObjectMeta objectMeta = buildObjectMeta(namespace, "redis5", "base");
// 设置spec
DeploymentSpec deploymentSpec = new DeploymentSpec();
// 设置labelSelector
LabelSelector labelSelector = new LabelSelector();
Map<String, String> matchLabels = new HashMap<>();
matchLabels.put("qcloud-app", "redis5");
labelSelector.setMatchLabels(matchLabels);
// 设置strategy
DeploymentStrategy deploymentStrategy = new DeploymentStrategy();
deploymentStrategy.setType("Recreate");
// 设置pod Template
PodTemplateSpec podTemplateSpec = new PodTemplateSpec();
PodSpec podSpec = new PodSpec();
List<Container> containerList = new ArrayList<>();
Container container1 = createRedisContainer(image, "6379");
Container container2 = createRedisContainer(image, "6380");
Container container3 = createRedisContainer(image, "6381");
Container container4 = createRedisContainer(image, "6382");
Container container5 = createRedisContainer(image, "6383");
containerList.add(container1);
containerList.add(container2);
containerList.add(container3);
containerList.add(container4);
containerList.add(container5);
// imagePullSecrets
List<LocalObjectReference> imagePullSecrets = buildImagePullSecrets();
podSpec.setContainers(containerList);
podSpec.setDnsPolicy("ClusterFirst");
podSpec.setImagePullSecrets(imagePullSecrets);
podSpec.setRestartPolicy("Always");
podSpec.setTerminationGracePeriodSeconds(30L);
// 设置PodTemplateSpec
podTemplateSpec.setMetadata(objectMeta);
podTemplateSpec.setSpec(podSpec);
// 设置Deployment Spec
deploymentSpec.setReplicas(1);
deploymentSpec.setRevisionHistoryLimit(1);
deploymentSpec.setStrategy(deploymentStrategy);
deploymentSpec.setTemplate(podTemplateSpec);
deploymentSpec.setSelector(labelSelector);
DeploymentStatus deploymentStatus = new DeploymentStatus();
// deployment设置
redisDeployment.setApiVersion("apps/v1");
redisDeployment.setKind("Deployment");
redisDeployment.setMetadata(objectMeta);
redisDeployment.setSpec(deploymentSpec);
redisDeployment.setStatus(deploymentStatus);
log.info("创建redis5 Deployment:{}", redisDeployment);
return kubernetesClient.apps().deployments().inNamespace(namespace).create(redisDeployment);
}
/**
* redis哨兵模式 Service
* @param namespace
......
......@@ -317,8 +317,13 @@ public class DingdingUtils {
public static String buildDailyProdBugNotifyMsg(Iterable<Issue> issues) {
String title = "线上未解决工单统计";
String content = "📣线上未解决工单统计:" + "\n\n";
int count = 0;
List<Issue> issueList = new ArrayList<>();
for (Issue issue: issues) {
issueList.add(issue);
}
if (issueList.size() > 0) {
int count = 0;
for (Issue issue: issueList) {
count = count + 1;
String issueUrl = "http://jira2.quantgroup.cn/browse/" + issue.getKey();
content = content + count + "、[" + issue.getSummary().replace("\"", "") + "](" + issueUrl + ")\n";
......@@ -337,6 +342,10 @@ public class DingdingUtils {
content += "- 持续时间:" + duration + "小时\n\n";
}
content += "**截止当前,共有" + String.valueOf(count) + "个工单未解决,请对应经办人尽快跟进解决**";
}
if (issueList.size() == 0) {
content += "**截止当前,所有工单都已经解决完毕,产研小伙伴最给力了👍🏻**";
}
return buildMarkdownMsg(title, content, true);
}
......
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