GithubHelp home page GithubHelp logo

k8s-rest's Introduction

k8s-rest

Use kubernetes rest API to test out things.

to list various things like nodes, pods, ...

The example uses jsonpath to fish out the names of items.

$ go run main.go
[04:48:47 k8s-rest/main.go:65 main.printResult]                                 
0.000s res=NodeList                                                             
0.001s res=[]interface {}{                                                      
           "kube-master",                                                       
           "kube-node-1",
           "kube-node-2",
       }
0.017s res=PodList
0.018s res=[]interface {}{
           "etcd-kube-master",
           "kube-apiserver-kube-master",
           "kube-controller-manager-kube-master",
           "kube-dns-64d6979467-wrq4c",
           "kube-proxy-kt6lm",
           "kube-proxy-stc9s",
           "kube-proxy-tzt2z",
           "kube-scheduler-kube-master",
           "kubernetes-dashboard-866bbc8b55-g7gqx",
       }
0.094s res=NamespaceList
0.094s res=[]interface {}{
           "default",
           "kube-public",
           "kube-system",
       }
0.100s res=ServiceList
0.100s res=[]interface {}{
           "kubernetes",
...

As printed via q.Q

to test namespace adding

Equivalent of doing

$ kubectl create -f namespace.yaml

is to do

$ go run main.go -namespace namespace.yaml
$ kubectl get namespaces
NAME               STATUS    AGE
default            Active    2d
kube-public        Active    2d
kube-system        Active    2d
test-namespace-1   Active    4s

to create a deployment

Equivalent of doing

$ kubectl apply -f deployment.yaml

is to do

$ go run main.go -deployment deployment.yaml  -namespace test-namespace-1

In this case -namespace is not a file, but the namespace name created before.

To verify:

kubectl get pods --namespace test-namespace-1
NAME          READY     STATUS    RESTARTS   AGE
nginx-82n45   1/1       Running   0          4m

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.