Browse code

Add examples for pod creation

Jessica Forrester authored on 2014/08/12 23:32:12
Showing 7 changed files
... ...
@@ -31,8 +31,10 @@ You'll need Docker and the Go language compilation tools installed.
31 31
 6.  In another terminal window, switch to the directory:
32 32
 
33 33
         $ cd $GOPATH/src/github.com/openshift/origin
34
-        $ output/go/bin/openshift kube create services -c examples/test-service.json
35
-    
34
+        $ output/go/bin/openshift kube create pods -c examples/hello-openshift/hello-pod.json
35
+
36
+    You can also try the [multiple container pod](https://github.com/openshift/origin/blob/master/examples/test-pod-multi.json) example that includes a database and an admin front-end.
37
+   
36 38
 Coming soon: Vagrant environments supporting OpenShift - see [Kubernetes README.md](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/README.md) for now.
37 39
 
38 40
 API
39 41
new file mode 100644
... ...
@@ -0,0 +1,4 @@
0
+FROM scratch
1
+MAINTAINER Jessica Forrester <jforrest@redhat.com>
2
+ADD hello_openshift /hello_openshift
3
+ENTRYPOINT ["/hello_openshift"]
0 4
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+Hello, OpenShift!
1
+-----------------
2
+
3
+This example will serve an http response of "Hello Openshift!" to [http://localhost:6061](http://localhost:6061).  To create the pod run:
4
+
5
+        $ cd $GOPATH/src/github.com/openshift/origin
6
+        $ output/go/bin/openshift kube create pods -c examples/hello-openshift/hello-pod.json
7
+
8
+Contribute
9
+----------
10
+
11
+For any updates to hello_openshift.go, the hello_openshift binary should be rebuilt using:
12
+
13
+        $ CGO_ENABLED=0 go build -a -ldflags '-s' hello_openshift.go
0 14
\ No newline at end of file
1 15
new file mode 100644
... ...
@@ -0,0 +1,22 @@
0
+{
1
+  "id": "hello-openshift",
2
+  "kind": "Pod",
3
+  "apiVersion": "v1beta1",
4
+  "desiredState": {
5
+    "manifest": {
6
+      "version": "v1beta1",
7
+      "id": "hello-openshift",
8
+      "containers": [{
9
+        "name": "hello-openshift",
10
+        "image": "openshift/hello-openshift",
11
+        "ports": [{
12
+          "containerPort": 8080,
13
+          "hostPort": 6061
14
+        }]
15
+      }]
16
+    }
17
+  },
18
+  "labels": {
19
+    "name": "hello-openshift"
20
+  }
21
+}
0 22
new file mode 100755
1 23
Binary files /dev/null and b/examples/hello-openshift/hello_openshift differ
2 24
new file mode 100644
... ...
@@ -0,0 +1,20 @@
0
+package main
1
+
2
+import (
3
+	"fmt"
4
+	"net/http"
5
+)
6
+
7
+func helloHandler(w http.ResponseWriter, r *http.Request) {
8
+	fmt.Fprintln(w, "Hello OpenShift!")
9
+}
10
+
11
+func main() {
12
+	http.HandleFunc("/", helloHandler)
13
+
14
+	fmt.Println("Started, serving at 8080")
15
+	err := http.ListenAndServe(":8080", nil)
16
+	if err != nil {
17
+		panic("ListenAndServe: " + err.Error())
18
+	}
19
+}
0 20
new file mode 100644
... ...
@@ -0,0 +1,31 @@
0
+{
1
+  "id": "mongodb-1",
2
+  "kind": "Pod",
3
+  "desiredState": {
4
+    "manifest": {
5
+      "version": "v1beta1",
6
+      "id": "mongodb-1",
7
+      "containers": [
8
+        {
9
+          "name": "rockmongo",
10
+          "image": "openshift/centos-rockmongo",
11
+          "ports": [{
12
+            "containerPort": 80,
13
+            "hostPort": 6060
14
+          }]
15
+        },
16
+        {
17
+          "name": "mongodb",
18
+          "image": "openshift/centos-mongodb",
19
+          "ports": [{
20
+            "containerPort": 27017,
21
+            "hostPort": 27017
22
+          }]
23
+        }
24
+      ]
25
+    }
26
+  },
27
+  "labels": {
28
+    "name": "mongodb_with_admin"
29
+  }
30
+}