添加sealos修改方式

This commit is contained in:
pengluan 2022-06-05 20:38:37 +08:00
parent 1f72a76e6d
commit 89959e964d
8 changed files with 15 additions and 9 deletions

View File

@ -36,6 +36,12 @@ services:
```
sealos部署的k8s修改kube-api启动参数
```
--service-account-issuer=kubernetes.default.svc
--service-account-signing-key-file=/etc/kubernetes/pki/sa.key
```
tke联系腾讯云添加
```bash
kube-api:

View File

@ -28,7 +28,7 @@ if not cluster:
else:
clusters = conf.get('CLUSTERS',{})
if clusters and cluster in clusters:
kubeconfig = clusters[cluster]['KUBECONFIG']
kubeconfig = clusters[cluster].get('KUBECONFIG','')
k8s_config.kube_config.load_kube_config(config_file=kubeconfig)
else:
print('no kubeconfig in cluster %s' % cluster)

View File

@ -36,7 +36,7 @@ if not cluster:
else:
clusters = conf.get('CLUSTERS',{})
if clusters and cluster in clusters:
kubeconfig = clusters[cluster]['KUBECONFIG']
kubeconfig = clusters[cluster].get('KUBECONFIG','')
k8s_config.kube_config.load_kube_config(config_file=kubeconfig)
else:
print('no kubeconfig in cluster %s' % cluster)

View File

@ -36,7 +36,7 @@ if not cluster:
else:
clusters = conf.get('CLUSTERS',{})
if clusters and cluster in clusters:
kubeconfig = clusters[cluster]['KUBECONFIG']
kubeconfig = clusters[cluster].get('KUBECONFIG','')
k8s_config.kube_config.load_kube_config(config_file=kubeconfig)
else:
print('no kubeconfig in cluster %s' % cluster)

View File

@ -33,7 +33,7 @@ if not cluster:
else:
clusters = conf.get('CLUSTERS',{})
if clusters and cluster in clusters:
kubeconfig = clusters[cluster]['KUBECONFIG']
kubeconfig = clusters[cluster].get('KUBECONFIG','')
k8s_config.kube_config.load_kube_config(config_file=kubeconfig)
else:
print('no kubeconfig in cluster %s' % cluster)

View File

@ -59,7 +59,7 @@ class Myapp(BaseMyappView):
from myapp.utils.py.py_k8s import K8s
all_clusters = conf.get('CLUSTERS',{})
if cluster_name in all_clusters:
kubeconfig = all_clusters[cluster_name]['KUBECONFIG']
kubeconfig = all_clusters[cluster_name].get('KUBECONFIG','')
pod_url = all_clusters[cluster_name].get('K8S_DASHBOARD_CLUSTER') + "#/log/%s/%s/pod?namespace=%s&container=%s" % (namespace, pod_name, namespace, pod_name)
else:
kubeconfig = None

View File

@ -152,7 +152,7 @@ class Docker_ModelView_Base():
def debug(self,docker_id):
docker = db.session.query(Docker).filter_by(id=docker_id).first()
from myapp.utils.py.py_k8s import K8s
k8s_client = K8s(conf.get('CLUSTERS').get(conf.get('ENVIRONMENT')).get('KUBECONFIG'))
k8s_client = K8s(conf.get('CLUSTERS').get(conf.get('ENVIRONMENT')).get('KUBECONFIG',''))
namespace = conf.get('NOTEBOOK_NAMESPACE')
pod_name="docker-%s-%s"%(docker.created_by.username,str(docker.id))
pod = k8s_client.get_pods(namespace=namespace,pod_name=pod_name)
@ -218,7 +218,7 @@ class Docker_ModelView_Base():
def delete_pod(self,docker_id):
docker = db.session.query(Docker).filter_by(id=docker_id).first()
from myapp.utils.py.py_k8s import K8s
k8s_client = K8s(conf.get('CLUSTERS').get(conf.get('ENVIRONMENT')).get('KUBECONFIG'))
k8s_client = K8s(conf.get('CLUSTERS').get(conf.get('ENVIRONMENT')).get('KUBECONFIG',''))
namespace = conf.get('NOTEBOOK_NAMESPACE')
pod_name="docker-%s-%s"%(docker.created_by.username,str(docker.id))
k8s_client.delete_pods(namespace=namespace,pod_name=pod_name)
@ -256,7 +256,7 @@ class Docker_ModelView_Base():
def save(self,docker_id):
docker = db.session.query(Docker).filter_by(id=docker_id).first()
from myapp.utils.py.py_k8s import K8s
k8s_client = K8s(conf.get('CLUSTERS').get(conf.get('ENVIRONMENT')).get('KUBECONFIG'))
k8s_client = K8s(conf.get('CLUSTERS').get(conf.get('ENVIRONMENT')).get('KUBECONFIG',''))
namespace = conf.get('NOTEBOOK_NAMESPACE')
pod_name="docker-%s-%s"%(docker.created_by.username,str(docker.id))
pod = k8s_client.v1.read_namespaced_pod(name=pod_name, namespace=namespace)

View File

@ -138,7 +138,7 @@ class Crd_ModelView_Base():
if 'pipeline-id' in labels:
pipeline = db.session.query(Pipeline).filter_by(id=int(labels['pipeline-id'])).first()
if pipeline:
kubeconfig=pipeline.project.cluster['KUBECONFIG']
kubeconfig=pipeline.project.cluster.get('KUBECONFIG','')
k8s_client = py_k8s.K8s(kubeconfig)
crd_info = conf.get("CRD_INFO", {}).get(self.crd_name, {})