Skip to content

Latest commit

 

History

History
85 lines (66 loc) · 1.53 KB

README.md

File metadata and controls

85 lines (66 loc) · 1.53 KB

client-go-examples

I created this repo as I wanted to learn using client-go library for accessing Kubernetes API

Instructions to use

Install

git clone https://github.com/reetasingh/client-go-examples.git

Examples

List Pods

reetasingh:practice-client-go reetasingh$ go run cmd/list_pods/main.go 

List Namespaces

reetasingh:practice-client-go reetasingh$ go run cmd/list_namespaces/main.go 

List pods with label run=abc

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[]
==================

Watch event on pod (Added/Modified/Deleted)

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

Get pod

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