123
This commit is contained in:
parent
2d61b8bf7c
commit
71d7956e65
|
@ -0,0 +1,10 @@
|
||||||
|
.body-right-Pods{
|
||||||
|
width: 1420px;
|
||||||
|
height: 830px;
|
||||||
|
position: absolute;
|
||||||
|
top: 72px;
|
||||||
|
left: 220px;
|
||||||
|
border-radius: 10px;
|
||||||
|
float: right;
|
||||||
|
background-color: #f7f8fa;
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import axios from 'axios';
|
||||||
|
import './TrainPods.css'
|
||||||
|
|
||||||
|
function TrainPods(){
|
||||||
|
return(
|
||||||
|
<div className='body-right-Pods'>asdas</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TrainPods
|
|
@ -48,6 +48,7 @@ function TrainManage(){
|
||||||
<p>关闭时间:2024-11-5</p>
|
<p>关闭时间:2024-11-5</p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<Link to='/teacher/trainmanage/TrainPods' >管理实训</Link>
|
||||||
<Link to='/teacher/SendTrain' className='sendtestpage'>前往发布实训</Link>
|
<Link to='/teacher/SendTrain' className='sendtestpage'>前往发布实训</Link>
|
||||||
</div>}
|
</div>}
|
||||||
<button onClick={()=>{
|
<button onClick={()=>{
|
||||||
|
|
|
@ -254,7 +254,7 @@ function Operation1() {
|
||||||
</ul>
|
</ul>
|
||||||
)}
|
)}
|
||||||
</li>
|
</li>
|
||||||
<Link to={`/operation2/1`} style={{color:'#000',textDecoration:'none'}}>
|
<Link to={`/operation2/${operateID}`} style={{color:'#000',textDecoration:'none'}}>
|
||||||
<li style={{ marginTop: isSubjectDropdownOpen ? '186px' : '0' }}>实训题</li>
|
<li style={{ marginTop: isSubjectDropdownOpen ? '186px' : '0' }}>实训题</li>
|
||||||
</Link>
|
</Link>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -21,7 +21,7 @@ function SignInPage(){
|
||||||
if (data.result === '登录成功' && data.user==='user'){
|
if (data.result === '登录成功' && data.user==='user'){
|
||||||
localStorage.setItem('islogin',ID)
|
localStorage.setItem('islogin',ID)
|
||||||
alert('用户登录成功')
|
alert('用户登录成功')
|
||||||
window.location.href=''//后期改成学生页面
|
window.location.href='/'//后期改成学生页面
|
||||||
}else if(data.result==='登录成功'&&data.user==='teacher'){
|
}else if(data.result==='登录成功'&&data.user==='teacher'){
|
||||||
localStorage.setItem('islogin',ID)
|
localStorage.setItem('islogin',ID)
|
||||||
alert('教师登录成功')
|
alert('教师登录成功')
|
||||||
|
|
|
@ -27,6 +27,7 @@ import SendTrain from '../TeacherPages/Trainmanage/SendTrain'
|
||||||
import TrainManage from '../TeacherPages/Trainmanage/Trainmanage'
|
import TrainManage from '../TeacherPages/Trainmanage/Trainmanage'
|
||||||
import StudentLink from '../TeacherPages/MarkingPages/StudentLink';
|
import StudentLink from '../TeacherPages/MarkingPages/StudentLink';
|
||||||
import Test from '../TeacherPages/TestManage/Test'
|
import Test from '../TeacherPages/TestManage/Test'
|
||||||
|
import TrainPods from '../TeacherPages/Trainmanage/TrainPods'
|
||||||
|
|
||||||
|
|
||||||
// 定义一个组件来包裹除了特定页面(exam)外的所有页面使其有导航
|
// 定义一个组件来包裹除了特定页面(exam)外的所有页面使其有导航
|
||||||
|
@ -64,6 +65,7 @@ function App() {
|
||||||
<Route path='managetest' element={<ManageTest />}/> {/* 考试管理 */}
|
<Route path='managetest' element={<ManageTest />}/> {/* 考试管理 */}
|
||||||
<Route path="classID/:key" element={<ClassID />} /> {/* 班级管理1 */}
|
<Route path="classID/:key" element={<ClassID />} /> {/* 班级管理1 */}
|
||||||
<Route path='mark/studentlink/Mark/:key' element={<StudentLink/>}/> {/* 批改1 */}
|
<Route path='mark/studentlink/Mark/:key' element={<StudentLink/>}/> {/* 批改1 */}
|
||||||
|
<Route path='trainmanage/TrainPods' element={<TrainPods/> }/>
|
||||||
{/* 其他需要HeaderNavTeacher的页面 */}
|
{/* 其他需要HeaderNavTeacher的页面 */}
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ spec:
|
||||||
runAsGroup: 0
|
runAsGroup: 0
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: '0.5'
|
cpu: '1'
|
||||||
memory: 0.5Gi
|
memory: 1.2Gi
|
||||||
requests:
|
requests:
|
||||||
cpu: '0.3'
|
cpu: '0.2'
|
||||||
memory: 0.3Gi
|
memory: 0.2Gi
|
|
@ -15,8 +15,8 @@ spec:
|
||||||
runAsGroup: 0
|
runAsGroup: 0
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: '0.5'
|
cpu: '1.3'
|
||||||
memory: 0.5Gi
|
memory: 1.3Gi
|
||||||
requests:
|
requests:
|
||||||
cpu: '0.3'
|
cpu: '0.3'
|
||||||
memory: 0.3Gi
|
memory: 0.3Gi
|
|
@ -1,5 +1,5 @@
|
||||||
import k8s_func
|
import k8s_func
|
||||||
studentList=['n20240101-55']
|
studentList=['n20240101-56','n20240102-56','s20240101-52','s20240102-52']
|
||||||
|
|
||||||
for i in studentList:
|
for i in studentList:
|
||||||
k8s_func.delete_pod(i)
|
k8s_func.delete_pod(i)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import yaml
|
||||||
from kubernetes import client, config
|
from kubernetes import client, config
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
import dmPython
|
import dmPython
|
||||||
|
|
||||||
# Load in-cluster config
|
# Load in-cluster config
|
||||||
|
|
||||||
config.load_incluster_config()
|
config.load_incluster_config()
|
||||||
|
@ -12,81 +13,82 @@ v1 = client.CoreV1Api()
|
||||||
namespace = open("/var/run/secrets/kubernetes.io/serviceaccount/namespace").read()
|
namespace = open("/var/run/secrets/kubernetes.io/serviceaccount/namespace").read()
|
||||||
IP = "36.138.114.105"
|
IP = "36.138.114.105"
|
||||||
|
|
||||||
|
|
||||||
def list_pods():
|
def list_pods():
|
||||||
ret = v1.list_namespaced_pod(namespace, watch=False)
|
ret = v1.list_namespaced_pod(namespace, watch=False)
|
||||||
return ({
|
return ({
|
||||||
"list": [{
|
"list": [{
|
||||||
"name": item.metadata.name,
|
"name": item.metadata.name,
|
||||||
"ip": item.status.pod_ip
|
"ip": item.status.pod_ip
|
||||||
} for item in ret.items]
|
} for item in ret.items]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def list_services():
|
def list_services():
|
||||||
ret = v1.list_namespaced_service(namespace)
|
ret = v1.list_namespaced_service(namespace)
|
||||||
return {
|
return {
|
||||||
"list": [{
|
"list": [{
|
||||||
"ip": item.spec.cluster_ip,
|
"ip": item.spec.cluster_ip,
|
||||||
"name": item.metadata.name,
|
"name": item.metadata.name,
|
||||||
"ports": [port.to_dict() for port in item.spec.ports]
|
"ports": [port.to_dict() for port in item.spec.ports]
|
||||||
} for item in ret.items]
|
} for item in ret.items]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_pod(type, name):
|
def create_pod(type, name):
|
||||||
# 读取 pod yaml 文件
|
# 读取 pod yaml 文件
|
||||||
with open(f"assets/type{type}-pod.yaml") as f:
|
with open(f"assets/type{type}-pod.yaml") as f:
|
||||||
pod_manifest = yaml.safe_load(f)
|
pod_manifest = yaml.safe_load(f)
|
||||||
pod_manifest["metadata"]["name"] = name
|
pod_manifest["metadata"]["name"] = name
|
||||||
pod_manifest["metadata"]["labels"]["app"] = name
|
pod_manifest["metadata"]["labels"]["app"] = name
|
||||||
# 创建 Pod
|
# 创建 Pod
|
||||||
resp = v1.create_namespaced_pod(
|
resp = v1.create_namespaced_pod(
|
||||||
body=pod_manifest,
|
body=pod_manifest,
|
||||||
namespace=namespace
|
namespace=namespace
|
||||||
)
|
)
|
||||||
# print(f"pod '{resp.metadata.name}' 创建成功")
|
# print(f"pod '{resp.metadata.name}' 创建成功")
|
||||||
# 创建 Service
|
# 创建 Service
|
||||||
with open(f"assets/type{type}-service.yaml") as f:
|
with open(f"assets/type{type}-service.yaml") as f:
|
||||||
service_pod = yaml.safe_load(f)
|
service_pod = yaml.safe_load(f)
|
||||||
service_pod["metadata"]["name"] = name + "-service"
|
service_pod["metadata"]["name"] = name + "-service"
|
||||||
service_pod["spec"]["selector"]["app"] = name
|
service_pod["spec"]["selector"]["app"] = name
|
||||||
|
|
||||||
|
resp = v1.create_namespaced_service(
|
||||||
|
body=service_pod,
|
||||||
|
namespace=namespace
|
||||||
|
)
|
||||||
|
# print(f"服务 '{resp.metadata.name}' 创建成功")
|
||||||
|
if type == 1:
|
||||||
|
# 创建成功,再次查询,拿到端口
|
||||||
|
service = v1.read_namespaced_service(name=name + "-service", namespace=namespace)
|
||||||
|
# print(service)
|
||||||
|
# print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port))
|
||||||
|
else:
|
||||||
|
service = v1.read_namespaced_service(name=name + "-service", namespace=namespace)
|
||||||
|
# print(service)
|
||||||
|
# print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port))
|
||||||
|
return "cjcg"
|
||||||
|
|
||||||
resp = v1.create_namespaced_service(
|
|
||||||
body=service_pod,
|
|
||||||
namespace=namespace
|
|
||||||
)
|
|
||||||
# print(f"服务 '{resp.metadata.name}' 创建成功")
|
|
||||||
if type == 1:
|
|
||||||
# 创建成功,再次查询,拿到端口
|
|
||||||
service = v1.read_namespaced_service(name=name + "-service", namespace=namespace)
|
|
||||||
# print(service)
|
|
||||||
# print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port))
|
|
||||||
else:
|
|
||||||
service = v1.read_namespaced_service(name=name + "-service", namespace=namespace)
|
|
||||||
# print(service)
|
|
||||||
# print("访问地址:" + IP + ":" + str(service.spec.ports[0].node_port))
|
|
||||||
return "cjcg"
|
|
||||||
|
|
||||||
# create_pod(0,'20240101-zt-9-0')
|
# create_pod(0,'20240101-zt-9-0')
|
||||||
|
|
||||||
def delete_pod(name):
|
def delete_pod(name):
|
||||||
v1.delete_namespaced_pod(name=name, namespace=namespace)
|
v1.delete_namespaced_pod(name=name, namespace=namespace)
|
||||||
print('deleting pod ' + name)
|
print('deleting pod ' + name)
|
||||||
v1.delete_namespaced_service(name=name + "-service", namespace=namespace)
|
v1.delete_namespaced_service(name=name + "-service", namespace=namespace)
|
||||||
return "删除成功"
|
return "删除成功"
|
||||||
|
|
||||||
|
|
||||||
def check_dm(name):
|
def check_dm(name):
|
||||||
try:
|
try:
|
||||||
service = v1.read_namespaced_service(name=name + "-service", namespace=namespace)
|
service = v1.read_namespaced_service(name=name + "-service", namespace=namespace)
|
||||||
print(service.spec.cluster_ip)
|
print(service.spec.cluster_ip)
|
||||||
db = dmPython.connect(user='SYSDBA', password='SYSDBA', host=service.spec.cluster_ip)
|
db = dmPython.connect(user='SYSDBA', password='SYSDBA', host=service.spec.cluster_ip)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
records = cursor.execute("SELECT * FROM V$VERSION").fetchall()
|
records = cursor.execute("SELECT * FROM V$VERSION").fetchall()
|
||||||
for record in records:
|
for record in records:
|
||||||
print(record)
|
print(record)
|
||||||
return "OK"
|
return "OK"
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return "NO"
|
return "NO"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue