File tree Expand file tree Collapse file tree 8 files changed +37
-8
lines changed
in-cluster-client-configuration
out-of-cluster-client-configuration Expand file tree Collapse file tree 8 files changed +37
-8
lines changed Original file line number Diff line number Diff line change
1
+ # client-go Examples
2
+
3
+ This directory contains examples that cover various use cases and functionality
4
+ for client-go.
5
+
6
+ ### Configuration
7
+
8
+ - [ ** Authenticate in cluster** ] ( ./in-cluster-client-configuration ) : Configure a
9
+ client while running inside the Kubernetes cluster.
10
+ - [ ** Authenticate out of cluster** ] ( ./out-of-cluster-client-configuration ) :
11
+ Configure a client to access a Kubernetes cluster from outside.
12
+
13
+ ### Basics
14
+
15
+ - [ ** Managing resources with API** ] ( ./create-update-delete-deployment ) : Create,
16
+ get, update, delete a Deployment resource.
17
+
18
+ ### Advanced Concepts
19
+
20
+ - [ ** Work queues** ] ( ./workqueue ) : Create a hotloop-free controller with the
21
+ rate-limited workqueue and the [ informer framework] [ informer ] .
22
+ - [ ** Third-party resources (deprecated)** ] ( ./third-party-resources-deprecated ) :
23
+ Register a custom resource type with the API, create/update/query this custom
24
+ type, and write a controller drives the cluster state based on the changes to
25
+ the custom resources.
26
+
27
+ [ informer ] : https://godoc.org/k8s.io/client-go/tools/cache#NewInformer
28
+
Original file line number Diff line number Diff line change 9
9
)
10
10
11
11
go_binary (
12
- name = "in-cluster" ,
12
+ name = "in-cluster-client-configuration " ,
13
13
library = ":go_default_library" ,
14
14
tags = ["automanaged" ],
15
15
)
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
# Authenticating inside the cluster
2
2
3
- This example shows you how you can write an application that authenticates to
4
- the Kubernetes API while it is running on a Kubernetes cluster.
3
+ This example shows you how to configure a client with client-go to authenticate
4
+ to the Kubernetes API from an application running inside the Kubernetes cluster.
5
5
6
6
client-go uses the [ Service Account token] [ sa ] mounted inside the Pod at the
7
7
` /var/run/secrets/kubernetes.io/serviceaccount ` path when the
@@ -11,7 +11,7 @@ client-go uses the [Service Account token][sa] mounted inside the Pod at the
11
11
12
12
First compile the application for Linux:
13
13
14
- cd in-cluster
14
+ cd in-cluster-client-configuration
15
15
GOOS=linux go build -o ./app .
16
16
17
17
Then package it to a docker image using the provided Dockerfile to run it on
File renamed without changes.
Original file line number Diff line number Diff line change 9
9
)
10
10
11
11
go_binary (
12
- name = "out-of-cluster" ,
12
+ name = "out-of-cluster-client-configuration " ,
13
13
library = ":go_default_library" ,
14
14
tags = ["automanaged" ],
15
15
)
Original file line number Diff line number Diff line change 1
1
# Authenticating outside the cluster
2
2
3
- This example shows you how to authenticate to the Kubernetes API from an
4
- application running outside the Kubernetes cluster with client-go.
3
+ This example shows you how to configure a client with client-go to authenticate
4
+ to the Kubernetes API from an application running outside the Kubernetes
5
+ cluster.
5
6
6
7
You can use your kubeconfig file that contains the context information
7
8
of your cluster to initialize a client. The kubeconfig file is also used
@@ -14,7 +15,7 @@ Make sure your `kubectl` is configured and pointed to a cluster. Run
14
15
15
16
Run this application with:
16
17
17
- cd out-of-cluster
18
+ cd out-of-cluster-client-configuration
18
19
go build -o app .
19
20
./app
20
21
File renamed without changes.
You can’t perform that action at this time.
0 commit comments