From 344d41f020a6a22d0800e3aac501a015986ffdcd Mon Sep 17 00:00:00 2001
From: Brendan Burns <bburns@microsoft.com>
Date: Fri, 15 Mar 2019 21:42:23 -0700
Subject: [PATCH] Add an example of how to create a pod, fix a bug.

Signed-off-by: Brendan Burns <bburns@microsoft.com>
---
 examples/create-pod/main.go     | 54 +++++++++++++++++++++++++++++++++
 kubernetes/client/api_client.go |  3 ++
 2 files changed, 57 insertions(+)
 create mode 100644 examples/create-pod/main.go

diff --git a/examples/create-pod/main.go b/examples/create-pod/main.go
new file mode 100644
index 0000000..1850942
--- /dev/null
+++ b/examples/create-pod/main.go
@@ -0,0 +1,54 @@
+/*
+Copyright 2019 The Kubernetes Authors.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+// Note: the example only works with the code within the same release/branch.
+package main
+
+import (
+	"context"
+
+	"github.com/kubernetes-client/go/kubernetes/client"
+	"github.com/kubernetes-client/go/kubernetes/config"
+)
+
+func main() {
+	c, err := config.LoadKubeConfig()
+	if err != nil {
+		panic(err.Error())
+	}
+
+	// create the clientset
+	clientset := client.NewAPIClient(c)
+	pod := client.V1Pod{
+		Metadata: &client.V1ObjectMeta{
+			Name:      "my-pod",
+			Namespace: "default",
+		},
+		Spec: &client.V1PodSpec{
+			Containers: []client.V1Container{
+				client.V1Container{
+					Name:  "www",
+					Image: "nginx",
+				},
+			},
+		},
+	}
+
+	_, _, err = clientset.CoreV1Api.CreateNamespacedPod(context.Background(), "default", pod, nil)
+	if err != nil {
+		panic(err)
+	}
+}
diff --git a/kubernetes/client/api_client.go b/kubernetes/client/api_client.go
index 3a1d944..ddf392f 100644
--- a/kubernetes/client/api_client.go
+++ b/kubernetes/client/api_client.go
@@ -184,6 +184,9 @@ func selectHeaderContentType(contentTypes []string) string {
 	if contains(contentTypes, "application/json") {
 		return "application/json"
 	}
+	if contains(contentTypes, "*/*") {
+		return "application/json"
+	}
 	return contentTypes[0] // use the first content type specified in 'consumes'
 }