简体   繁体   English

我想使用 kube.netes API 从 AWS Lambda function 重新启动部署

[英]I want to use kubernetes API to restart the deployment from the AWS Lambda function

I have a eks cluster where I have a pod A and I want to deploy a new pod B that is dedicated to be used to restart the deployment of pod A via kube.netes api such that I call an LB service of POD B from lambda in such form it will restart the deployment of pod A,just looking forward on how we can achieve that,It would be really great if anyone can assist on this.我有一个 eks 集群,其中有一个 pod A,我想部署一个新的 pod B,专门用于通过 kube.netes api 重新启动 pod A 的部署,以便我从 lambda 调用 POD B 的 LB 服务以这种形式,它将重新启动 pod A 的部署,只是期待我们如何实现这一目标,如果有人可以提供帮助,那就太好了。

An Approach on how to restart the pod from another pod using kube.netes API关于如何使用 kube.netes 从另一个 pod 重启 pod 的方法 API

You can check for the client library and use it for restarting the POD.您可以检查客户端库并将其用于重新启动 POD。

List of K8s library: https://kube.netes.io/docs/reference/using-api/client-libraries/ K8s库列表: https://kube.netes.io/docs/reference/using-api/client-libraries/

If you use python :如果您使用python

from kubernetes import client, config, watch
import json
import requests
import time
logger = logging.getLogger('k8s_events')
logger.setLevel(logging.DEBUG)

# If running inside pod
#config.load_incluster_config()

# If running locally
config.load_kube_config()

v1 = client.CoreV1Api()
v1ext = client.ExtensionsV1beta1Api() 

way to authenticate the with K8s cluster, you can also use the service account to authenticate and further add the method to restart the POD.与K8s集群认证的方式,也可以使用服务账号认证,进一步添加重启POD的方式。

If your cluster is exposed or proxy there you can also patch deployment so which will also auto restart the deployment(POD).如果您的集群暴露或在那里代理,您还可以修补部署,这样也将自动重新启动部署 (POD)。

curl -k --data '{"spec":{"template":{"metadata":{"annotations":{"kubectl.kubrnetes.io/restartedAt":"'"$(date +%Y-%m-%dT%T%z)"'"}}}}}' -XPATCH   -H "Accept: application/json, */*" -H "Content-Type: application/strategic-merge-patch+json" localhost:8001/apis/extensions/v1beta1/namespaces/default/deployments/<name of deployment> 

Extra :额外的

If you don't want to run API you can also run the kubectl command on the cluster and restat the POD A from POD B.如果您不想运行API ,您还可以在集群上运行kubectl命令并从 POD B 重新启动 POD A。

Ref: https://itnext.io/running-kubectl-commands-from-within-a-pod-b303e8176088参考: https://itnext.io/running-kubectl-commands-from-within-a-pod-b303e8176088

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想在从 cli 调用时在 aws Lambda 中传递参数 - I want to pass parameters in aws Lambda while invoking from cli 从 eventbridge api 目的地调用 AWS Lambda Function URL - Invoke AWS Lambda Function URL from eventbridge api destination 是否可以从 AWS 无服务器 API 中的其他 lambda 函数调用 lambda function? - Is it possible to call lambda function from other lambda functions in AWS serverless API? AWS lambda ResourceConflictException 部署 - AWS lambda ResourceConflictException on deployment 在 AWS Lambda 中运行 .NET 6 Web API 项目,部署为 ZIP - Running .NET 6 Web API project in AWS Lambda with ZIP deployment AWS python lambda 部署 package 我怎样才能从源代码管理中提取源代码或 package? - AWS python lambda deployment package how can i just pull the source or package from source control? 如何将 AWS Lambda function 列入 Google API 的白名单 - How to whitelist AWS Lambda function for Google API 我可以使用 AWS Lambda 来满足我的要求吗? - Can I use AWS Lambda for my requirements? 在没有 lambda 的情况下,我如何以及可以使用什么将 AWS API 网关连接到 RDS? - How & what can i use to connect AWS API-Gateways to RDS without lambda? AWS API Gateway 忽略从自定义授权方 Lambda 函数返回的身份验证策略 - AWS API Gateway ignores auth policy returned from the Custom Authorizer Lambda Function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM