Closed HaunHsiung closed 3 years ago
tcpdump to track http request would help
You need to print the response body and it should have more info.
I think you can:
printf("%s\n", apiClient->dataReceived);
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale
.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close
.
Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale
/remove-lifecycle stale
I will take a look.
I have written a sample to create/list config maps, it works well at my env.
This sample uses data
other than binary_data
, if you want to use binary_data
, please wait the PR https://github.com/kubernetes-client/c/pull/68 to merge.
void create_configmap(apiClient_t * apiClient)
{
char *api_version = strdup("v1");
char *kind = strdup("ConfigMap");
list_t *data = list_create();
keyValuePair_t *kv = keyValuePair_create(strdup("worker1"), strdup("1"));
list_addElement(data, kv);
kv = keyValuePair_create(strdup("worker2"), strdup("2"));
list_addElement(data, kv);
v1_object_meta_t *meta = v1_object_meta_create(NULL,
NULL,
NULL,
0,
NULL,
NULL,
NULL,
0,
NULL,
NULL,
strdup("cm1"),
strdup("default"),
NULL,
NULL,
NULL,
NULL);
v1_config_map_t *body = v1_config_map_create(api_version,
NULL,
data,
kind,
meta);
v1_config_map_t *ret_config_map = CoreV1API_createNamespacedConfigMap(apiClient,
"default",
body,
NULL,
NULL,
NULL);
printf("%s: The return code of HTTP request=%ld\n", __func__, apiClient->response_code);
if (201 == apiClient->response_code) {
printf("%s: Create the config map successfully.\n", __func__);
} else {
fprintf(stderr, "%s: Failed to create the config map.\n", __func__);
return;
}
if (ret_config_map) {
v1_config_map_free(ret_config_map);
ret_config_map = NULL;
}
if (body) {
v1_config_map_free(body);
body = NULL;
}
}
void list_configmap(apiClient_t * apiClient)
{
v1_config_map_list_t *config_map_list = CoreV1API_listNamespacedConfigMap(apiClient,
"default", // char *namespace
"true", // char *pretty
0, // int allowWatchBookmarks
NULL, // char * _continue
NULL, // char * fieldSelector
NULL, // char * labelSelector
0, // int limit
NULL, // char * resourceVersion
0, // int timeoutSeconds
0 //int watch
);
printf("%s: The return code of HTTP request=%ld\n", __func__, apiClient->response_code);
if (200 == apiClient->response_code) {
printf("%s: List the config maps successfully.\n", __func__);
} else {
fprintf(stderr, "%s: Failed to list the config maps.\n", __func__);
return;
}
if (config_map_list && config_map_list->items) {
listEntry_t *config_map_list_entry = NULL;
v1_config_map_t *config_map = NULL;
list_ForEach(config_map_list_entry, config_map_list->items) {
config_map = config_map_list_entry->data;
printf("\tThe config map name: %s\n", config_map->metadata->name);
listEntry_t *data_entry = NULL;
keyValuePair_t *pair = NULL;
list_ForEach(data_entry, config_map->data) {
pair = data_entry->data;
printf("\tkey=%s, value=%s\n", pair->key, (char *) pair->value);
}
}
v1_config_map_list_free(config_map_list);
config_map_list = NULL;
} else {
fprintf(stderr, "%s: The config map list is invalid.\n", __func__);
}
}
the example given above is my case but return with code 422, seems it is illegal to describe configmap. please help me, thanks a lot! @idvoretskyi @tg123 @webwurst @justaugustus @lavalamp