We expect to provide a go client:
- Flexibility. It can support all Kubernetes-based systems with minimized extra development, such as Openshift, istio, etc.
- Usability. Developers just need to learn to write json/yaml(kubernetes native style) from Kubernetes documentation.
- Integration. It can work with the other Kubernetes clients, such as official.
official | cdk8s | this project | |
---|---|---|---|
Compatibility | for kubernetes-native kinds | for crd kinds | for both |
Support customized Kubernetes resources | a lot of development | a lot of development | zero-deployment |
Works with the other SDKs | complex | complex | simple |
git clone --recursive https://github.com/kubesys/client-go
The easiest way to create a client is:
KubernetesClient client = new KubernetesClient(url, token);
client.Init()
Here, the token can be created and get by following commands:
- create token
kubectl create -f https://raw.githubusercontent.com/kubesys/client-go/master/account.yaml
- get token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep kubernetes-client | awk '{print $1}') | grep "token:" | awk -F":" '{print$2}' | sed 's/ //g'
Assume you have a json:
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"name": "busybox",
"namespace": "default",
"labels": {
"test": "test"
}
}
}
List resources:
client.ListResources("Pod")
Create a resource:
client.CreateResource(json);
Get a resource:
client.GetResource("Pod", "default", "busybox");
Delete a resource::
client.DeleteResource("Pod", "default", "busybox")
fmt.Println(client.GetKinds());
go mod init client-go
go mod tidy
- 1.0.x: product ready
- 1.0.0: using gojson