当前位置: 首页 > news >正文

使用gcloud SDK 管理和部署 Cloud run service

查看cloud run 上的service 列表:

gcloud run services list

> gcloud run services listSERVICE             REGION        URL                                                 LAST DEPLOYED BY                                              LAST DEPLOYED AT
✔  helloservice        europe-west2  https://helloservice-7hq3m4pdya-nw.a.run.app        terraform@jason-hsbc.iam.gserviceaccount.com                  2023-12-02T18:42:14.055559Z
✔  helloservice2       europe-west2  https://helloservice2-7hq3m4pdya-nw.a.run.app       jason1.pan@maplequad.com                                      2023-12-02T14:58:46.466365Z
✔  java-http-function  europe-west2  https://java-http-function-7hq3m4pdya-nw.a.run.app  service-912156613264@gcf-admin-robot.iam.gserviceaccount.com  2023-11-04T20:57:43.771263Z







获得某个service 的详细信息

gcloud run services describe 《servicename》 --region=《regionname》

 gcloud run services describe helloservice --region=europe-west2
✔ Service helloservice in region europe-west2URL:     https://helloservice-7hq3m4pdya-nw.a.run.app
Ingress: all
Traffic:100% LATEST (currently helloservice-00008-cuv)Last updated on 2023-12-02T18:42:14.055559Z by terraform@jason-hsbc.iam.gserviceaccount.com:Revision helloservice-00008-cuvContainer helloservice-1Image:           europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/helloservice:0.0.2Port:            8080Memory:          512MiCPU:             1000mStartup Probe:TCP every 240sPort:          8080Initial delay: 0sTimeout:       240sFailure threshold: 1Type:          DefaultService account:   vm-common@jason-hsbc.iam.gserviceaccount.comConcurrency:       80Max Instances:     2Timeout:           300s







停止某个service

实际上无这个功能

参考下面google的官方说明
https://cloud.google.com/run/docs/managing/services

Disabling an existing service
Cloud Run does not offer a direct way to make a service stop serving traffic, but you can achieve a similar result by revoking the permission to invoke the service to identities that are invoking the service. Notably, if your service is “public”, remove allUsers from the Cloud Run Invoker role (roles/run.invoker).

建议你直接删除不必要的service, 或者修改权限设置让它不能被访问







删除某个service

gcloud run services delete --region=《regionname》 -q

-q 这里意思是quite , 避免删除确认提问, 小心用就是了

> gcloud run services delete helloservice --region=europe-west2 -q
Deleting [helloservice]...done.                                                                                                                                                                      
Deleted service [helloservice].







部署某个service

重点来了, 部署某个service , 只要service name 和 region相同会覆盖旧的service, 不用先停止再部署

命令行部署 cloud run service 和 在 google console 上部署的是差不多的
https://blog.csdn.net/nvd11/article/details/134725434

命令:
gcloud run deploy 《servicename》
–image=《GAR url / tag name of your image》
–port=《container port》
–platform=managed
–region=《region name》
–min-instances=0
–max-instances=2
–ingress=all
–service-account=《gcp service account name》
–no-allow-unauthenticated or allow-unauthenticated

> gcloud run deploy helloservice \--image=europe-west2-docker.pkg.dev/jason-hsbc/my-docker-repo/helloservice:0.0.1-SNAPSHOT \--port=8080 \--platform=managed \--region=europe-west2 \--min-instances=0 \--max-instances=2 \--ingress=all \--service-account=vm-common@jason-hsbc.iam.gserviceaccount.com \--no-allow-unauthenticated
Deploying container to Cloud Run service [helloservice] in project [jason-hsbc] region [europe-west2]
✓ Deploying new service... Done.                                                                                                                                                                     ✓ Creating Revision...                                                                                                                                                                             ✓ Routing traffic...                                                                                                                                                                               
Done.                                                                                                                                                                                                
Service [helloservice] revision [helloservice-00001-qnk] has been deployed and is serving 100 percent of traffic.
Service URL: https://helloservice-7hq3m4pdya-nw.a.run.app







用Jenkins 自动化部署某个service

这里我把jenkins file 和 jenkins library 发出来作为参考

jenkins file:
https://nvd11.coding.net/p/Jenkins_lib_java_docker/d/jenkins_files/git/tree/master/cloudrun/cloudrun_helloservice.groovy

jenkins lib:
https://nvd11.coding.net/p/Jenkins_lib_java_docker/d/Jenkins_Libs/git/tree/master/vars/build.groovy

在这里插入图片描述

http://www.lryc.cn/news/251069.html

相关文章:

  • JS逆向-mytoken之code参数
  • 第九节HarmonyOS 常用基础组件4-Button
  • 常用数据预处理方法 python
  • 【无标题】AttributeError: module ‘gradio‘ has no attribute ‘outputs‘
  • 无人机助力电力设备螺母缺销智能检测识别,python基于YOLOv7开发构建电力设备螺母缺销小目标检测识别系统
  • 动态页面技术的发展与应用
  • 1-算法基础-编程基础
  • HarmonyOS应用开发——程序框架UIAbility、启动模式与路由跳转
  • node.js-连接SQLserver数据库
  • 目标检测YOLO系列从入门到精通技术详解100篇-【图像处理】图像预处理方法
  • Android drawable layer-list右上角红点,xml布局实现,Kotlin
  • 网络虚拟化场景下网络包的发送过程
  • 《数据结构与测绘程序设计》试题详细解析(仅供参考)
  • Raft 算法
  • Redis队列stream,Redis多线程详解
  • ThinkPHP的方法接收json数据问题
  • 简单理解算法
  • C/C++ 内存管理(2)
  • Net6.0或Net7.0项目升级到Net8.0 并 消除.Net8中SqlSugar的警告
  • 力扣题:字符串的反转-11.22
  • Effective C++(二):对象的初始化
  • 云原生高级--shell自动化脚本备份
  • Spring Boot实现热部署
  • MVCC-
  • 键盘打字盲打练习系列之刻意练习——1
  • 某公司前端笔试题(12.30)
  • Sentinel核心类解读:Node
  • 网络安全领域的12个大语言模型用例
  • 十大网络攻击手段解析,助您建立坚固的网络防线
  • jvm 调优参数