2014-06-06 23:40:48 +00:00
|
|
|
/*
|
|
|
|
Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2014-06-11 20:03:46 +00:00
|
|
|
|
2014-06-06 23:40:48 +00:00
|
|
|
// A basic integration test for the service.
|
|
|
|
// Assumes that there is a pre-existing etcd server running on localhost.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
2014-06-24 23:31:33 +00:00
|
|
|
"net/http"
|
2014-06-06 23:40:48 +00:00
|
|
|
"net/http/httptest"
|
2014-07-02 20:51:27 +00:00
|
|
|
"reflect"
|
2014-06-27 03:24:10 +00:00
|
|
|
"runtime"
|
2014-07-02 20:51:27 +00:00
|
|
|
"sync"
|
2014-06-06 23:40:48 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
2014-09-11 17:02:53 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest"
|
2014-08-09 21:12:55 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/apiserver"
|
2014-06-11 20:03:46 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
2014-06-18 00:57:06 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/controller"
|
2014-06-24 01:28:06 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet"
|
2014-07-15 20:24:41 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/config"
|
2014-09-09 04:33:17 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
2014-07-01 20:30:19 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
2014-06-24 01:28:06 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/master"
|
2014-06-25 03:51:57 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
|
2014-08-18 21:42:08 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
|
2014-08-21 20:35:50 +00:00
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler"
|
|
|
|
"github.com/GoogleCloudPlatform/kubernetes/plugin/pkg/scheduler/factory"
|
|
|
|
|
2014-06-06 23:40:48 +00:00
|
|
|
"github.com/coreos/go-etcd/etcd"
|
2014-06-25 03:51:57 +00:00
|
|
|
"github.com/golang/glog"
|
2014-06-06 23:40:48 +00:00
|
|
|
)
|
|
|
|
|
2014-07-01 20:30:19 +00:00
|
|
|
var (
|
2014-09-09 04:33:17 +00:00
|
|
|
fakeDocker1, fakeDocker2 dockertools.FakeDockerClient
|
2014-07-01 20:30:19 +00:00
|
|
|
)
|
2014-06-27 22:02:06 +00:00
|
|
|
|
2014-07-02 00:08:32 +00:00
|
|
|
type fakePodInfoGetter struct{}
|
|
|
|
|
|
|
|
func (fakePodInfoGetter) GetPodInfo(host, podID string) (api.PodInfo, error) {
|
|
|
|
// This is a horrible hack to get around the fact that we can't provide
|
|
|
|
// different port numbers per kubelet...
|
|
|
|
var c client.PodInfoGetter
|
|
|
|
switch host {
|
|
|
|
case "localhost":
|
|
|
|
c = &client.HTTPPodInfoGetter{
|
|
|
|
Client: http.DefaultClient,
|
|
|
|
Port: 10250,
|
|
|
|
}
|
|
|
|
case "machine":
|
|
|
|
c = &client.HTTPPodInfoGetter{
|
|
|
|
Client: http.DefaultClient,
|
|
|
|
Port: 10251,
|
|
|
|
}
|
|
|
|
default:
|
2014-08-21 20:35:50 +00:00
|
|
|
glog.Fatalf("Can't get info for: '%v', '%v'", host, podID)
|
2014-07-02 00:08:32 +00:00
|
|
|
}
|
|
|
|
return c.GetPodInfo("localhost", podID)
|
|
|
|
}
|
|
|
|
|
2014-07-18 20:22:26 +00:00
|
|
|
type delegateHandler struct {
|
|
|
|
delegate http.Handler
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *delegateHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|
|
|
if h.delegate != nil {
|
|
|
|
h.delegate.ServeHTTP(w, req)
|
2014-07-26 23:09:15 +00:00
|
|
|
return
|
2014-07-18 20:22:26 +00:00
|
|
|
}
|
|
|
|
w.WriteHeader(http.StatusNotFound)
|
|
|
|
}
|
|
|
|
|
2014-07-01 20:30:19 +00:00
|
|
|
func startComponents(manifestURL string) (apiServerURL string) {
|
2014-06-06 23:40:48 +00:00
|
|
|
// Setup
|
|
|
|
servers := []string{"http://localhost:4001"}
|
2014-06-25 03:51:57 +00:00
|
|
|
glog.Infof("Creating etcd client pointing to %v", servers)
|
2014-06-24 01:28:06 +00:00
|
|
|
machineList := []string{"localhost", "machine"}
|
2014-06-06 23:40:48 +00:00
|
|
|
|
2014-07-18 20:22:26 +00:00
|
|
|
handler := delegateHandler{}
|
2014-08-09 21:12:55 +00:00
|
|
|
apiServer := httptest.NewServer(&handler)
|
2014-07-15 20:24:41 +00:00
|
|
|
|
|
|
|
etcdClient := etcd.NewClient(servers)
|
2014-08-28 04:32:04 +00:00
|
|
|
keys, err := etcdClient.Get("/", false, false)
|
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Unable to list root etcd keys: %v", err)
|
|
|
|
}
|
|
|
|
for _, node := range keys.Node.Nodes {
|
|
|
|
if _, err := etcdClient.Delete(node.Key, true); err != nil {
|
|
|
|
glog.Fatalf("Unable delete key: %v", err)
|
|
|
|
}
|
|
|
|
}
|
2014-07-15 20:24:41 +00:00
|
|
|
|
2014-08-28 13:56:38 +00:00
|
|
|
cl := client.NewOrDie(apiServer.URL, nil)
|
2014-07-08 06:30:18 +00:00
|
|
|
cl.PollPeriod = time.Second * 1
|
|
|
|
cl.Sync = true
|
2014-07-18 20:22:26 +00:00
|
|
|
|
|
|
|
// Master
|
2014-07-27 02:16:39 +00:00
|
|
|
m := master.New(&master.Config{
|
|
|
|
Client: cl,
|
|
|
|
EtcdServers: servers,
|
|
|
|
Minions: machineList,
|
|
|
|
PodInfoGetter: fakePodInfoGetter{},
|
|
|
|
})
|
2014-08-09 21:12:55 +00:00
|
|
|
storage, codec := m.API_v1beta1()
|
|
|
|
handler.delegate = apiserver.Handle(storage, codec, "/api/v1beta1")
|
2014-07-18 20:22:26 +00:00
|
|
|
|
2014-08-21 20:35:50 +00:00
|
|
|
// Scheduler
|
|
|
|
scheduler.New((&factory.ConfigFactory{cl}).Create()).Run()
|
|
|
|
|
2014-08-21 04:27:19 +00:00
|
|
|
controllerManager := controller.NewReplicationManager(cl)
|
2014-07-20 19:00:52 +00:00
|
|
|
|
|
|
|
// Prove that controllerManager's watch works by making it not sync until after this
|
|
|
|
// test is over. (Hopefully we don't take 10 minutes!)
|
|
|
|
controllerManager.Run(10 * time.Minute)
|
2014-06-06 23:40:48 +00:00
|
|
|
|
2014-07-15 20:24:41 +00:00
|
|
|
// Kubelet (localhost)
|
|
|
|
cfg1 := config.NewPodConfig(config.PodConfigNotificationSnapshotAndUpdates)
|
2014-08-19 03:45:37 +00:00
|
|
|
config.NewSourceEtcd(config.EtcdKeyForHost(machineList[0]), etcdClient, cfg1.Channel("etcd"))
|
2014-07-15 20:24:41 +00:00
|
|
|
config.NewSourceURL(manifestURL, 5*time.Second, cfg1.Channel("url"))
|
2014-07-22 21:40:59 +00:00
|
|
|
myKubelet := kubelet.NewIntegrationTestKubelet(machineList[0], &fakeDocker1)
|
2014-07-15 20:24:41 +00:00
|
|
|
go util.Forever(func() { myKubelet.Run(cfg1.Updates()) }, 0)
|
|
|
|
go util.Forever(func() {
|
2014-08-20 18:24:51 +00:00
|
|
|
kubelet.ListenAndServeKubeletServer(myKubelet, cfg1.Channel("http"), "localhost", 10250)
|
2014-07-15 20:24:41 +00:00
|
|
|
}, 0)
|
2014-06-24 01:28:06 +00:00
|
|
|
|
2014-07-15 20:24:41 +00:00
|
|
|
// Kubelet (machine)
|
2014-06-29 05:16:26 +00:00
|
|
|
// Create a second kubelet so that the guestbook example's two redis slaves both
|
2014-06-24 01:28:06 +00:00
|
|
|
// have a place they can schedule.
|
2014-07-15 20:24:41 +00:00
|
|
|
cfg2 := config.NewPodConfig(config.PodConfigNotificationSnapshotAndUpdates)
|
2014-08-19 03:45:37 +00:00
|
|
|
config.NewSourceEtcd(config.EtcdKeyForHost(machineList[1]), etcdClient, cfg2.Channel("etcd"))
|
2014-07-22 21:40:59 +00:00
|
|
|
otherKubelet := kubelet.NewIntegrationTestKubelet(machineList[1], &fakeDocker2)
|
2014-07-15 20:24:41 +00:00
|
|
|
go util.Forever(func() { otherKubelet.Run(cfg2.Updates()) }, 0)
|
|
|
|
go util.Forever(func() {
|
2014-08-20 18:24:51 +00:00
|
|
|
kubelet.ListenAndServeKubeletServer(otherKubelet, cfg2.Channel("http"), "localhost", 10251)
|
2014-07-15 20:24:41 +00:00
|
|
|
}, 0)
|
2014-06-24 01:28:06 +00:00
|
|
|
|
2014-08-09 21:12:55 +00:00
|
|
|
return apiServer.URL
|
2014-07-01 20:30:19 +00:00
|
|
|
}
|
2014-06-06 23:40:48 +00:00
|
|
|
|
2014-08-18 21:42:08 +00:00
|
|
|
// podsOnMinions returns true when all of the selected pods exist on a minion.
|
|
|
|
func podsOnMinions(c *client.Client, pods api.PodList) wait.ConditionFunc {
|
|
|
|
podInfo := fakePodInfoGetter{}
|
|
|
|
return func() (bool, error) {
|
|
|
|
for i := range pods.Items {
|
|
|
|
host, id := pods.Items[i].CurrentState.Host, pods.Items[i].ID
|
|
|
|
if len(host) == 0 {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
if _, err := podInfo.GetPodInfo(host, id); err != nil {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func runReplicationControllerTest(c *client.Client) {
|
2014-06-06 23:40:48 +00:00
|
|
|
data, err := ioutil.ReadFile("api/examples/controller.json")
|
|
|
|
if err != nil {
|
2014-06-25 03:51:57 +00:00
|
|
|
glog.Fatalf("Unexpected error: %#v", err)
|
2014-06-06 23:40:48 +00:00
|
|
|
}
|
|
|
|
var controllerRequest api.ReplicationController
|
2014-08-04 22:52:59 +00:00
|
|
|
if err := json.Unmarshal(data, &controllerRequest); err != nil {
|
2014-06-25 03:51:57 +00:00
|
|
|
glog.Fatalf("Unexpected error: %#v", err)
|
2014-06-06 23:40:48 +00:00
|
|
|
}
|
|
|
|
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Infof("Creating replication controllers")
|
2014-09-08 04:14:18 +00:00
|
|
|
if _, err := c.CreateReplicationController(&controllerRequest); err != nil {
|
2014-06-25 03:51:57 +00:00
|
|
|
glog.Fatalf("Unexpected error: %#v", err)
|
2014-06-06 23:40:48 +00:00
|
|
|
}
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Infof("Done creating replication controllers")
|
|
|
|
|
2014-06-09 05:38:45 +00:00
|
|
|
// Give the controllers some time to actually create the pods
|
2014-08-22 15:36:01 +00:00
|
|
|
if err := wait.Poll(time.Second, time.Second*10, c.ControllerHasDesiredReplicas(controllerRequest)); err != nil {
|
2014-08-18 21:42:08 +00:00
|
|
|
glog.Fatalf("FAILED: pods never created %v", err)
|
|
|
|
}
|
2014-06-06 23:40:48 +00:00
|
|
|
|
2014-08-18 21:42:08 +00:00
|
|
|
// wait for minions to indicate they have info about the desired pods
|
|
|
|
pods, err := c.ListPods(labels.Set(controllerRequest.DesiredState.ReplicaSelector).AsSelector())
|
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("FAILED: unable to get pods to list: %v", err)
|
2014-06-06 23:40:48 +00:00
|
|
|
}
|
2014-09-08 04:14:18 +00:00
|
|
|
if err := wait.Poll(time.Second, time.Second*10, podsOnMinions(c, *pods)); err != nil {
|
2014-08-18 21:42:08 +00:00
|
|
|
glog.Fatalf("FAILED: pods never started running %v", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
glog.Infof("Pods created")
|
2014-07-01 20:30:19 +00:00
|
|
|
}
|
|
|
|
|
2014-07-02 20:51:27 +00:00
|
|
|
func runAtomicPutTest(c *client.Client) {
|
|
|
|
var svc api.Service
|
|
|
|
err := c.Post().Path("services").Body(
|
2014-09-08 04:14:18 +00:00
|
|
|
&api.Service{
|
2014-09-11 17:02:53 +00:00
|
|
|
JSONBase: api.JSONBase{ID: "atomicservice", APIVersion: latest.Version},
|
2014-07-02 20:51:27 +00:00
|
|
|
Port: 12345,
|
|
|
|
Labels: map[string]string{
|
|
|
|
"name": "atomicService",
|
|
|
|
},
|
2014-07-11 04:14:46 +00:00
|
|
|
// This is here because validation requires it.
|
|
|
|
Selector: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
2014-07-02 20:51:27 +00:00
|
|
|
},
|
|
|
|
).Do().Into(&svc)
|
|
|
|
if err != nil {
|
|
|
|
glog.Fatalf("Failed creating atomicService: %v", err)
|
|
|
|
}
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Info("Created atomicService")
|
2014-07-11 04:14:46 +00:00
|
|
|
testLabels := labels.Set{
|
|
|
|
"foo": "bar",
|
|
|
|
}
|
2014-07-07 18:44:14 +00:00
|
|
|
for i := 0; i < 5; i++ {
|
2014-07-02 20:51:27 +00:00
|
|
|
// a: z, b: y, etc...
|
|
|
|
testLabels[string([]byte{byte('a' + i)})] = string([]byte{byte('z' - i)})
|
|
|
|
}
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(len(testLabels))
|
|
|
|
for label, value := range testLabels {
|
|
|
|
go func(l, v string) {
|
|
|
|
for {
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Infof("Starting to update (%s, %s)", l, v)
|
2014-07-02 20:51:27 +00:00
|
|
|
var tmpSvc api.Service
|
2014-07-20 19:00:52 +00:00
|
|
|
err := c.Get().
|
|
|
|
Path("services").
|
|
|
|
Path(svc.ID).
|
|
|
|
PollPeriod(100 * time.Millisecond).
|
|
|
|
Do().
|
|
|
|
Into(&tmpSvc)
|
2014-07-02 20:51:27 +00:00
|
|
|
if err != nil {
|
|
|
|
glog.Errorf("Error getting atomicService: %v", err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if tmpSvc.Selector == nil {
|
|
|
|
tmpSvc.Selector = map[string]string{l: v}
|
|
|
|
} else {
|
|
|
|
tmpSvc.Selector[l] = v
|
|
|
|
}
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Infof("Posting update (%s, %s)", l, v)
|
2014-07-02 20:51:27 +00:00
|
|
|
err = c.Put().Path("services").Path(svc.ID).Body(&tmpSvc).Do().Error()
|
|
|
|
if err != nil {
|
|
|
|
if se, ok := err.(*client.StatusErr); ok {
|
|
|
|
if se.Status.Code == http.StatusConflict {
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Infof("Conflict: (%s, %s)", l, v)
|
2014-07-02 20:51:27 +00:00
|
|
|
// This is what we expect.
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
glog.Errorf("Unexpected error putting atomicService: %v", err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
break
|
|
|
|
}
|
2014-07-07 18:44:14 +00:00
|
|
|
glog.Infof("Done update (%s, %s)", l, v)
|
2014-07-02 20:51:27 +00:00
|
|
|
wg.Done()
|
|
|
|
}(label, value)
|
|
|
|
}
|
|
|
|
wg.Wait()
|
2014-08-04 22:52:59 +00:00
|
|
|
if err := c.Get().Path("services").Path(svc.ID).Do().Into(&svc); err != nil {
|
2014-07-02 20:51:27 +00:00
|
|
|
glog.Fatalf("Failed getting atomicService after writers are complete: %v", err)
|
|
|
|
}
|
|
|
|
if !reflect.DeepEqual(testLabels, labels.Set(svc.Selector)) {
|
|
|
|
glog.Fatalf("Selector PUTs were not atomic: wanted %v, got %v", testLabels, svc.Selector)
|
|
|
|
}
|
|
|
|
glog.Info("Atomic PUTs work.")
|
|
|
|
}
|
|
|
|
|
|
|
|
type testFunc func(*client.Client)
|
|
|
|
|
2014-07-01 20:30:19 +00:00
|
|
|
func main() {
|
2014-07-02 20:51:27 +00:00
|
|
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
2014-07-01 20:30:19 +00:00
|
|
|
util.ReallyCrash = true
|
|
|
|
util.InitLogs()
|
|
|
|
defer util.FlushLogs()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
defer util.FlushLogs()
|
|
|
|
time.Sleep(3 * time.Minute)
|
|
|
|
glog.Fatalf("This test has timed out.")
|
|
|
|
}()
|
|
|
|
|
|
|
|
manifestURL := ServeCachedManifestFile()
|
|
|
|
|
|
|
|
apiServerURL := startComponents(manifestURL)
|
|
|
|
|
|
|
|
// Ok. we're good to go.
|
|
|
|
glog.Infof("API Server started on %s", apiServerURL)
|
|
|
|
// Wait for the synchronization threads to come up.
|
|
|
|
time.Sleep(time.Second * 10)
|
|
|
|
|
2014-08-28 13:56:38 +00:00
|
|
|
kubeClient := client.NewOrDie(apiServerURL, nil)
|
2014-07-02 20:51:27 +00:00
|
|
|
|
|
|
|
// Run tests in parallel
|
|
|
|
testFuncs := []testFunc{
|
|
|
|
runReplicationControllerTest,
|
|
|
|
runAtomicPutTest,
|
|
|
|
}
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(len(testFuncs))
|
|
|
|
for i := range testFuncs {
|
|
|
|
f := testFuncs[i]
|
|
|
|
go func() {
|
|
|
|
f(kubeClient)
|
|
|
|
wg.Done()
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
wg.Wait()
|
2014-06-24 01:28:06 +00:00
|
|
|
|
|
|
|
// Check that kubelet tried to make the pods.
|
|
|
|
// Using a set to list unique creation attempts. Our fake is
|
|
|
|
// really stupid, so kubelet tries to create these multiple times.
|
2014-07-01 20:30:19 +00:00
|
|
|
createdPods := util.StringSet{}
|
2014-06-24 23:31:33 +00:00
|
|
|
for _, p := range fakeDocker1.Created {
|
2014-06-24 01:28:06 +00:00
|
|
|
// The last 8 characters are random, so slice them off.
|
2014-06-24 17:19:47 +00:00
|
|
|
if n := len(p); n > 8 {
|
2014-07-01 20:30:19 +00:00
|
|
|
createdPods.Insert(p[:n-8])
|
2014-06-24 01:28:06 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-24 23:31:33 +00:00
|
|
|
for _, p := range fakeDocker2.Created {
|
|
|
|
// The last 8 characters are random, so slice them off.
|
|
|
|
if n := len(p); n > 8 {
|
2014-07-01 20:30:19 +00:00
|
|
|
createdPods.Insert(p[:n-8])
|
2014-06-24 23:31:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// We expect 5: 2 net containers + 2 pods from the replication controller +
|
|
|
|
// 1 net container + 2 pods from the URL.
|
|
|
|
if len(createdPods) != 7 {
|
2014-07-01 20:30:19 +00:00
|
|
|
glog.Fatalf("Unexpected list of created pods:\n\n%#v\n\n%#v\n\n%#v\n\n", createdPods.List(), fakeDocker1.Created, fakeDocker2.Created)
|
2014-06-24 01:28:06 +00:00
|
|
|
}
|
2014-07-02 00:24:17 +00:00
|
|
|
glog.Infof("OK - found created pods: %#v", createdPods.List())
|
2014-06-06 23:40:48 +00:00
|
|
|
}
|
2014-06-24 23:31:33 +00:00
|
|
|
|
2014-07-08 06:30:18 +00:00
|
|
|
// ServeCachedManifestFile serves a file for kubelet to read.
|
2014-06-24 23:31:33 +00:00
|
|
|
func ServeCachedManifestFile() (servingAddress string) {
|
|
|
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if r.URL.Path == "/manifest" {
|
|
|
|
w.Write([]byte(testManifestFile))
|
|
|
|
return
|
|
|
|
}
|
2014-06-25 03:51:57 +00:00
|
|
|
glog.Fatalf("Got request: %#v\n", r)
|
2014-06-24 23:31:33 +00:00
|
|
|
http.NotFound(w, r)
|
|
|
|
}))
|
|
|
|
return server.URL + "/manifest"
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
// This is copied from, and should be kept in sync with:
|
|
|
|
// https://raw.githubusercontent.com/GoogleCloudPlatform/container-vm-guestbook-redis-python/master/manifest.yaml
|
2014-08-04 22:52:59 +00:00
|
|
|
testManifestFile = `version: v1beta2
|
|
|
|
id: container-vm-guestbook
|
2014-06-24 23:31:33 +00:00
|
|
|
containers:
|
|
|
|
- name: redis
|
|
|
|
image: dockerfile/redis
|
|
|
|
volumeMounts:
|
|
|
|
- name: redis-data
|
2014-06-30 23:16:06 +00:00
|
|
|
mountPath: /data
|
2014-06-24 23:31:33 +00:00
|
|
|
|
|
|
|
- name: guestbook
|
|
|
|
image: google/guestbook-python-redis
|
|
|
|
ports:
|
|
|
|
- name: www
|
|
|
|
hostPort: 80
|
|
|
|
containerPort: 80
|
|
|
|
|
|
|
|
volumes:
|
|
|
|
- name: redis-data`
|
|
|
|
)
|