# flask-k8s **Repository Path**: goooood/flask-k8s ## Basic Information - **Project Name**: flask-k8s - **Description**: No description available - **Primary Language**: Unknown - **License**: GPL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-23 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README flask返回json数据 jsonify: 对数组直接可以使用 Content-Type: application/json json.dumps() 返回类型:Content-Type: text/html; charset=utf-8 #方法1 # return jsonify(list_dict) #方法2 # return json.dumps(list_dict) #方法3 # return Response(json.dumps(list_dict),content_type='application/json') #方法4 同时返回状态 #return make_response(jsonify(list_dict),201) restful访问istio的api 在kubernetes的apigroup中有以下个与istio有关,分别是 authentication.istio.io, config.istio.io, networking.istio.io 其中config.istio.io为最主要的,istio流量控制相关的 routerule, egressrule, destinationpolicie 策略执行相关的 memquota,quota,rule,QuotaSpec,QuotaSpecBinding 监控与日志配置相关的 metric, logentrie http调用相关的 httpapispecbinding, tracespan, httpapispec node =>namesapce => (环境) => 项目 => 应用=> deployment/pod/service(volume,probe,secret,configmap,env,image,label,selector,ports,tolent,taints,status,stragedy) => ingress/gateway rbac=>storageclass=>job=>statefulset=> ctrl+space 提示快捷键 apiVersion: networking.istio.io/v1alpha3 http://192.168.11.51:1900/apis/networking.istio.io/v1alpha3/gateways 2、把其他例子一并搞完(deployment,patch,watch) 3、模仿sparrow例子(写个蓝绿,灰度,(AB的例子)) 4、正式写案例 // 配置服务健康检查使用的 type HealthData struct { // 检查类型 HealthType string // 检查端口 HealthPort string // http访问路径 HealthPath string // 服务启动预计时间 HealthInitialDelay string // 检查间隔 HealthInterval string // 失败阈值 HealthFailureThreshold string // 检查超时 HealthTimeout string // 通过命令检查 HealthCmd string } jsontoyaml https://www.json2yaml.com/ 1、先创建名称空间 问题 表单创建 标签和 service的标签对不上导致 一直503 # 序列化后的表单数据:{"project":"","environment":"dev","cluster":"k8s-cluster1","imageRepo":"myhub.mydocker.com","imageName":"",\ # "imageTag":"","imagePullPolicy":"IfNotPresent","containerPort":"","replicas":"","cpu":"0.25","memory":"0.25","label_key1":"","label_value1":"",\ # "label_key2":"","label_value2":"","probeType":"http","httpPort":"","healthPath":"","tcpPort":"8080","healthCmd":"ls /tmp","initialDelaySeconds":"30",\ # "periodSeconds":"20","failureThreshold":"3","healthTimeout":"10","env":"","volumeMount":"","updateType":""} 1、创建集群 (集群名称,集群的配置文件config,云类型:私有云/公有云) 2、创建环境 3、创建harbor,仓库 4、创建项目,创建命名空间,选择注入(可以删除) 5、创建应用 集群 环境 所属项目 端口 容器镜像 6、应用灰度,回滚, kubernetes.client.rest.ApiException: (409) Reason: Conflict HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Tue, 30 Jun 2020 09:43:31 GMT', 'Content-Length': '202'}) HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"namespaces \"yw-dev\" already exists",\ "reason":"AlreadyExists","details":{"name":"yw-dev","kind":"namespaces"},"code":40 status:409 reason:Conflict body:{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"namespaces \"yw-dev\" already exists","reason":"AlreadyExists","details":{"name":"yw-dev","kind":"namespaces"},"code":409} class ApiException(Exception): def __init__(self, status=None, reason=None, http_resp=None): if http_resp: self.status = http_resp.status self.reason = http_resp.reason self.body = http_resp.data self.headers = http_resp.getheaders() else: self.status = status self.reason = reason self.body = None self.headers = None # for k, v in kwargs.items(): # print ('Optional argument %s (kwargs): %s' % (k, v)) # if claim_ref is not None: # self.claim_ref = claim_ref # if flex_volume is not None: # self.flex_volume = flex_volume # if glusterfs is not None: # self.glusterfs = glusterfs # if host_path is not None: # self.host_path = host_path # if local is not None: # self.local = local # if mount_options is not None: # self.mount_options = mount_options # if persistent_volume_reclaim_policy is not None: # self.persistent_volume_reclaim_policy = persistent_volume_reclaim_policy # if rbd is not None: # self.rbd = rbd # if storage_class_name is not None: # self.storage_class_name = storage_class_name # if storageos is not None: # self.storageos = storageos # if volume_mode is not None: # # self.volume_mode = volume_mode 跟命名空间无关: api版本 node namespaces storageclass pv 有关 deployment pod service configmap secret job cronjob daemonset stateful pvc gateway ingress vs dr 首页: https://istio.io/latest/docs/concepts/traffic-management/ 1、速率限制 2、负载均衡算法 3、熔断 https://istio.io/latest/docs/reference/config/networking/destination-rule/ # 熔断 trafficPolicy: connectionPool: tcp: maxConnections: 1 http: http1MaxPendingRequests: 1 maxRequestsPerConnection: 1 outlierDetection: # 开始拒绝连接的错误个数 consecutiveErrors: 1 interval: 1s baseEjectionTime: 3m maxEjectionPercent: 100 4、内外网 5、跨域(1 失败) 6、鉴权 7、请求超时 timeout: 7s 8、路由(vs,dr,redirect) 9、流量镜像 10、链路跟踪 1、添加agent 定义node label 2、checkout的证书ID 换成m-s里面定义的 credentialsId: 'gitee_account',