Skip to content

Repo which contains examples of using client go for various actions and Kubernetes resources

Notifications You must be signed in to change notification settings

reetasingh/client-go-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Repo which contains examples of using client go for various actions and Kubernetes resources

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages