How to get pod ip?
pods, err := clientset.CoreV1().Pods("mpich-system").List(metav1.ListOptions{})
if err != nil {
// handle error
}
for _, pod := range pods.Items {
fmt.Println(pod.Name, pod.Status.PodIP)
}
@ericchiang Thanks
Pods("") should get the namespace but where do you find it? I am a bit lost it's all the time nil/empty
Now it says I have no access ..
load: "panic: pods is forbidden: User "system:serviceaccount:default:default" cannot list resource "pods" in API group "" in the namespace "default"
I can't make it work.. I tried to manage multiple stuff in the IAM but still nothing..
Now it says I have no access ..
load: "panic: pods is forbidden: User "system:serviceaccount:default:default" cannot list resource "pods" in API group "" in the namespace "default"I can't make it work.. I tried to manage multiple stuff in the IAM but still nothing..
@Emixam23 you need to give appropriate roles to your service account via clusterrolebinding or role binding. The default serviceaccount has not permission to list resources.
For example:
kubectl create role some-role --verb=get --verb=list --verb=watch --verb=update --resource=pods --resource=endpoints --resource=services
kubectl create rolebinding some-role-binding --role=some-role --serviceaccount=default:default
Or you can create a custom serviceaccount and give roles to it and use that serviceaccount.
Most helpful comment