generated from kubernetes/kubernetes-template-project
- Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathmain.c
63 lines (55 loc) · 2.11 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<kube_config.h>
#include<apiClient.h>
#include<CoreV1API.h>
#include<malloc.h>
#include<stdio.h>
#include<errno.h>
voiddelete_a_pod(apiClient_t*apiClient)
{
v1_pod_t*pod=CoreV1API_deleteNamespacedPod(apiClient,
"test-pod-6", // char *name
"default", // char *namespace
NULL, // char *pretty
NULL, // char *dryRun
NULL, // int *gracePeriodSeconds
NULL, // int* ignoreStoreReadErrorWithClusterBreakingPotential
NULL, // int *orphanDependents
NULL, // char *propagationPolicy
NULL// v1_delete_options_t *body
);
printf("The return code of HTTP request=%ld\n", apiClient->response_code);
if (200==apiClient->response_code||202==apiClient->response_code) {
printf("The pod is deleted successfully.\n");
} else {
printf("Failed to delete the pod.\n");
}
if (pod) {
v1_pod_free(pod);
pod=NULL;
}
}
intmain(intargc, char*argv[])
{
char*basePath=NULL;
sslConfig_t*sslConfig=NULL;
list_t*apiKeys=NULL;
intrc=load_kube_config(&basePath, &sslConfig, &apiKeys, NULL); /* NULL means loading configuration from $HOME/.kube/config */
if (rc!=0) {
printf("Cannot load kubernetes configuration.\n");
return-1;
}
apiClient_t*apiClient=apiClient_create_with_base_path(basePath, sslConfig, apiKeys);
if (!apiClient) {
printf("Cannot create a kubernetes client.\n");
return-1;
}
delete_a_pod(apiClient);
apiClient_free(apiClient);
apiClient=NULL;
free_client_config(basePath, sslConfig, apiKeys);
basePath=NULL;
sslConfig=NULL;
apiKeys=NULL;
apiClient_unsetupGlobalEnv();
return0;
}