I created this repo as I wanted to learn using client-go
library for accessing Kubernetes API
Install
git clone https://github.com/reetasingh/client-go-examples.git
reetasingh:practice-client-go reetasingh$ go run cmd/list_pods/main.go
reetasingh:practice-client-go reetasingh$ go run cmd/list_namespaces/main.go
reetasingh:practice-client-go reetasingh$ go run cmd/list_pods_with_label_in_namespace/main.go
There are 1 pods in the cluster
Pod name abc
Namespace default
ResourceVersion 735549
Number of containers = 1
Containers
Container Name abc
Container Image nginx
Labels map[run:abc]
Annotations map[]
==================
reetasingh-ltm8:practice-client-go reetasingh$ go run cmd/watch_pods/main.go
pod name abc -
resource version 745618
Pod added
pod name abc -
resource version 745662
Pod modified
pod name abc -
resource version 745666
Pod modified
pod name abc -
resource version 745685
Pod modified
pod name abc -
resource version 745686
Pod deleted
^Z
reetasingh:practice-client-go reetasingh$ go run cmd/get_pod/main.go
Pod name abc
Namespace default
ResourceVersion 779828
Number of containers = 1
Containers
Container Name abc
Container Image nginx
Labels map[run:abc]
Annotations map[]
==================
for other actions check the cmd
directory