diff --git a/agent-go/k8s_exec/CmiiK8sOperator_test.go b/agent-go/k8s_exec/CmiiK8sOperator_test.go index 3594544..10bf65f 100644 --- a/agent-go/k8s_exec/CmiiK8sOperator_test.go +++ b/agent-go/k8s_exec/CmiiK8sOperator_test.go @@ -49,12 +49,16 @@ func TestBackupAllCmiiDeploymentToMap(t *testing.T) { func TestUpdateCmiiDeploymentImageTag(t *testing.T) { - //tag := UpdateCmiiDeploymentImageTag("devflight", "cmii-uav-depotautoreturn", "123sdsa45678") - //tag := UpdateCmiiDeploymentImageTag("demo", "cmii-uav-platform", "5.2.0-011101") - tag := UpdateCmiiDeploymentImageTag("demo", "cmii-uav-waypoint", "5.2.0-011102") - //tag := UpdateCmiiDeploymentImageTag("uavms", "uavms-lowaltitude-platform", "5.1.0-011103") + cmiiEnv := "uavms" + appName := "uavms-lowaltitude-platform" + newTag := "5.2.0-011202" + tag := UpdateCmiiDeploymentImageTag(cmiiEnv, appName, newTag) assert.Equal(t, tag, true, "update image tag failed !") + + check := CmiiOperator.DeploymentStatusCheck(cmiiEnv, appName, 180) + assert.Equal(t, check, true, "deployment run failed!") + } func TestRollBackCmiiDeploymentFromUpdateLog(t *testing.T) { @@ -65,7 +69,7 @@ func TestRollBackCmiiDeploymentFromUpdateLog(t *testing.T) { func TestRestartCmiiBackendDeployment(t *testing.T) { - RestartCmiiBackendDeployment("devflight") + RestartCmiiBackendDeployment("test") } func TestRestartCmiiFrontendDeployment(t *testing.T) { @@ -96,7 +100,7 @@ func TestFindAllNodeNotHealthy(t *testing.T) { } func TestFindPodNotHealthy(t *testing.T) { - podNotHealthy := FindPodNotHealthy("int") + podNotHealthy := FindPodNotHealthy("valida") podNotHealthy = FilterAllCmiiPodSoft(podNotHealthy) for _, podInterface := range podNotHealthy { @@ -105,7 +109,7 @@ func TestFindPodNotHealthy(t *testing.T) { } func TestFindPodNotHealthy_And_Delete(t *testing.T) { - podNotHealthy := FindPodNotHealthy("int") + podNotHealthy := FindPodNotHealthy("uavms") podNotHealthy = FilterAllCmiiPodSoft(podNotHealthy) for _, podInterface := range podNotHealthy { diff --git a/agent-go/k8s_exec/K8sOperator.go b/agent-go/k8s_exec/K8sOperator.go index 5b91b8a..9fd9167 100644 --- a/agent-go/k8s_exec/K8sOperator.go +++ b/agent-go/k8s_exec/K8sOperator.go @@ -301,39 +301,37 @@ func (op *CmiiK8sOperator) DeploymentOneInterface(cmiiEnv, appName string) (depl return &convert } -func (op *CmiiK8sOperator) DeploymentScale(cmiiEnv, appFizz string, scaleCount int32) bool { +func (op *CmiiK8sOperator) DeploymentScale(cmiiEnv, appName string, scaleCount int32) bool { - deploymentFizz := op.DeploymentFizz(cmiiEnv, appFizz) + deployment := op.DeploymentOneInterface(cmiiEnv, appName) client := op.CurrentClient - for _, deployment := range deploymentFizz { - log.DebugF("[DeploymentScale] - start to scale [%s] [%s] to %d", deployment.Namespace, deployment.Name, scaleCount) + log.DebugF("[DeploymentScale] - start to scale [%s] [%s] to %d", deployment.Namespace, deployment.Name, scaleCount) - scale := &autoscalingv1.Scale{ - ObjectMeta: metav1.ObjectMeta{ - Name: deployment.Name, - Namespace: deployment.Namespace, - }, - Spec: autoscalingv1.ScaleSpec{ - Replicas: scaleCount, - }, - } - - updateScale, err := client.AppsV1().Deployments(deployment.Namespace).UpdateScale( - context.TODO(), - deployment.Name, - scale, - metav1.UpdateOptions{}, - ) - if err != nil { - log.ErrorF("[DeploymentScale] - scale error %s", err.Error()) - return false - } - - log.InfoF("[DeploymentScale] - scale of [%s] [%s] to %d success !", updateScale.Namespace, updateScale.Name, scaleCount) + scale := &autoscalingv1.Scale{ + ObjectMeta: metav1.ObjectMeta{ + Name: deployment.Name, + Namespace: deployment.Namespace, + }, + Spec: autoscalingv1.ScaleSpec{ + Replicas: scaleCount, + }, } + updateScale, err := client.AppsV1().Deployments(deployment.Namespace).UpdateScale( + context.TODO(), + deployment.Name, + scale, + metav1.UpdateOptions{}, + ) + if err != nil { + log.ErrorF("[DeploymentScale] - scale error %s", err.Error()) + return false + } + + log.InfoF("[DeploymentScale] - scale of [%s] [%s] to %d success !", updateScale.Namespace, updateScale.Name, scaleCount) + return true } @@ -396,20 +394,76 @@ func (op *CmiiK8sOperator) DeploymentRestart(cmiiEnv, appName string) bool { return result } -func (op *CmiiK8sOperator) ReplicaSet(cmiiEnv, replicaSetName string) *v1.ReplicaSet { +func (op *CmiiK8sOperator) DeploymentStatusCheck(cmiiEnv, appName string, waitTimeOut int) bool { op.changeOperatorEnv(cmiiEnv) + // 设置超时时间和时间间隔 + timeout := time.After(time.Duration(waitTimeOut) * time.Second) + tick := time.Tick(2 * time.Second) + + // 监控Pod状态 + for { + select { + case <-timeout: + log.ErrorF("[DeploymentStatusCheck] - [%s] [%s] 状态: 失败!", cmiiEnv, appName) + return false + case <-tick: + // check deployment exists + deployment := op.DeploymentOneInterface(cmiiEnv, appName) + if deployment == nil { + log.ErrorF("[DeploymentStatusCheck] - [%s] [%s] not exists !", cmiiEnv, appName) + return false + } + if deployment.AvailableReplicas == deployment.Replicas { + log.InfoF("[DeploymentStatusCheck] - [%s] [%s] Available: %d, Total: %d success !", cmiiEnv, appName, deployment.AvailableReplicas, deployment.Replicas) + return true + } + + log.DebugF("[DeploymentStatusCheck] - [%s] [%s] Available: %d, Total: %d waiting !", cmiiEnv, appName, deployment.AvailableReplicas, deployment.Replicas) + } + } +} + +func (op *CmiiK8sOperator) ReplicaSetExists(cmiiEnv, replicaSetName string) *v1.ReplicaSet { + + op.changeOperatorEnv(cmiiEnv) client := op.CurrentClient replicaSet, err := client.AppsV1().ReplicaSets(op.CurrentNamespace).Get(context.TODO(), replicaSetName, metav1.GetOptions{}) if err != nil { + log.ErrorF("[ReplicaSetExists] - [%s] [%s] not exists !", cmiiEnv, replicaSetName) return nil } return replicaSet } +func (op *CmiiK8sOperator) ReplicaSetByAppName(cmiiEnv, appName string) (replicaList []v1.ReplicaSet) { + deploy := op.DeploymentExist(cmiiEnv, appName) + if deploy == nil { + log.ErrorF("[ReplicaSetByAppName] - [%s] [%s] app not exists !", cmiiEnv, appName) + return nil + } + + labelSelector := metav1.FormatLabelSelector(deploy.Spec.Selector) + //Get the replica sets that belong to the deployment. + replicaSets, err := op.CurrentClient.AppsV1().ReplicaSets(op.CurrentNamespace).List(context.TODO(), metav1.ListOptions{ + LabelSelector: labelSelector, + }) + if err != nil { + log.ErrorF("[ReplicaSetByAppName] - [%s] [%s] list replicaset error %s", cmiiEnv, appName, err.Error()) + return nil + } + + for _, replicaSet := range replicaSets.Items { + replicaSet.SetManagedFields(nil) + replicaList = append(replicaList, replicaSet) + } + + return replicaList +} + func (op *CmiiK8sOperator) PodAll(cmiiEnv string) []corev1.Pod { op.changeOperatorEnv(cmiiEnv) @@ -533,10 +587,57 @@ func (op *CmiiK8sOperator) PodAllInterface(cmiiEnv string) []CmiiPodInterface { return results[:index] } -// PodAllInSpecificNode cmiiEnv aims to specific k8s cluster -func PodAllInSpecificNode(cmiiEnv, nodeName string) (podList []CmiiPodInterface) { +func (op *CmiiK8sOperator) PodByAppName(cmiiEnv, appName string) (podList []CmiiPodInterface) { - return nil + deploy := op.DeploymentExist(cmiiEnv, appName) + if deploy == nil { + log.ErrorF("[PodByAppName] - [%s] [%s] app not exists !", cmiiEnv, appName) + return nil + } + + labelSelector := metav1.FormatLabelSelector(deploy.Spec.Selector) + //Get the replica sets that belong to the deployment. + pods, err := op.CurrentClient.CoreV1().Pods(op.CurrentNamespace).List(context.TODO(), metav1.ListOptions{ + LabelSelector: labelSelector, + }) + if err != nil { + log.ErrorF("[PodByAppName] - [%s] [%s] list pods error %s", cmiiEnv, appName, err.Error()) + return nil + } + + cmiiPodInterface := CmiiPodInterface{} + for _, pod := range pods.Items { + pod.SetManagedFields(nil) + podInterface := cmiiPodInterface.Convert(pod) + podList = append(podList, podInterface) + } + + return podList +} + +func (op *CmiiK8sOperator) PodByNodeName(cmiiEnv, nodeName string) (podList []CmiiPodInterface) { + + node := op.NodeExists(cmiiEnv, nodeName) + if node == nil { + return nil + } + + list, err := op.CurrentClient.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{ + FieldSelector: "spec.nodeName=" + nodeName, + }) + if err != nil { + log.ErrorF("[PodByNodeName] - [%s] [%s] list pod error %s !", cmiiEnv, nodeName, err.Error()) + return nil + } + + podInterface := CmiiPodInterface{} + for _, pod := range list.Items { + cmiiPodInterface := podInterface.Convert(pod) + + podList = append(podList, cmiiPodInterface) + } + + return podList } func (op *CmiiK8sOperator) PodFizz(cmiiEnv, appFizz string) (fizzPod []corev1.Pod) { @@ -608,3 +709,21 @@ func (op *CmiiK8sOperator) NodeAllInterface(cmiiEnv string) (nodeList []CmiiNode return nodeList } + +func (op *CmiiK8sOperator) NodeExists(cmiiEnv, nodeName string) (node *CmiiNodeInterface) { + + op.changeOperatorEnv(cmiiEnv) + client := op.CurrentClient + + nodeInterface := CmiiNodeInterface{} + + nodeList, err := client.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{}) + if err != nil { + log.ErrorF("[NodeExists] - [%s] [%s] not exists !", cmiiEnv, nodeName) + return nil + } + + convert := nodeInterface.Convert(*nodeList) + + return &convert +} diff --git a/agent-go/k8s_exec/K8sOperator_test.go b/agent-go/k8s_exec/K8sOperator_test.go index c9afc45..c52e024 100644 --- a/agent-go/k8s_exec/K8sOperator_test.go +++ b/agent-go/k8s_exec/K8sOperator_test.go @@ -3,6 +3,7 @@ package k8s_exec import ( "agent-go/utils" "fmt" + "github.com/magiconair/properties/assert" "testing" "time" ) @@ -100,6 +101,28 @@ func TestCmiiK8sOperator_DeploymentOneInterface(t *testing.T) { utils.BeautifulPrint(*deploy) } +func TestCmiiK8sOperator_ReplicaSetExists(t *testing.T) { + + cmiiEnv := "uavcloud-devflight" + appName := "cmii-admin-data-bf8f87cb7" + + exists := CmiiOperator.ReplicaSetExists(cmiiEnv, appName) + + utils.BeautifulPrint(*exists) +} + +func TestCmiiK8sOperator_ReplicaSetByAppName(t *testing.T) { + + cmiiEnv := "uavcloud-devflight" + appName := "cmii-admin-data" + + exists := CmiiOperator.ReplicaSetByAppName(cmiiEnv, appName) + + for _, replicaSet := range exists { + utils.BeautifulPrint(replicaSet) + } +} + func TestCmiiK8sOperator_PodAll(t *testing.T) { start := time.Now() podList := CmiiOperator.PodAll("devflight") @@ -132,6 +155,17 @@ func TestCmiiK8sOperator_PodFizz(t *testing.T) { } +func TestCmiiK8sOperator_PodByAppName(t *testing.T) { + cmiiEnv := "uavcloud-devflight" + nodeName := "dev-01.ecs.io" + + exists := CmiiOperator.PodByNodeName(cmiiEnv, nodeName) + + for _, podInterface := range exists { + utils.BeautifulPrint(podInterface) + } +} + func TestCmiiDeploymentInterface_Convert(t *testing.T) { log.DebugF("dadasdadasd") @@ -158,9 +192,30 @@ func TestCmiiK8sOperator_PodFizz2(t *testing.T) { } +func TestCmiiK8sOperator_PodByNodeName(t *testing.T) { + cmiiEnv := "uavcloud-devflight" + appName := "cmii-admin-data" + + exists := CmiiOperator.PodByAppName(cmiiEnv, appName) + + for _, podInterface := range exists { + utils.BeautifulPrint(podInterface) + } +} + +func TestCmiiK8sOperator_DeploymentStatusCheck(t *testing.T) { + + cmiiEnv := "devflight" + appName := "cmii-uav-gateway" + + check := CmiiOperator.DeploymentStatusCheck(cmiiEnv, appName, 180) + assert.Equal(t, check, true, "deployment run failed!") + +} + func TestCmiiK8sOperator_NodeAll(t *testing.T) { start := time.Now() - nodeList := CmiiOperator.NodeAll("uat") + nodeList := CmiiOperator.NodeAll("dev") elapsed := time.Since(start).Milliseconds() fmt.Printf("执行耗时: %d ms\n", elapsed) diff --git a/agent-go/k8s_exec/log/cmii-update-log.txt b/agent-go/k8s_exec/log/cmii-update-log.txt index f2eba2d..cdf5a77 100644 --- a/agent-go/k8s_exec/log/cmii-update-log.txt +++ b/agent-go/k8s_exec/log/cmii-update-log.txt @@ -7,3 +7,10 @@ 2024-01-11-11-58-15 uavcloud-uavms uavms-lowaltitude-platform 5.1.0 5.2.0-011101 2024-01-11-14-00-34 uavcloud-uavms uavms-lowaltitude-platform 5.1.0-011102 5.1.0-011103 2024-01-11-14-49-53 uavcloud-demo cmii-uav-waypoint 5.2.0-011101 5.2.0-011102 +2024-01-11-15-32-28 uavcloud-demo cmii-uav-platform 5.2.0-011101 5.2.0-011102 +2024-01-11-17-09-44 uavcloud-feature cmii-uav-platform 5.2.0-validation 5.2.0-011102 +2024-01-11-17-35-47 uavcloud-uavms cmii-uav-surveillance 5.1.0-LAIN05A 5.1.0-011101 +2024-01-11-17-38-06 uavcloud-uavms uavms-lowaltitude-platform 5.1.0-011103 5.1.0-011102 +2024-01-11-17-49-09 uavcloud-uavms uavms-lowaltitude-platform 5.1.0-011102 5.1.0-011104 +2024-01-12-10-38-30 uavcloud-uavms uavms-lowaltitude-platform 5.1.0-011105 5.2.0-011201 +2024-01-12-12-09-59 uavcloud-uavms uavms-lowaltitude-platform 5.2.0-011201 5.2.0-011202 diff --git a/agent-go/tmp/cmii-backend-pod.yaml b/agent-go/tmp/cmii-backend-pod.yaml new file mode 100644 index 0000000..4720d7a --- /dev/null +++ b/agent-go/tmp/cmii-backend-pod.yaml @@ -0,0 +1,295 @@ +{ + "metadata": { + "name": "cmii-admin-data-bf8f87cb7-8bz4l", + "generateName": "cmii-admin-data-bf8f87cb7-", + "namespace": "uavcloud-devflight", + "selfLink": "/api/v1/namespaces/uavcloud-devflight/pods/cmii-admin-data-bf8f87cb7-8bz4l", + "uid": "1cc7936f-0416-40aa-9d9f-811814a7a1ee", + "resourceVersion": "474134438", + "creationTimestamp": "2024-01-10T07:23:09Z", + "labels": { + "app.kubernetes.io/instance": "cmii-admin-data", + "app.kubernetes.io/managed-by": "Helm", + "cmii.app": "cmii-admin-data", + "cmii.modules": "cmlc.lcadm", + "cmii.type": "backend", + "cmii/managed-by": "jenkins-pipeline-standalone-job", + "pod-template-hash": "bf8f87cb7" + }, + "ownerReferences": [ + { + "apiVersion": "apps/v1", + "kind": "ReplicaSet", + "name": "cmii-admin-data-bf8f87cb7", + + "uid": "f853fc51-894b-432f-8cc0-1f7acce715ff", + "controller": true, + "blockOwnerDeletion": true + } + ] + }, + "spec": { + "volumes": [ + { + "name": "nfs-backend-log-volume", + "persistentVolumeClaim": { + "claimName": "nfs-backend-log-pvc" + + } + }, + { + "name": "elk-json-log", + "hostPath": { + "path": "/var/log/", + "type": "" + } + }, + { + "name": "default-token-hzddz", + "secret": { + "secretName": "default-token-hzddz", + "defaultMode": 420 + } + } + ], + "containers": [ + { + "name": "cmii-admin-data", + "image": "harbor.cdcyy.com.cn/cmii/cmii-admin-data:5.2.0-beta", + "ports": [ + { + "name": "pod-port", + "containerPort": 8080, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "GIT_BRANCH", + "value": "staging" + }, + { + "name": "GIT_COMMIT", + "value": "378998cb81c98afc29ff327419e9449907a210d5" + }, + { + "name": "K8S_NAMESPACE", + "value": "uavcloud-devflight" + }, + { + "name": "APPLICATION_NAME", + "value": "cmii-admin-data" + }, + { + "name": "CUST_JAVA_OPTS", + "value": "-Xms256m -Xmx512m -Dlog4j2.formatMsgNoLookups=true" + }, + { + "name": "NACOS_REGISTRY", + "value": "helm-nacos:8848" + }, + { + "name": "NACOS_USERNAME", + "value": "developer" + }, + { + "name": "NACOS_PASSWORD", + "value": "Deve@9128" + }, + { + "name": "NACOS_DISCOVERY_IP", + "valueFrom": { + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "status.podIP" + } + } + }, + { + "name": "NACOS_DISCOVERY_PORT", + "value": "8080" + }, + { + "name": "IMAGE_VERSION", + "value": "5.2.0-beta" + }, + { + "name": "BIZ_CONFIG_GROUP" + }, + { + "name": "SYS_CONFIG_GROUP" + } + ], + "resources": { + "limits": { + "cpu": "2", + "memory": "2Gi" + }, + "requests": { + "cpu": "100m", + "memory": "200Mi" + } + }, + "volumeMounts": [ + { + "name": "nfs-backend-log-volume", + "mountPath": "/cmii/logs", + "subPath": "uavcloud-devflight/cmii-admin-data" + }, + { + "name": "elk-json-log", + "mountPath": "/cmii/jsonlogs", + "subPath": "json_pv_logfile" + }, + { + "name": "default-token-hzddz", + "readOnly": true, + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" + } + ], + "livenessProbe": { + "httpGet": { + "path": "/cmii/ping", + "port": "pod-port", + "scheme": "HTTP" + }, + "initialDelaySeconds": 5, + "timeoutSeconds": 2, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "readinessProbe": { + "httpGet": { + "path": "/cmii/ping", + "port": "pod-port", + "scheme": "HTTP" + }, + "initialDelaySeconds": 5, + "timeoutSeconds": 2, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 3 + }, + "startupProbe": { + "httpGet": { + "path": "/cmii/ping", + "port": "pod-port", + "scheme": "HTTP" + }, + "initialDelaySeconds": 120, + "timeoutSeconds": 2, + "periodSeconds": 10, + "successThreshold": 1, + "failureThreshold": 10 + }, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "imagePullPolicy": "Always" + } + ], + "restartPolicy": "Always", + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "serviceAccountName": "default", + "serviceAccount": "default", + "nodeName": "dev-04.ecs.io", + "securityContext": { }, + "imagePullSecrets": [ + { + "name": "harborsecret" + } + ], + "affinity": { + "nodeAffinity": { + "requiredDuringSchedulingIgnoredDuringExecution": { + "nodeSelectorTerms": [ + { + "matchExpressions": [ + { + "key": "uavcloud.affinity", + "operator": "In", + "values": [ + "common" + ] + } + ] + } + ] + } + } + }, + "schedulerName": "default-scheduler", + "tolerations": [ + { + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + }, + { + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "effect": "NoExecute", + "tolerationSeconds": 300 + } + ], + "priority": 0, + "enableServiceLinks": true + }, + "status": { + "phase": "Running", + "conditions": [ + { + "type": "Initialized", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2024-01-10T07:23:09Z" + }, + { + "type": "Ready", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2024-01-10T07:25:31Z" + }, + { + "type": "ContainersReady", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2024-01-10T07:25:31Z" + }, + { + "type": "PodScheduled", + "status": "True", + "lastProbeTime": null, + "lastTransitionTime": "2024-01-10T07:23:09Z" + } + ], + "hostIP": "192.168.11.158", + "podIP": "10.244.32.143", + "podIPs": [ + { + "ip": "10.244.32.143" + } + ], + "startTime": "2024-01-10T07:23:09Z", + "containerStatuses": [ + { + "name": "cmii-admin-data", + "state": { + "running": { + "startedAt": "2024-01-10T07:23:22Z" + } + }, + "lastState": { }, + "ready": true, + "restartCount": 0, + "image": "harbor.cdcyy.com.cn/cmii/cmii-admin-data:5.2.0-beta", + "imageID": "docker-pullable://harbor.cdcyy.com.cn/cmii/cmii-admin-data@sha256:5e8fc9a55ffd4bf9772e0f44142486d27f37aaca28d8fa920e7248aea89a7e28", + "containerID": "docker://4b6e5594d8a3a5202c1ecfb85dbfbcb5215926a21544f8f3646a1d605ce6e70c", + "started": true + } + ], + "qosClass": "Burstable" + } +} \ No newline at end of file diff --git a/agent-go/tmp/cmii-backend-replicaset.yaml b/agent-go/tmp/cmii-backend-replicaset.yaml new file mode 100644 index 0000000..4fa4eea --- /dev/null +++ b/agent-go/tmp/cmii-backend-replicaset.yaml @@ -0,0 +1,549 @@ +{ + "metadata": { + "name": "cmii-admin-data-bf8f87cb7", + "namespace": "uavcloud-devflight", + "selfLink": "/apis/apps/v1/namespaces/uavcloud-devflight/replicasets/cmii-admin-data-bf8f87cb7", + "uid": "f853fc51-894b-432f-8cc0-1f7acce715ff", + "resourceVersion": "474134441", + "generation": 3, + "creationTimestamp": "2023-12-28T03:10:25Z", + "labels": { + "app.kubernetes.io/instance": "cmii-admin-data", + "app.kubernetes.io/managed-by": "Helm", + "cmii.app": "cmii-admin-data", + "cmii.modules": "cmlc.lcadm", + "cmii.type": "backend", + "cmii/managed-by": "jenkins-pipeline-standalone-job", + "pod-template-hash": "bf8f87cb7" + }, + "annotations": { + "deployment.kubernetes.io/desired-replicas": "2", + "deployment.kubernetes.io/max-replicas": "3", + "deployment.kubernetes.io/revision": "1", + "meta.helm.sh/release-name": "cmii-admin-data", + "meta.helm.sh/release-namespace": "uavcloud-devflight" + }, + "ownerReferences": [ + { + "apiVersion": "apps/v1", + "kind": "Deployment", + "name": "cmii-admin-data", + + "uid": "a3714e1c-ba59-4fc8-bdd6-fd27b676c943", + "controller": true, + "blockOwnerDeletion": true + } + ], + "managedFields": [ + { + "manager": "kube-controller-manager", + "operation": "Update", + "apiVersion": "apps/v1", + "time": "2024-01-10T07:25:31Z", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:annotations": { + ".": { }, + "f:deployment.kubernetes.io/desired-replicas": { }, + "f:deployment.kubernetes.io/max-replicas": { }, + "f:deployment.kubernetes.io/revision": { }, + "f:meta.helm.sh/release-name": { }, + "f:meta.helm.sh/release-namespace": { } + }, + "f:labels": { + ".": { }, + "f:app.kubernetes.io/instance": { }, + "f:app.kubernetes.io/managed-by": { }, + "f:cmii.app": { }, + "f:cmii.modules": { }, + "f:cmii.type": { }, + "f:cmii/managed-by": { }, + "f:pod-template-hash": { } + }, + "f:ownerReferences": { + ".": { }, + "k:{\"uid\":\"a3714e1c-ba59-4fc8-bdd6-fd27b676c943\"}": { + ".": { }, + "f:apiVersion": { }, + "f:blockOwnerDeletion": { }, + "f:controller": { }, + "f:kind": { }, + "f:name": { }, + "f:uid": { } + } + } + }, + "f:spec": { + "f:replicas": { }, + "f:selector": { + "f:matchLabels": { + ".": { }, + "f:cmii.app": { }, + "f:cmii.type": { }, + "f:cmii/managed-by": { }, + "f:pod-template-hash": { } + } + }, + "f:template": { + "f:metadata": { + "f:labels": { + ".": { }, + "f:app.kubernetes.io/instance": { }, + "f:app.kubernetes.io/managed-by": { }, + "f:cmii.app": { }, + "f:cmii.modules": { }, + "f:cmii.type": { }, + + "f:cmii/managed-by": { }, + "f:pod-template-hash": { } + } + }, + "f:spec": { + "f:affinity": { + ".": { }, + "f:nodeAffinity": { + ".": { }, + "f:requiredDuringSchedulingIgnoredDuringExecution": { + ".": { }, + "f:nodeSelectorTerms": { } + } + } + }, + "f:containers": { + "k:{\"name\":\"cmii-admin-data\"}": { + ".": { }, + "f:env": { + ".": { }, + "k:{\"name\":\"APPLICATION_NAME\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"BIZ_CONFIG_GROUP\"}": { + ".": { }, + "f:name": { } + + }, + "k:{\"name\":\"CUST_JAVA_OPTS\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"GIT_BRANCH\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"GIT_COMMIT\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"IMAGE_VERSION\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"K8S_NAMESPACE\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"NACOS_DISCOVERY_IP\"}": { + ".": { }, + "f:name": { }, + "f:valueFrom": { + ".": { }, + "f:fieldRef": { + ".": { }, + "f:apiVersion": { }, + "f:fieldPath": { } + } + } + }, + "k:{\"name\":\"NACOS_DISCOVERY_PORT\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"NACOS_PASSWORD\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"NACOS_REGISTRY\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"NACOS_USERNAME\"}": { + ".": { }, + "f:name": { }, + "f:value": { } + }, + "k:{\"name\":\"SYS_CONFIG_GROUP\"}": { + ".": { }, + "f:name": { } + + } + }, + "f:image": { }, + "f:imagePullPolicy": { }, + "f:livenessProbe": { + ".": { }, + "f:failureThreshold": { }, + "f:httpGet": { + + ".": { }, + "f:path": { }, + "f:port": { }, + "f:scheme": { } + }, + "f:initialDelaySeconds": { }, + "f:periodSeconds": { }, + "f:successThreshold": { }, + "f:timeoutSeconds": { } + }, + "f:name": { }, + "f:ports": { + ".": { }, + "k:{\"containerPort\":8080,\"protocol\":\"TCP\"}": { + ".": { }, + "f:containerPort": { }, + "f:name": { }, + "f:protocol": { } + } + }, + "f:readinessProbe": { + ".": { }, + "f:failureThreshold": { }, + "f:httpGet": { + + ".": { }, + "f:path": { }, + "f:port": { }, + "f:scheme": { } + }, + "f:initialDelaySeconds": { }, + "f:periodSeconds": { }, + "f:successThreshold": { }, + "f:timeoutSeconds": { } + }, + "f:resources": { + + ".": { }, + "f:limits": { + ".": { }, + "f:cpu": { }, + + "f:memory": { } + }, + "f:requests": { + ".": { }, + "f:cpu": { }, + + "f:memory": { } + } + }, + "f:startupProbe": { + ".": { }, + "f:failureThreshold": { }, + "f:httpGet": { + + ".": { }, + "f:path": { }, + "f:port": { }, + "f:scheme": { } + }, + "f:initialDelaySeconds": { }, + "f:periodSeconds": { }, + "f:successThreshold": { }, + "f:timeoutSeconds": { } + }, + "f:terminationMessagePath": { }, + "f:terminationMessagePolicy": { }, + "f:volumeMounts": { + ".": { }, + "k:{\"mountPath\":\"/cmii/jsonlogs\"}": { + ".": { }, + "f:mountPath": { }, + "f:name": { }, + "f:subPath": { } + }, + "k:{\"mountPath\":\"/cmii/logs\"}": { + ".": { }, + "f:mountPath": { }, + "f:name": { }, + "f:subPath": { } + } + } + } + }, + "f:dnsPolicy": { }, + "f:imagePullSecrets": { + ".": { }, + "k:{\"name\":\"harborsecret\"}": { + ".": { }, + "f:name": { } + } + }, + "f:restartPolicy": { }, + "f:schedulerName": { }, + "f:securityContext": { }, + "f:terminationGracePeriodSeconds": { }, + "f:volumes": { + ".": { }, + "k:{\"name\":\"elk-json-log\"}": { + ".": { }, + "f:hostPath": { + ".": { }, + "f:path": { }, + "f:type": { } + }, + "f:name": { } + }, + "k:{\"name\":\"nfs-backend-log-volume\"}": { + ".": { }, + "f:name": { }, + "f:persistentVolumeClaim": { + ".": { }, + "f:claimName": { } + } + } + } + } + } + }, + "f:status": { + "f:availableReplicas": { }, + "f:fullyLabeledReplicas": { }, + "f:observedGeneration": { }, + "f:readyReplicas": { }, + "f:replicas": { } + } + } + } + ] + }, + "spec": { + "replicas": 2, + "selector": { + "matchLabels": { + "cmii.app": "cmii-admin-data", + "cmii.type": "backend", + "cmii/managed-by": "jenkins-pipeline-standalone-job", + "pod-template-hash": "bf8f87cb7" + } + }, + "template": { + "metadata": { + "creationTimestamp": null, + "labels": { + "app.kubernetes.io/instance": "cmii-admin-data", + "app.kubernetes.io/managed-by": "Helm", + "cmii.app": "cmii-admin-data", + "cmii.modules": "cmlc.lcadm", + "cmii.type": "backend", + "cmii/managed-by": "jenkins-pipeline-standalone-job", + "pod-template-hash": "bf8f87cb7" + } + }, + "spec": { + "volumes": [ + { + "name": "nfs-backend-log-volume", + "persistentVolumeClaim": { + "claimName": "nfs-backend-log-pvc" + } + }, + { + "name": "elk-json-log", + "hostPath": { + "path": "/var/log/", + + "type": "" + } + } + ], + "containers": [ + { + "name": "cmii-admin-data", + "image": "harbor.cdcyy.com.cn/cmii/cmii-admin-data:5.2.0-beta", + "ports": [ + { + "name": "pod-port", + "containerPort": 8080, + "protocol": "TCP" + } + ], + "env": [ + { + "name": "GIT_BRANCH", + "value": "staging" + + }, + { + "name": "GIT_COMMIT", + "value": "378998cb81c98afc29ff327419e9449907a210d5" + }, + { + "name": "K8S_NAMESPACE", + "value": "uavcloud-devflight" + }, + { + "name": "APPLICATION_NAME", + "value": "cmii-admin-data" + }, + { + "name": "CUST_JAVA_OPTS", + "value": "-Xms256m -Xmx512m -Dlog4j2.formatMsgNoLookups=true" + }, + { + "name": "NACOS_REGISTRY", + "value": "helm-nacos:8848" + }, + { + "name": "NACOS_USERNAME", + "value": "developer" + }, + { + "name": "NACOS_PASSWORD", + "value": "Deve@9128" + }, + { + "name": "NACOS_DISCOVERY_IP", + "valueFrom": { + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "status.podIP" + } + } + }, + { + "name": "NACOS_DISCOVERY_PORT", + "value": "8080" + }, + { + "name": "IMAGE_VERSION", + "value": "5.2.0-beta" + }, + { + "name": "BIZ_CONFIG_GROUP" + }, + { + "name": "SYS_CONFIG_GROUP" + } + ], + "resources": { + "limits": { + "cpu": "2", + "memory": "2Gi" + }, + "requests": { + "cpu": "100m", + "memory": "200Mi" + } + }, + "volumeMounts": [ + { + "name": "nfs-backend-log-volume", + "mountPath": "/cmii/logs", + "subPath": "uavcloud-devflight/cmii-admin-data" + }, + { + "name": "elk-json-log", + "mountPath": "/cmii/jsonlogs", + "subPath": "json_pv_logfile" + } + ], + "livenessProbe": { + "httpGet": { + "path": "/cmii/ping", + "port": "pod-port", + "scheme": "HTTP" + }, + "initialDelaySeconds": 5, + "timeoutSeconds": 2, + "periodSeconds": 10, + "successThreshold": 1, + + "failureThreshold": 3 + }, + "readinessProbe": { + "httpGet": { + "path": "/cmii/ping", + "port": "pod-port", + + "scheme": "HTTP" + }, + "initialDelaySeconds": 5, + "timeoutSeconds": 2, + "periodSeconds": 10, + "successThreshold": 1, + + "failureThreshold": 3 + }, + "startupProbe": { + "httpGet": { + "path": "/cmii/ping", + "port": "pod-port", + "scheme": "HTTP" + }, + "initialDelaySeconds": 120, + "timeoutSeconds": 2, + "periodSeconds": 10, + "successThreshold": 1, + + "failureThreshold": 10 + + }, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "imagePullPolicy": "Always" + } + ], + "restartPolicy": "Always", + + "terminationGracePeriodSeconds": 30, + "dnsPolicy": "ClusterFirst", + "securityContext": { }, + "imagePullSecrets": [ + { + "name": "harborsecret" + + } + ], + "affinity": { + "nodeAffinity": { + "requiredDuringSchedulingIgnoredDuringExecution": { + "nodeSelectorTerms": [ + + { + "matchExpressions": [ + { + "key": "uavcloud.affinity", + "operator": "In", + "values": [ + "common" + ] + } + ] + } + ] + } + } + }, + "schedulerName": "default-scheduler" + } + } + }, + "status": { + "replicas": 2, + "fullyLabeledReplicas": 2, + "readyReplicas": 2, + "availableReplicas": 2, + "observedGeneration": 3 + } +} +