k8s pod创建过程 watch
时间: 2023-03-10 17:54:51 浏览: 84
Pod创建过程中,Kubernetes会调用一系列API调用,以确保Pod被成功创建。Kubernetes会根据您在Pod定义文件中设置的配置,检查和更新集群状态,并且在必要时启动容器。Kubernetes还会使用watch机制来查看Pod的状态,以确保Pod在创建完成后处于运行状态。
相关问题
write apython code to watch the pod of k8s
基于Python的K8s Pod监控代码如下:from kubernetes import client, config# Configs can be set in Configuration class directly or using helper utility
config.load_kube_config()v1 = client.CoreV1Api()
print("Listing pods with their IPs:")
ret = v1.list_pod_for_all_namespaces(watch=True)
for i in ret.items:
print("%s\t%s\t%s" % (i.status.pod_ip, i.metadata.namespace, i.metadata.name))
k8s sa使用示例
在Kubernetes中,SA(Service Account)是一种用于身份验证和授权的对象。下面是一个k8s SA的使用示例:
1. 创建一个SA对象:kubectl create sa my-sa
2. 创建一个角色:kubectl create role my-role --verb=get,list,watch --resource=pods
3. 将角色绑定到SA上:kubectl create rolebinding my-role-binding --role=my-role --serviceaccount=default:my-sa
4. 使用SA访问API:kubectl run my-pod --image=nginx --serviceaccount=my-sa
在这个示例中,我们首先创建了一个SA对象,然后创建了一个角色并将其绑定到SA上。最后,我们使用SA来创建一个Pod对象。这个Pod将使用SA的身份来访问API,并且只有在角色绑定到SA上时才能访问pods资源。
相关推荐
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)