diff --git a/README.md b/README.md index 6384ad382c9c..3410c548ff39 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,10 @@ You'll need Docker and the Go language compilation tools installed. 6. In another terminal window, switch to the directory: $ cd $GOPATH/src/github.com/openshift/origin - $ output/go/bin/openshift kube create services -c examples/test-service.json - + $ output/go/bin/openshift kube create pods -c examples/hello-openshift/hello-pod.json + + 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. + Coming soon: Vagrant environments supporting OpenShift - see [Kubernetes README.md](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/README.md) for now. API diff --git a/examples/hello-openshift/Dockerfile b/examples/hello-openshift/Dockerfile new file mode 100644 index 000000000000..4672929d850e --- /dev/null +++ b/examples/hello-openshift/Dockerfile @@ -0,0 +1,4 @@ +FROM scratch +MAINTAINER Jessica Forrester +ADD hello_openshift /hello_openshift +ENTRYPOINT ["/hello_openshift"] diff --git a/examples/hello-openshift/README.md b/examples/hello-openshift/README.md new file mode 100644 index 000000000000..67d58fd7066a --- /dev/null +++ b/examples/hello-openshift/README.md @@ -0,0 +1,14 @@ +Hello, OpenShift! +----------------- + +This example will serve an http response of "Hello Openshift!" to [http://localhost:6061](http://localhost:6061). To create the pod run: + + $ cd $GOPATH/src/github.com/openshift/origin + $ output/go/bin/openshift kube create pods -c examples/hello-openshift/hello-pod.json + +Contribute +---------- + +For any updates to hello_openshift.go, the hello_openshift binary should be rebuilt using: + + $ CGO_ENABLED=0 go build -a -ldflags '-s' hello_openshift.go \ No newline at end of file diff --git a/examples/hello-openshift/hello-pod.json b/examples/hello-openshift/hello-pod.json new file mode 100644 index 000000000000..f58ee398c017 --- /dev/null +++ b/examples/hello-openshift/hello-pod.json @@ -0,0 +1,22 @@ +{ + "id": "hello-openshift", + "kind": "Pod", + "apiVersion": "v1beta1", + "desiredState": { + "manifest": { + "version": "v1beta1", + "id": "hello-openshift", + "containers": [{ + "name": "hello-openshift", + "image": "openshift/hello-openshift", + "ports": [{ + "containerPort": 8080, + "hostPort": 6061 + }] + }] + } + }, + "labels": { + "name": "hello-openshift" + } +} diff --git a/examples/hello-openshift/hello_openshift b/examples/hello-openshift/hello_openshift new file mode 100755 index 000000000000..74266a1a220a Binary files /dev/null and b/examples/hello-openshift/hello_openshift differ diff --git a/examples/hello-openshift/hello_openshift.go b/examples/hello-openshift/hello_openshift.go new file mode 100644 index 000000000000..413b8fb5afaa --- /dev/null +++ b/examples/hello-openshift/hello_openshift.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "net/http" +) + +func helloHandler(w http.ResponseWriter, r *http.Request) { + fmt.Fprintln(w, "Hello OpenShift!") +} + +func main() { + http.HandleFunc("/", helloHandler) + + fmt.Println("Started, serving at 8080") + err := http.ListenAndServe(":8080", nil) + if err != nil { + panic("ListenAndServe: " + err.Error()) + } +} diff --git a/examples/test-pod-multi.json b/examples/test-pod-multi.json new file mode 100644 index 000000000000..c12030d732bd --- /dev/null +++ b/examples/test-pod-multi.json @@ -0,0 +1,31 @@ +{ + "id": "mongodb-1", + "kind": "Pod", + "desiredState": { + "manifest": { + "version": "v1beta1", + "id": "mongodb-1", + "containers": [ + { + "name": "rockmongo", + "image": "openshift/centos-rockmongo", + "ports": [{ + "containerPort": 80, + "hostPort": 6060 + }] + }, + { + "name": "mongodb", + "image": "openshift/centos-mongodb", + "ports": [{ + "containerPort": 27017, + "hostPort": 27017 + }] + } + ] + } + }, + "labels": { + "name": "mongodb_with_admin" + } +}