云应用引擎 CAE-创建组件配置:请求示例
时间:2024-11-08 17:47:00
请求示例
- 创建云数据库RDS组件配置,数据库名称为“cae”,地址为100.xx.xx.xxx,端口号为3306。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "rds", "data" : { "spec" : { "rds_id" : "a5fdee4cf88c4277a68688a014f444bdin01", "rds_db_name" : "cae", "rds_address" : "100.xx.xx.xxx", "rds_username" : "cae", "rds_password" : "xxx", "rds_port" : "3306" } } } ] }
- 创建 微服务引擎CSE 组件配置,配置中心地址:“https://192.168.1.xxx:30103,https://192.168.1.xxx:30103”,服务注册发现地址:“https://192.168.1.xxx:30100,https://192.168.1.xxx:30100”。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "cse", "data" : { "spec" : { "config_center_addr" : "https://192.168.1.xxx:30103,https://192.168.1.xxx:30103", "service_center_addr" : "https://192.168.1.xxx:30100,https://192.168.1.xxx:30100", "cse_id" : "25779525-1aac-44be-abda-f9164f1b41b8" } } } ] }
- 创建环境变量组件配置,配置时区为Asia/Shanghai,且注入一个名称为password的凭据作为环境变量。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "env", "data" : { "spec" : { "envs" : { "TZ" : "Asia/Shanghai" }, "env_references" : { "env_name" : "db_password", "value_from" : { "name" : "password", "reference_type" : "dewSecret" } } } } } ] }
- 创建内网访问方式和负载均衡类型的外网访问方式组件配置。
- 内网访问方式类型为ClusterIP,监听端口为80,访问端口为8080,协议为TCP。
- 外网访问方式类型为LoadBalancer,监听端口为80,访问端口为9090,协议为TCP,配置白名单访问控制,仅允许170.126.0.0/16网段的用户访问。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "access", "data" : { "spec" : { "items" : [ { "type" : "ClusterIP", "ports" : [ { "target_port" : 80, "port" : 8080, "protocol" : "TCP" } ] }, { "type" : "LoadBalancer", "access_control" : { "type" : "white", "ip_list" : [ "170.126.0.0/16" ] }, "elb_id" : "xxx", "ports" : [ { "target_port" : 80, "port" : 9090, "protocol" : "TCP" } ] } ] } } } ] }
- 创建转发策略类型的外网访问方式组件配置,如下请求示例配置了两条转发策略,两条策略的对外协议为HTTPS、负载均衡策略为默认策略,使用加权轮询算法、访问端口为8443,配置黑名单访问策略,不允许10.120.1.1和10.120.1.2这两个IP访问,安全策略为tls-1-2-strict,服务器默认证书是test。
- 第一条转发策略 域名 设置为test.example.com,URL匹配规则为前缀匹配,匹配路径为/test1,监听端口设置为80,第一条访问策略未配置域名证书对,使用默认证书test。
- 第二条转发策略域名设置为test.example.cn,URL匹配规则为前缀匹配,匹配路径为/test2,监听端口设置为80,第二条访问策略配置了域名证书对,使用域名证书对中的证书test1。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "access", "data" : { "spec" : { "items" : [ { "type" : "Ingress", "access_control" : { "type" : "black", "ip_list" : [ "10.120.1.1", "10.120.1.2" ] }, "ports" : [ { "port" : 8443, "protocol" : "HTTPS", "default_certificate" : "test", "policy" : "tls-1-2-strict", "target_port" : 80, "paths" : [ { "path" : "/test1", "url_match_mode" : "STARTS_WITH", "hostname" : "test.example.com" } ] }, { "port" : 8443, "protocol" : "HTTPS", "default_certificate" : "test", "certificate" : "test1", "policy" : "tls-1-2-strict", "target_port" : 80, "paths" : [ { "path" : "/test2", "url_match_mode" : "STARTS_WITH", "hostname" : "test.example.cn" } ] } ] } ] }, "metadata" : { "annotations" : { "kubernetes.io/elb.health-check-flag" : "off", "kubernetes.io/elb.lb-algorithm" : "ROUND_ROBIN" } } } } ] }
- 创建伸缩策略组件配置,配置最大实例数3个,最小实例数1个,cpu使用率30%,内存使用率30%,缩容冷却时间窗5分钟,每次最大缩容99个实例,最大扩容4个实例,禁止缩容功能关闭。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "scaling", "data" : { "spec" : { "scale_strategy" : "metric", "max_replica_count" : 3, "min_replica_count" : 1, "advanced" : { "scaledown_stabilization_seconds" : 300, "scaledown_rate" : 99, "scaleup_stabilization_seconds" : 0, "scaleup_rate" : 4, "disable_scaledown" : false }, "triggers" : [ { "metadata" : { "type" : "Utilization", "value" : "30" }, "type" : "cpu" }, { "metadata" : { "type" : "Utilization", "value" : "30" }, "type" : "memory" } ] } } } ] }
- 创建 云存储 配置组件配置(OBS桶配置、OBS并行文件系统、SFS3.0容量型配置),配置存储桶,挂载路径为/tmp,权限设置为读写;配置并行文件系统,挂载路径为/temp,权限设置为读写。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "volume", "data" : { "spec" : { "volumes" : [ { "volume_id" : "bef119d0-c7d1-4b58-9794-8b74faf80a59", "resource_name" : "test-nacos", "resource_type" : "obs", "resource_sub_type" : "object_bucket", "umask" : "0027", "mount_info" : [ { "path" : "/tmp", "access_mode" : "ReadWriteMany" } ] }, { "mount_info" : [ { "path" : "/temp", "access_mode" : "ReadWriteMany" } ], "volume_id" : "a061934d-52e3-4b36-aea7-6c51879f84c9", "resource_name" : "test", "resource_type" : "obs", "resource_sub_type" : "parallel_file_system", "umask" : "0027" } ] } } } ] }
- 创建健康检查组件配置(配置存活探针、就绪探针、启动探针)。
- 配置存活探针,类型为livenessProbe,检测周期10s,延迟时间1s,超时时间1s,成功阈值1,最大失败次数3,端口为80,协议HTTP,路径、请求头未设置。
- 配置就绪探针,类型为readinessProbe,检测周期10s,延迟时间0s(0可不传),超时时间1s,成功阈值1,最大失败次数3,端口为80,协议HTTP,路径、请求头未设置。
- 配置启动探针,类型为startupProbe,检测周期10s,延迟时间0s(0可不传),超时时间1s,成功阈值1,最大失败次数3,端口为80,协议HTTP,路径未设置,请求头设置x-auth-token。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "healthCheck", "data" : { "spec" : { "livenessProbe" : { "periodSeconds" : 10, "initialDelaySeconds" : 1, "timeoutSeconds" : 1, "successThreshold" : 1, "failureThreshold" : 3, "httpGet" : { "path" : "", "port" : 80, "httpHeaders" : [ ], "scheme" : "HTTP" } }, "startupProbe" : { "periodSeconds" : 10, "timeoutSeconds" : 1, "successThreshold" : 1, "failureThreshold" : 3, "httpGet" : { "path" : "", "port" : 80, "httpHeaders" : [ { "name" : "x-auth-token", "value" : "xxx" } ], "scheme" : "HTTP" } }, "readinessProbe" : { "periodSeconds" : 10, "timeoutSeconds" : 1, "successThreshold" : 1, "failureThreshold" : 3, "httpGet" : { "path" : "", "port" : 80, "httpHeaders" : [ ], "scheme" : "HTTP" } } } } } ] }
- 创建生命周期管理组件配置(配置启动后处理、停止前处理)。配置启动后命令脚本“/bin/sh -c "echo service start"”,配置停止前命令脚本“/bin/sh -c "echo service end"”。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "lifecycle", "data" : { "spec" : { "postStart" : { "exec" : { "command" : [ "/bin/sh", "-c", "echo service start" ] } }, "preStop" : { "exec" : { "command" : [ "/bin/sh", "-c", "echo service end" ] } } } } } ] }
- 创建自定义日志配置,创建自定义路径“/var/log/error.log”。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "log", "data" : { "spec" : { "log_paths" : [ "/var/log/error.log" ] } } } ] }
- 创建性能管理配置,探针注入方式为自动注入。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "apm2", "data" : { "spec" : { "instrumentation" : "automatic" } } } ] }
- 创建自定义监控指标配置,采集路径为/metrics,采集端口为2112,指定一个自定义监控指标,名称为myapp_processed_ops_total。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "customMetric", "data" : { "spec" : { "path" : "/metrics", "port" : 2112, "metrics" : [ "myapp_processed_ops_total" ] } } } ] }
- 使用增删改模式新增转发策略类型的外网访问方式组件配置,如下请求示例配置了基于最后一次生效配置中uid为“1”的访问方式中uid为“1-1”的转发策略配置,修改了监听端口为8080,URL为/test3,域名为test.example.com,URL匹配规则为正则匹配并且剩余字段保持不变后新增到原有配置中。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "access", "data" : { "spec" : { "items" : [ { "operator" : "modify", "uid" : 1, "ports" : [ { "operator" : "copy", "uid" : "1-1", "target_port" : 8080, "paths" : [ { "path" : "/test3", "url_match_mode" : "REGEX", "hostname" : "test.example.com" } ] } ] } ] } } } ] }
- 使用增删改模式删除转发策略类型的外网访问方式组件配置,如下请求示例配置了将最后一次生效配置中uid为“1”的访问方式中uid为“1-2”的转发策略配置删除。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "access", "data" : { "spec" : { "items" : [ { "operator" : "modify", "uid" : 1, "ports" : [ { "operator" : "delete", "uid" : "1-2" } ] } ] } } } ] }
- 使用增删改模式修改转发策略类型的外网访问方式组件配置,如下请求示例配置了将最后一次生效配置中uid为“1”的访问方式中uid为“1-2”的转发策略配置,只修改监听端口为8081。
POST https://{endpoint}/v1/{project_id}/cae/applications/{application_id}/components/{component_id}/configurations { "api_version" : "v1", "kind" : "ComponentConfiguration", "items" : [ { "type" : "access", "data" : { "spec" : { "items" : [ { "operator" : "modify", "uid" : 1, "ports" : [ { "operator" : "modify", "uid" : "1-2", "target_port" : 8081 } ] } ] } } } ] }
support.huaweicloud.com/api-cae/CreateComponentConfiguration.html
看了此文的人还看了
CDN加速
GaussDB
文字转换成语音
免费的服务器
如何创建网站
域名网站购买
私有云桌面
云主机哪个好
域名怎么备案
手机云电脑
SSL证书申请
云点播服务器
免费OCR是什么
电脑云桌面
域名备案怎么弄
语音转文字
文字图片识别
云桌面是什么
网址安全检测
网站建设搭建
国外CDN加速
SSL免费证书申请
短信批量发送
图片OCR识别
云数据库MySQL
个人域名购买
录音转文字
扫描图片识别文字
OCR图片识别
行驶证识别
虚拟电话号码
电话呼叫中心软件
怎么制作一个网站
Email注册网站
华为VNC
图像文字识别
企业网站制作
个人网站搭建
华为云计算
免费租用云托管
云桌面云服务器
ocr文字识别免费版
HTTPS证书申请
图片文字识别转换
国外域名注册商
使用免费虚拟主机
云电脑主机多少钱
鲲鹏云手机
短信验证码平台
OCR图片文字识别
SSL证书是什么
申请企业邮箱步骤
免费的企业用邮箱
云免流搭建教程
域名价格
推荐文章